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

pic16f616 timer 0 interrupt problems

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



Joined: 10 Oct 2011
Posts: 7

View user's profile Send private message

pic16f616 timer 0 interrupt problems
PostPosted: Mon Oct 10, 2011 12:18 pm     Reply with quote

Hi All,
I am having problems running my code on PIC16F616.
I have following simple code where I want to use timer0 int as RTC.
Clock = 8 MHz, hardware int 0 is enabled.
Nothing is working if I enable or add timer0 interrupt code.
I appreciate the help.
===============================


Code:


#include <16F616.h>
#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC                    //Internal RC Osc
#FUSES BROWNOUT_NOSL            //Brownout enabled during operation, disabled during SLEEP

#use delay(clock=8000000)  //int=8000000)

#define KEY1   PIN_C3
#define PUMP   PIN_C2
#define IGN    PIN_C1

void  EXT_isr(void)
{
   intcnt = 0;
}


#int_TIMER0
void  TIMER0_isr(void)
{
//even if i have nothing here
}

void main()
{
   unsigned int x = 0;

   port_A_pullups(0x01);
   setup_adc_ports(sAN3);
   setup_adc(ADC_CLOCK_INTERNAL);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1|RTCC_8_bit);      //128 us overflow
   setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
   enable_interrupts(INT_EXT);
   enable_interrupts(INT_TIMER0);
   enable_interrupts(GLOBAL);
   
   WHILE(1)
     {
           
            OUTPUT_HIGH(IGN);
            OUTPUT_HIGH(PUMP);
            OUTPUT_HIGH(LED1); // = 1;
            for(x = 0;x < 6000;x++)
            {
               ;
            }
            //delay_ms(1000);
            OUTPUT_LOW(IGN);
            OUTPUT_LOW(PUMP);
            OUTPUT_LOW(LED1); // = 1;
            for(x = 0;x < 6000;x++)
            {
               ;
            }
            //delay_ms(1000);
     }


}


Last edited by pic16freak on Mon Oct 10, 2011 12:40 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 10, 2011 12:30 pm     Reply with quote

You need to place an interrupt directive in the line just before the isr
function declaration. This tells the compiler that the routine is an isr
for the specified device.

Download the CCS manual:
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Look in this section for a list of interrupt directives for each peripheral
module, etc.
Quote:

#INT_xxxx
pic16freak



Joined: 10 Oct 2011
Posts: 7

View user's profile Send private message

I have interrupt directive..
PostPosted: Mon Oct 10, 2011 12:42 pm     Reply with quote

Sorry I missed "#" in the code posted..code now modified.
Still nothing works..
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 10, 2011 12:56 pm     Reply with quote

Quote:

unsigned int x = 0;

for(x = 0;x < 6000;x++)

Look in the CCS manual in this section:
Quote:

Basic and Special types

Note the size of an 'int' in CCS. Look at the two tables at the start of
that section.


Also you're still missing the #int_ext directive for your other isr.
pic16freak



Joined: 10 Oct 2011
Posts: 7

View user's profile Send private message

Thank you so much..
PostPosted: Mon Oct 10, 2011 1:17 pm     Reply with quote

As soon as I added #int for the other interrupt,
and changed the data type to int16 from unsigned int, the code started working.
I appreciate the quick replies.
Thank you.
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