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 support@ccsinfo.com

Timer 1 not interrupting (PIC12F629 with 32kHz crystal)

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



Joined: 19 Oct 2003
Posts: 24
Location: Cambridge, UK

View user's profile Send private message Send e-mail

Timer 1 not interrupting (PIC12F629 with 32kHz crystal)
PostPosted: Mon Mar 29, 2004 4:16 pm     Reply with quote

Hi,

PIC = 12F629
Clock = 32kHz crystal (LP mode)
PCM = V3.153

Using MPLAB 6.4 & simulator, I cannot get timer 1 to fire.

Here's the simple code:-


Code:

#include <12F629.h>
#use delay(clock=32768)
#fuses LP,BROWNOUT,NOWDT,PUT

#int_TIMER1
TIMER1_isr() {

a++;

}

void main() {

      setup_counters(RTCC_INTERNAL,RTCC_DIV_32);
      setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
      setup_comparator(FALSE);
      setup_vref(FALSE);

      enable_interrupts(INT_TIMER1);
      enable_interrupts(global);

   while(1){}

}




Any pointers appreciated!, thanks.

Regards,
Darren
valemike
Guest







PostPosted: Mon Mar 29, 2004 4:26 pm     Reply with quote

When I use an external (not on osc1 and osc2, but rather on rc0 and rc1) 32Khz clock for Timer1, this code works:

Code:
   setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1 | T1_CLK_OUT);
    enable_interrupts(INT_TIMER1);
    enable_interrupts(GLOBAL);


But when i use an external 4MHz clock, this is what works:

Code:
   setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
   set_timer1(0);
dazlogan



Joined: 19 Oct 2003
Posts: 24
Location: Cambridge, UK

View user's profile Send private message Send e-mail

8-)
PostPosted: Tue Mar 30, 2004 1:28 am     Reply with quote

It seems to be working now, i am getting an 8 second interrupt which is correct.

Now how do I get the chip to wake up from sleep on a timer 1 interrupt?

Thanks

Regards,
Darren
dazlogan



Joined: 19 Oct 2003
Posts: 24
Location: Cambridge, UK

View user's profile Send private message Send e-mail

code
PostPosted: Tue Mar 30, 2004 1:36 am     Reply with quote

here's the code by the way which works:

Code:

int a;

// timer 1 interrupt, triggers every 8 seconds
#int_TIMER1
TIMER1_isr() {

   a++;

}


// main function
void main() {

   #byte CMCON=0X19
   #byte INTCON=0X0B

      setup_counters(RTCC_INTERNAL,RTCC_DIV_32);
      setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
   set_timer1(0);
      setup_comparator(FALSE);
      setup_vref(FALSE);

   CMCON=0x07;
   INTCON|=0XC0;

      enable_interrupts(INT_TIMER1);
      enable_interrupts(global);

   while(1){
      //a++;
      //sleep();
   }

}



The INTCON|=0XC0 made the difference.

But I still need to wake up from sleep.

Thanks

Regards,
Darren
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