hello, is it possible to use a pic 18f4550 in a flowcode program written around a pic 16f887, I have changed the pic to 4550 in the configuration but when compiling to hex I get the following tex, it compiles ok when using a 16f 887
random.c(976:15): error: unknown identifier 'tmr0'
random.c(976:15): error: invalid operand 'tmr0'
random.c(976:13): error: failed to generate expression
random.c success
failure
Return code = 1
Flowcode was unable to compile the flowchart's C code due to the following errors:
I tried to add c code to set up t0con register for timer0 but still came with errors, also have changed some config stings but no joy
pic16f to pic18f
Moderator: Benj
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: pic16f to pic18f
Hi siliconchip,
18F4550 has probably got a 16bit timer0 instead of 8bit.
So adding a l (letter L in lower case) after the 0 should do the trick:
Martin
18F4550 has probably got a 16bit timer0 instead of 8bit.
So adding a l (letter L in lower case) after the 0 should do the trick:
Code: Select all
FCV_TIMER0 = tmr0l;
Martin
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: pic16f to pic18f
wow thanks martin adding l in lower case has done the trick although when I was looking at the 4550 data sheet I was under the impression the timer was available in both 8 and 16 bit, hence that's why i tried setting the T0CON register in an earlier attempt to 8 bit, I believe that in 16 bit mode there is TMROH and TMROL( LOW BYTE, HIGH BYTE), so am I right in thinking that by adding the l to tmro in my code only reads the lower 8 bits of timer0 I would appreciate it if you could explain the reason for adding the lower case l
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: pic16f to pic18f
Hi siliconchip,
I'm not an expert on this but Your correct when you say about timer0 can be 8 or 16bit modes.
You need to use tmr0l if reading from timer0 low byte whether in 8 bit or 16bit mode.
If bit 6 of t0con is set (1 via C code box) then timer0 is in 8 bit mode. This means that interrupt will be serviced when tmr0l rolls over from 255 to 0
If bit 6 of t0con is Reset (0 via C code box) then timer0 is in 16 bit mode. This means that interrupt will be serviced when tmr0l+(tmr0h * 256) rolls over from 65535 to 0
Default settings of T08BIT (Bit 6) t0con with timer0 is 1.Therefore as a default timer 0 is always in 8bit mode.
For 16bit mode you will require a c code block with:
clear_bit(t0con,T08BIT);
Martin
I'm not an expert on this but Your correct when you say about timer0 can be 8 or 16bit modes.
You need to use tmr0l if reading from timer0 low byte whether in 8 bit or 16bit mode.
If bit 6 of t0con is set (1 via C code box) then timer0 is in 8 bit mode. This means that interrupt will be serviced when tmr0l rolls over from 255 to 0
If bit 6 of t0con is Reset (0 via C code box) then timer0 is in 16 bit mode. This means that interrupt will be serviced when tmr0l+(tmr0h * 256) rolls over from 65535 to 0
Default settings of T08BIT (Bit 6) t0con with timer0 is 1.Therefore as a default timer 0 is always in 8bit mode.
For 16bit mode you will require a c code block with:
clear_bit(t0con,T08BIT);
Martin
Martin
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: pic16f to pic18f
Hi siliconchip,
Your welcome.
So long as information helps you thats the main objective.
I have just downloaded your Flowchart, and I have noticed it won't work on hardware.
Reason is your timer0 interrupt is still on the default clock source from T0CKI instead of internal clock which is what it should be set on.
Background debug should also be disabled.
I appreciate flowchart posted is not set up for 18F4550, but when it is please consider what I have said.
Martin
Your welcome.
So long as information helps you thats the main objective.
I have just downloaded your Flowchart, and I have noticed it won't work on hardware.
Reason is your timer0 interrupt is still on the default clock source from T0CKI instead of internal clock which is what it should be set on.
Background debug should also be disabled.
I appreciate flowchart posted is not set up for 18F4550, but when it is please consider what I have said.
Martin
Martin