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

Interrupts on PIC12F609

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



Joined: 04 Jan 2011
Posts: 3

View user's profile Send private message Yahoo Messenger

Interrupts on PIC12F609
PostPosted: Fri Apr 29, 2011 5:44 am     Reply with quote

Hi,
We are currently using the midrange micro PIC12F609. I used the PCWHD wizard to generate a small code that enabled the timer0 interrupt. But this does not seem to be working. Please could you help me out. The code is as below
Code:

#include <12F609.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES IOSC4                    //INTOSC speed 4 MHz
#FUSES NOBROWNOUT               //No brownout reset

#use delay(int=4000000)
#byte STATUS    = 0x03
#bit REG_BANK   = 0x03.5
#byte OPTION_REG = 0x81

#define LED PIN_A1
#define DELAY 1000
#define MAX_SLEEP_CNT   1
         
int8 Sleep_Counter = 0;         

#int_TIMER0
void  TIMER0_isr(void)
{
   Sleep_Counter = 1;   
}


void main()
{
   int8 Toggle = 0;

   setup_timer_0( RTCC_INTERNAL | RTCC_DIV_256 | RTCC_8_bit );            
   setup_comparator( NC_NC_NC_NC );// This device COMP currently not supported by the PICWizard
   enable_interrupts( INT_TIMER0 );
   enable_interrupts( GLOBAL );

    //Example blinking LED program
   while(true){
      if( Sleep_Counter ) {
         Sleep_Counter = 0;
         if( Toggle ) {
            Toggle = 0;
            output_low(LED);
         }
            else {
               Toggle = 1;
                  output_high(LED);
           }          
        }   
     
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 01, 2011 6:25 pm     Reply with quote

Try a more simple program, and use Pin A5 for the LED. See if it works.

Your LED circuit should look like this:
Code:

pin      330 ohms      LED       
A5    ---/\/\/\/------->|----
                            |
                            |
                          -----  Ground 
                           ---
                            -
 

You can use a different resistor value if you don't have 330 ohms.
You could use 220 ohms or 470 ohms.

Here is the test program:
Code:

#include <12F609.h>
#fuses INTRC_IO,IOSC4,NOWDT,NOBROWNOUT
#use delay(clock=4000000)

#define LED PIN_A5

#int_timer0
void  timer0_isr(void)
{
output_toggle(LED);  // Blink the LED
}

//===========================
void main()
{
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256);             

enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);

while(1);
}


If it doesn't work, post your compiler version.
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