pic16f to pic18f

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

pic16f to pic18f

Post by siliconchip »

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
Attachments
random.fcf
(18.86 KiB) Downloaded 258 times

medelec35
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

Post by medelec35 »

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:

Code: Select all

FCV_TIMER0 = tmr0l;
Martin
Martin

siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

Re: pic16f to pic18f

Post by siliconchip »

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

medelec35
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

Post by medelec35 »

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
Martin

siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

Re: pic16f to pic18f

Post by siliconchip »

hi martin once again a big thanks for all your help

medelec35
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

Post by medelec35 »

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
Martin

Post Reply