View previous topic :: View next topic |
Author |
Message |
Bill24
Joined: 30 Jun 2012 Posts: 45
|
RTCC stops Timer1 |
Posted: Tue Nov 27, 2012 5:49 am |
|
|
Hi
I am using a PIC18F87K22 and CCS 4.135
My timer1 interrupt routine works unless the RTCC is setup. However I wish to use both.
In my initalize routine I have
Code: |
// Tick Timer
setup_timer_1(T1_INTERNAL|T1_DIV_BY_2);
// Enables internal RTCC
// setup_rtc(RTC_ENABLE,0);
......
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
|
This seems to work fine and my timer ISR gets called OK.
But if the line "setup_rtc(RTC_ENABLE,0);" is uncommented then the ISR is no longer called.
As far as I can see from the data sheet timer 1 and the RTCC are separate.
Any ideas on what I am doing wrong ? |
|
|
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Tue Nov 27, 2012 10:03 am |
|
|
It's likely this is a compiler bug. I'm using 4.137 and I noticed that setup_rtc is generating code that configures Timer 1. I'm not using timer 1, so I haven't (yet) gotten around to analyzing the problem further.
Try swapping the order - setup the RTC first, then timer 1. _________________ Andrew |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Tue Nov 27, 2012 10:18 am |
|
|
The default RTC code assumes you want to use the T1 external oscillator...
The behaviour varies with compiler version. On older compilers you had to explicitly enable/start the secondary oscillator, but the later versions all seem to try to set this up...
Make sure you have RTCOSC_INT selected in the fuses, then setup Timer1 after setting up the RTCC.
Best Wishes |
|
|
Bill24
Joined: 30 Jun 2012 Posts: 45
|
|
Posted: Wed Nov 28, 2012 7:45 am |
|
|
Ttelmah wrote: | The default RTC code assumes you want to use the T1 external oscillator...
The behaviour varies with compiler version. On older compilers you had to explicitly enable/start the secondary oscillator, but the later versions all seem to try to set this up...
Make sure you have RTCOSC_INT selected in the fuses, then setup Timer1 after setting up the RTCC.
Best Wishes |
Using RTCOSC_INT instead of RTCOSC_T1 has brought timer 1 back to life and now interrupts a before.
Does this mean the RTCC is using an internal RC clock rather than the sosc crystal ?
I can relate some of the fuses to bits in the configuration bits as shown in the data sheet but quite a few are guesswork.
E.g I believe #FUSES DEBUG sets CONFIG4L bit 7 but how can I ensure the RTCC is in fact using the external crystal ? |
|
|
|