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

18f2525, timer1 realtime clock with external 32768hz crystal

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



Joined: 20 Apr 2006
Posts: 6

View user's profile Send private message

18f2525, timer1 realtime clock with external 32768hz crystal
PostPosted: Thu Apr 20, 2006 3:17 pm     Reply with quote

Hello,
I have read a lot of threads about rtc but didn't found how to solve my problem.
I need to use timer1 on 18f2525(operating at 8MhzINTOSC) with external crystal at 32768hz to provide realtime time&data for datalogging purpose.
I need to provide time&date printout via rs232 when interrupt occurs( interrupt will be onchange portb.7 event)
Thanks in advance.
Best regards,
Lubo
P.S.
i want to use timer1 because as written in datasheet it will operate when pic is in sleep mode.
How can i preload the timer1 counter it update itself every 0.5 or 0.1 seconds
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 21, 2006 1:25 am     Reply with quote

Quote:
I need to use timer1 on 18f2525(operating at 8Mhz INTOSC) with
external crystal at 32768hz to provide realtime time.

Look in the Code Library:
http://www.ccsinfo.com/forum/viewtopic.php?t=26177
lubom



Joined: 20 Apr 2006
Posts: 6

View user's profile Send private message

18f2525, timer1 realtime clock with external 32768hz crystal
PostPosted: Fri Apr 21, 2006 2:07 am     Reply with quote

I checked the code in http://www.ccsinfo.com/forum/viewtopic.php?t=26177
Can you please tell me how to modify the following lines of the program to work with external crystal 32kHz connected at T1OSO and T1OSI and what kind of #fuse is needed for it to operate:

#define XTAL_FREQUENCY 20000000
#define TIMER1_FREQUENCY (XTAL_FREQUENCY / 4) // 1 clock tick = 1 instr. cycle =
void Initialize_RTC(void)
{
Ticker = TIMER1_FREQUENCY; // initialize clock counter to number of clocks per second
setup_timer_1( T1_INTERNAL | T1_DIV_BY_1 ); // initialize 16-bit Timer1 to interrupt
// exactly every 65536 clock cycles
// (about 76 times per second)
enable_interrupts( INT_TIMER1 ); // Start RTC
}

Thanks.
Regards,
Lubo
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