18f2525, timer1 realtime clock with external 32768hz crystal
Posted: Thu Apr 20, 2006 3:17 pm
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
Posted: Fri Apr 21, 2006 1:25 am
Quote:
I need to use timer1 on 18f2525(operating at 8Mhz INTOSC) with
external crystal at 32768hz to provide realtime time.
18f2525, timer1 realtime clock with external 32768hz crystal
Posted: Fri Apr 21, 2006 2:07 am
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
}
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