|
|
View previous topic :: View next topic |
Author |
Message |
Kari Guest
|
Defining Timer0 to 8bit on 18F452 |
Posted: Mon Dec 29, 2003 4:25 am |
|
|
Even if I define Timer0 to 8bit,
"setup_timer_0(RTCC_EXT_H_TO_L|RTCC_8_BIT);"
"printf(lcd_putc,"%03u",get_rtcc());" is not working. Compiler says "print format type is invalid". GET_RTCC() returns still long int because "printf(lcd_putc,"%03lu",get_rtcc());" is working. Is there something else to remember to define RTCC to 8bit?
PCWH is 3.180
Regards Kari, Finland |
|
|
Ttelmah Guest
|
Re: Defining Timer0 to 8bit on 18F452 |
Posted: Mon Dec 29, 2003 5:25 am |
|
|
Kari wrote: | Even if I define Timer0 to 8bit,
"setup_timer_0(RTCC_EXT_H_TO_L|RTCC_8_BIT);"
"printf(lcd_putc,"%03u",get_rtcc());" is not working. Compiler says "print format type is invalid". GET_RTCC() returns still long int because "printf(lcd_putc,"%03lu",get_rtcc());" is working. Is there something else to remember to define RTCC to 8bit?
PCWH is 3.180
Regards Kari, Finland |
'u', only supports an integer (8 bit). You have told the compiler to return a 16bit value for 'get_rtcc'. You need to use 'lu'.
Best Wishes |
|
|
Kari Guest
|
|
Posted: Mon Dec 29, 2003 5:58 am |
|
|
I have defined timer0 to work in 8-bit mode with this line:
setup_timer_0(RTCC_EXT_H_TO_L|RTCC_8_BIT);
Register value from asm listing is correct (0xF0).
Kari |
|
|
Ttelmah Guest
|
|
Posted: Mon Dec 29, 2003 7:20 am |
|
|
Kari wrote: | I have defined timer0 to work in 8-bit mode with this line:
setup_timer_0(RTCC_EXT_H_TO_L|RTCC_8_BIT);
Register value from asm listing is correct (0xF0).
Kari |
You are operating the timer in 8bit 'mode', but the _function_, returns a 16bit value, because the timer supports this. Hence you either have to use a long declaration, or retrieve the low byte only.
This would work:
printf(lcd_putc,"%03u",(int8)get_rtcc());
Best Wishes |
|
|
Kari Guest
|
|
Posted: Mon Dec 29, 2003 7:44 am |
|
|
Ok thanks, now I know it. I am moving from 16f877 to 18f452 and looking for easiest way to change code for it.
kari |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|