CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Defining Timer0 to 8bit on 18F452

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Kari
Guest







Defining Timer0 to 8bit on 18F452
PostPosted: Mon Dec 29, 2003 4:25 am     Reply with quote

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
PostPosted: Mon Dec 29, 2003 5:25 am     Reply with quote

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







PostPosted: Mon Dec 29, 2003 5:58 am     Reply with quote

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







PostPosted: Mon Dec 29, 2003 7:20 am     Reply with quote

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







PostPosted: Mon Dec 29, 2003 7:44 am     Reply with quote

Ok thanks, now I know it. I am moving from 16f877 to 18f452 and looking for easiest way to change code for it.

kari
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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