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

Compiler V4 to V5 -- Interrupt Problem

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



Joined: 23 Jun 2004
Posts: 24

View user's profile Send private message

Compiler V4 to V5 -- Interrupt Problem
PostPosted: Fri Oct 11, 2013 8:01 am     Reply with quote

Just kind of looking into this right now.

I have an interrupt on Timer 0 and Timer 1 -- neither are working now since I updated to V5.

Using a PIC16F887.

I'll look into it with debugging and try compiling the project using V4 and V5 -- then comparing .lst files to see what has changed.

Anyone else experience this?

Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 11, 2013 11:28 am     Reply with quote

Post a short compilable test program and post your compiler version.
Then we can test it.
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Fri Oct 11, 2013 12:36 pm     Reply with quote

As PCM_Programmer says 'versions'?.

'V4', covers over 100 compiler versions, and there were some significant changes in the early V4.1xx area.

Are you using the default CCS behaviours, or doing any 'DIY' work on the registers?. If the latter, then try using #DEVICE CCS4. This puts the handler behaviour back to V4 modes.

Are you confident the chip is running other than the interrupt?. Some of the _default_ values for fuses have changed. Check the fuses at the end of the .lst file, and see if anything here is different.

Generally, 99%+ of code that runs with 4.141, will directly work with V5 versions. However it has re-introduced a problem that existed a few versions ago, with on some chips, GIE being left turned off if you use sprintf (thread about this a few days ago). It is possible that your code is exhibiting this.

Best Wishes
jpage



Joined: 23 Jun 2004
Posts: 24

View user's profile Send private message

PostPosted: Fri Oct 11, 2013 1:38 pm     Reply with quote

Using Compiler V5.012 -- was using V4.132
PIC16F887

Wrote this test code for Timer1 -- (of course) it works fine when complied with V5.012.

So -- I will look into it further.

Ttelmah -- I did try the #DEVICE CCS4 earlier on the original code and it did not have an effect.
I will check out and compare .lst files too.

I'll keep you posted.
Thanks.


Code:

#include <16f887.h>
#fuses HS,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOFCMEN,NOCPD,NOWDT,BORV21
#use delay (clock=20000000)

#define Alarm2_LED    PIN_B0      //Alarm A2
#define Alarm1_LED    PIN_B1      //Alarm A1
#define INTS_PER_SECOND_1 10     //For Timer1  (16 bit)
#define TIME_OUT 5         //5 Second Timeout ON/OFF LED Cycle


int1 int_flag = FALSE;
int int_count_1 = 0;           // Number of interrupts left
long seconds_1 = 0;           // A running seconds counter  Timer 1


void main(){

   //Timer1 Setup -- will increment every 1.6us and overflow every 104.85 ms (1.6us*65535) -- set TIME_OUT at 5 (seconds)
   int_count_1 = INTS_PER_SECOND_1;
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
   set_timer1(0);// Set Timer1 to 0
   seconds_1 = 0;////Seconds Counter -- Increments by 1 every 10 (INT_TIMER1)Interrupts   

   //Initialize LEDs and Relays
   output_low(Alarm1_LED);
   output_low(Alarm2_LED);

   enable_interrupts(INT_TIMER1);
   enable_interrupts(GLOBAL);


   while(1){

      if (int_flag == TRUE){
         output_high(Alarm1_LED);
         output_high(Alarm2_LED);
      }
      else{
         output_low(Alarm1_LED);
         output_low(Alarm2_LED);
      }   
   }

}
/***************************************************************************************************/
/* Function: timer1_isr()                                                                      */
/* Args:   None                                                               */
/* Returns:   None                                                               */
/* Purpose: Interrupt Timer 1 Service Routine                                          */
/*                                                                            */
/*                                                                           */
/*                                                                           */
/****************************************************************************************************/
   #INT_TIMER1
   void timer1_isr()
   {                                 
   if(--int_count_1 == 0){
      ++seconds_1;
      int_count_1 = INTS_PER_SECOND_1;
      } 
   
   if (seconds_1 >= TIME_OUT){
         if(int_flag == TRUE)
            int_flag = FALSE;
         else
            int_flag = TRUE;

      seconds_1 = 0;      
      }
   
   }
jpage



Joined: 23 Jun 2004
Posts: 24

View user's profile Send private message

PostPosted: Mon Oct 14, 2013 2:33 pm     Reply with quote

