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 CCS Technical Support

#int_tmr0 Help

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



Joined: 13 Sep 2003
Posts: 87

View user's profile Send private message

#int_tmr0 Help
PostPosted: Thu Dec 18, 2003 7:39 pm     Reply with quote

Hello,

I'm planning to use the RTC of my PIC18F452 to tic every seconds at 20MHz clock.

I put instructions into my code as stated below:
Code:

#int_timer0
timer0_isr() {
   seconds++;            // This interrupt occurs every second
   ticxf = 1;                // set timer flag
   set_timer0(26473); // 26473.5 offset for 1.0s time in DIV_128
}


at my main routine I add this instructions:
Code:

setup_adc_ports(NO_ANALOGS);
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_128);
enable_interrupts(int_timer0);
enable_interrupts(GLOBAL);


My question is... I am correct with my setup in using timer0 that tic every seconds.

Anybody in the community who can provide me with a basic math calculation if in case I change the clock from 20MHz to 6Mhz.

A generic model would help... thank u
Guest








Re: #int_tmr0 Help
PostPosted: Fri Dec 19, 2003 8:18 am     Reply with quote

ritchie wrote:
Hello,

I'm planning to use the RTC of my PIC18F452 to tic every seconds at 20MHz clock.

I put instructions into my code as stated below:
Code:

#int_timer0
timer0_isr() {
   seconds++;            // This interrupt occurs every second
   ticxf = 1;                // set timer flag
   set_timer0(26473); // 26473.5 offset for 1.0s time in DIV_128
}


at my main routine I add this instructions:
Code:

setup_adc_ports(NO_ANALOGS);
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_128);
enable_interrupts(int_timer0);
enable_interrupts(GLOBAL);


My question is... I am correct with my setup in using timer0 that tic every seconds.

Anybody in the community who can provide me with a basic math calculation if in case I change the clock from 20MHz to 6Mhz.

A generic model would help... thank u


If you do a search in this forum for RTC you will find some excellent examples of much better solutions than what you plan to use.
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