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

RTCC stops Timer1

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



Joined: 30 Jun 2012
Posts: 45

View user's profile Send private message

RTCC stops Timer1
PostPosted: Tue Nov 27, 2012 5:49 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Tue Nov 27, 2012 10:03 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Nov 27, 2012 10:18 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 28, 2012 7:45 am     Reply with quote

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 ?
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