PCM programmer wrote:
Post a short compilable test program and post your compiler version.
Then we can test it.


Can you please try testing using sample code: With and Without #define FPRINT
The fprintf() is turning off the GIE bit and not allowing the timer1 interrupt to function.
I'm using a PIC16F887 and compiler Version 5.012

Code:

/*

Desciption:
Cycles Alarm1 and Alarm2 LEDs ON/OFF every 5 seconds using Timer1 interrupt

*/

#include <16f887.h>
#fuses HS,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOFCMEN,NOCPD,NOWDT,BORV21
#use delay (clock=20000000)

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, stream = RADIO) //Use for radio9600

#define Alarm2_LED    PIN_B0      //Alarm A2
#define Alarm1_LED    PIN_B1      //Alarm A1
#define INTS_PER_SECOND_1 10     //For Timer1  (16 bit)
#define TIME_OUT 5         //5 Second Timeout between ON/OFF LED Cycle

#define FPRINT   //Enable to see effect of fprintf() on GIE bit in INTCON register (Bit 7)



int1 int_flag = FALSE;
int int_count_1 = 0;           // Number of interrupts left before a second has elapsed ==> Timer 1
long seconds_1 = 0;           // A running seconds counter  ==> Timer 1



void main(){

   //Timer1 Setup -- will increment every 1.6us and overflow every 104.85 ms (1.6us*65535) -- set TIME_OUT at 5 (seconds)
   int_count_1 = INTS_PER_SECOND_1;
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
   set_timer1(0);// Set Timer1 to 0
   seconds_1 = 0;////Seconds Counter -- Increments by 1 every 10 (INT_TIMER1)Interrupts   

   //Initialize LEDs and Relays
   output_low(Alarm1_LED);
   output_low(Alarm2_LED);

   enable_interrupts(INT_TIMER1);
   enable_interrupts(GLOBAL);

   //if #define FPRINT -- turns off GIE and does not allow Timer1 interupt
   #ifdef FRINT
   fprintf(RADIO, "ATCN\r");//Send AT Command to Radio
   #endif

   while(1){

      if (int_flag == TRUE){
         output_high(Alarm1_LED);
         output_high(Alarm2_LED);
      }
      else{
         output_low(Alarm1_LED);
         output_low(Alarm2_LED);
      }   
   }

}
/***************************************************************************************************/
/* Function: timer1_isr()                                                                      */
/* Args:   None                                                               */
/* Returns:   None                                                               */
/* Purpose: Interrupt Timer 1 Service Routine                                          */
/*                                                                            */
/*                                                                           */
/*                                                                           */
/****************************************************************************************************/
   #INT_TIMER1
   void timer1_isr()
   {                                 
   if(--int_count_1 == 0){
      ++seconds_1;
      int_count_1 = INTS_PER_SECOND_1;
      } 
   
   if (seconds_1 >= TIME_OUT){
         if(int_flag == TRUE)
            int_flag = FALSE;
         else
            int_flag = TRUE;

      seconds_1 = 0;      
      }
   
   }


Thanks. J
jpage



Joined: 23 Jun 2004
Posts: 24

View user's profile Send private message

PostPosted: Mon Oct 14, 2013 2:35 pm     Reply with quote

Ttelmah wrote:
As PCM_Programmer says 'versions'?.

'V4', covers over 100 compiler versions, and there were some significant changes in the early V4.1xx area.

Are you using the default CCS behaviours, or doing any 'DIY' work on the registers?. If the latter, then try using #DEVICE CCS4. This puts the handler behaviour back to V4 modes.

Are you confident the chip is running other than the interrupt?. Some of the _default_ values for fuses have changed. Check the fuses at the end of the .lst file, and see if anything here is different.

Generally, 99%+ of code that runs with 4.141, will directly work with V5 versions. However it has re-introduced a problem that existed a few versions ago, with on some chips, GIE being left turned off if you use sprintf (thread about this a few days ago). It is possible that your code is exhibiting this.

Best Wishes


Thanks for the suggestion on the GIE bit -- I think that's it.
Just waiting on CCS to confirm it.

J
jpage



Joined: 23 Jun 2004
Posts: 24

View user's profile Send private message

[SOLVED] Compiler V4 to V5 -- Interrupt Problem
PostPosted: Mon Oct 21, 2013 8:48 am     Reply with quote

From CCS:

Quote:


The problem you reported has been fixed and will be in the next compiler release.

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