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 disabled during call to prevent re-entrancy:

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



Joined: 18 Jul 2006
Posts: 103

View user's profile Send private message

Interrupts disabled during call to prevent re-entrancy:
PostPosted: Thu Jun 18, 2015 5:17 pm     Reply with quote

Hi All,

It is late and I am tired so I am sure I am missing something that should be obvious.

I am using CCS V4.140 for a PIC16F1939.

When I compile the program I get the following error.
Code:

>>> Warning 216 "Timer.c" Line 2257(0,1): Interrupts disabled during call to prevent re-entrancy:  (@DIV1616)


I have the following variables declared.

Code:
//
//
//      8 BIT INTEGERS
//
int8 Econ1Counter;      // Used for the Economy mode counter for timer 1
int8 Econ2Counter;      // Used for the Economy mode counter for timer 2
int8 Econ3Counter;      // Used for the Economy mode counter for timer 3
int8 Econ4Counter;      // Used for the Economy mode counter for timer 4
int8 Econ1Preset;      // Set to hold the Preset Value EconCounter1 is counting up too
int8 Econ2Preset;      // Set to hold the Preset Value EconCounter2 is counting up too
int8 Econ3Preset;      // Set to hold the Preset Value EconCounter3 is counting up too
int8 Econ4Preset;      // Set to hold the Preset Value EconCounter4 is counting up too

int8 i,j,k, loops ;      // loop increment variables
int8 cx,cy;            // used for cursor loaction
int8 ScrollCount;      // Counter used for scroll delay
int8 TMR;            // Current Timer Displayed
int8 Program;         // Current Program Running
int8 Economy;         // Current Economy Setting
int8 PB_Test_New;      // PB Input Test (see if same buttons pressed)
int8 PB_Test_Old;      // Keeps track of the last state of the PB
int8 Function;         // Function that is selected
int8 CursorLocation;   // Location of the cursor
int8 OldPageNumber;      // Used to see if page change was requested
int8 PageNumber;      // Keeps track of what Page you are on
                  // PageNumber = 1  "Main Page"
                  // PageNumber = 2  "Edit Page"
                  // PageNumber = 3  "Purge Page
                  // PageNumber = 4  "Program Page
                  // PageNumber = 5  "Timer Page

//
//   16 BIT INTEGERS
//
// int16   GluePulse;      // Pulse width of Glue1 in Economy mode
int16   FPM;            // Feet per minute
int16   LowSpeed;         // Low Speed Cut off value
int16   PB_Deb_value;      // Debounce Preset Value for fast or slow debounce
int16   PB_Deb;            // PB Debounce
// int16   LowSpeedCounter;   // Counter for low speed cut off
// int16   PulseCounter;   // Pulse timer for economy mode
int16   FPM_Counter;      // Counter input
int16   T1_Counter;         // Timer1 Pulse Counter
int16   T2_Counter;         // Timer2 Pulse Counter
int16   T3_Counter;         // Timer3 Pulse Counter
int16   T4_Counter;         // Timer4 Pulse Counter






//
//      ARRAYS
//
int16   Timer[24];   // Current Timer values,      [0]=T1D1,  [1]=T1G1  [2]=T1D2  [3]=T1G2  [4]=T1D3  [5]=T1G3
               //                      [6]=T2D1,  [7]=T2G1  [8]=T2D2  [9]=T2G2 [10]=T2D3 [11]=T2G3
               //                     [12]=T3D1, [13]=T3G1 [14]=T3D2 [15]=T3G2 [16]=T3D3 [17]=T3G3
               //                     [18]=T4D1, [19]=T4G1 [20]=T4D2 [21]=T4G2 [22]=T4D3 [23]=T4G3
int8   Digits[5];   // Used to break up timer values into digits
//
//
//


//
//   STATUS BIT REGISTERS
//
int8   StatusBits1;               // Status Bits - first bank
#bit   NewButton = StatusBits1.0      // Push Button is pressed
#bit   PB1_Held_Slow = StatusBits1.1   // Set when PB1 held for short time
#bit   PB1_Held_Fast = StatusBits1.2   // Set when PB1 held for long time
#bit   PB2_Held_Slow = StatusBits1.3   // Set when PB2 held for short time
#bit   PB2_Held_Fast = StatusBits1.4   // Set when PB2 held for long time
#bit   UpdateValue = StatusBits1.5      // Set when the value is to be updated      

int8   StatusBits2;               // Status Bits - second bank
#bit   ChangingValues = StatusBits2.0   // Set when the value are being changed
#bit    CountDone = StatusBits2.1      // Set when Timer2 times out and Encoder Pulse count is stopped

int8   StatusBits3;               //  Status Bits - third bank
#bit   TRIG1 = StatusBits3.0         //   Set when Trigger 1 is first on.
#bit   TRIG2 = StatusBits3.1         //   Set when Trigger 2 is first on.
#bit   TRIG3 = StatusBits3.2         //   Set when Trigger 3 is first on.
#bit   TRIG4 = StatusBits3.3         //   Set when Trigger 4 is first on.
#bit   Timer1Running = StatusBits3.4   //  Set when Timer 1 is running.
#bit   Timer2Running = StatusBits3.5   //  Set when Timer 2 is running.
#bit   Timer3Running = StatusBits3.6   //  Set when Timer 3 is running.
#bit   Timer4Running = StatusBits3.7   //  Set when Timer 4 is running.

int8   StatusBits4;
#bit   T1D1_Running = StatusBits4.0   //   Set when Timer1 Delay 1 is active
#bit   T1G1_Running = StatusBits4.1   //   Set when Timer1 Glue 1 is active
#bit   T1D2_Running = StatusBits4.2   //   Set when Timer1 Delay 2 is active
#bit   T1G2_Running = StatusBits4.3   //   Set when Timer1 Glue 2 is active
#bit   T1D3_Running = StatusBits4.4   //   Set when Timer1 Delay 3 is active
#bit   T1G3_Running = StatusBits4.5   //   Set when Timer1 Glue 3 is active
#bit   T1Glueing = StatusBits4.6      //   Set when Timer1 is in the Glueing Stages

int8   StatusBits5;
#bit   T2D1_Running = StatusBits5.0   //   Set when Timer2 Delay 1 is active
#bit   T2G1_Running = StatusBits5.1   //   Set when Timer2 Glue 1 is active
#bit   T2D2_Running = StatusBits5.2   //   Set when Timer2 Delay 2 is active
#bit   T2G2_Running = StatusBits5.3   //   Set when Timer2 Glue 2 is active
#bit   T2D3_Running = StatusBits5.4   //   Set when Timer2 Delay 3 is active
#bit   T2G3_Running = StatusBits5.5   //   Set when Timer2 Glue 3 is active
#bit   T2Glueing = StatusBits5.6      //   Set when Timer2 is in the Glueing Stages

int8   StatusBits6;
#bit   T3D1_Running = StatusBits6.0   //   Set when Timer3 Delay 1 is active
#bit   T3G1_Running = StatusBits6.1   //   Set when Timer3 Glue 1 is active
#bit   T3D2_Running = StatusBits6.2   //   Set when Timer3 Delay 2 is active
#bit   T3G2_Running = StatusBits6.3   //   Set when Timer3 Glue 2 is active
#bit   T3D3_Running = StatusBits6.4   //   Set when Timer3 Delay 3 is active
#bit   T3G3_Running = StatusBits6.5   //   Set when Timer3 Glue 3 is active
#bit   T3Glueing = StatusBits6.6      //   Set when Timer3 is in the Glueing Stages

int8   StatusBits7;
#bit   T4D1_Running = StatusBits7.0   //   Set when Timer4 Delay 1 is active
#bit   T4G1_Running = StatusBits7.1   //   Set when Timer4 Glue 1 is active
#bit   T4D2_Running = StatusBits7.2   //   Set when Timer4 Delay 2 is active
#bit   T4G2_Running = StatusBits7.3   //   Set when Timer4 Glue 2 is active
#bit   T4D3_Running = StatusBits7.4   //   Set when Timer4 Delay 3 is active
#bit   T4G3_Running = StatusBits7.5   //   Set when Timer4 Glue 3 is active
#bit   T4Glueing = StatusBits7.6      //   Set when Timer4 is in the Glueing Stages

int8   StatusBits8;
#bit   Timer1Start = StatusBits8.0      // Used to show Timer 1 has started
#bit   Timer2Start = StatusBits8.1      // Used to show Timer 2 has started
#bit   Timer3Start = StatusBits8.2      // Used to show Timer 3 has started
#bit   Timer4Start = StatusBits8.3      // Used to show Timer 4 has started
#bit   Econ1Glue = StatusBits8.4      // Set when Economy Mode is allowing Glue1 output to be on
#bit   Econ2Glue = StatusBits8.5      // Set when Economy Mode is allowing Glue2 output to be on
#bit   Econ3Glue = StatusBits8.6      // Set when Economy Mode is allowing Glue3 output to be on
#bit   Econ4Glue = StatusBits8.7      // Set when Economy Mode is allowing Glue4 output to be on


If I remove the first eight int8 variables. (see below)
Code:

int8 Econ1Counter;      // Used for the Economy mode counter for timer 1
int8 Econ2Counter;      // Used for the Economy mode counter for timer 2
int8 Econ3Counter;      // Used for the Economy mode counter for timer 3
int8 Econ4Counter;      // Used for the Economy mode counter for timer 4
int8 Econ1Preset;      // Set to hold the Preset Value EconCounter1 is counting up too
int8 Econ2Preset;      // Set to hold the Preset Value EconCounter2 is counting up too
int8 Econ3Preset;      // Set to hold the Preset Value EconCounter3 is counting up too
int8 Econ4Preset;      // Set to hold the Preset Value EconCounter4 is counting up too


The error goes away but as soon as I add just one of them the error comes back.

I have looked at the Memory usage in the .lst file but it looks like I have plenty of room. Here is the first few lines of the .lst file.

Code:

CCS PCM C Compiler, Version 4.140, 7689               18-Jun-15 18:56

               Filename:   X:\Eds docs\Data\Customer Files\P-plus\DPC-VS4\Code\F1939\Timer.lst

               ROM used:   7896 words (48%)
                           Largest free fragment is 2048
               RAM used:   112 (11%) at main() level
                           137 (13%) worst case
               Stack:     9 worst case (7 in main + 2 for interrupts)


Is it possible I am declaring to many global variables?

Thanks in advance for any help.
drolleman



Joined: 03 Feb 2011
Posts: 116

View user's profile Send private message

PostPosted: Thu Jun 18, 2015 5:35 pm     Reply with quote

show full code

but, this usually because you call a function that is also used by an interrupt. you can't do that. functions like #timer0 above them can't be called by your program. so while you call the function the interrupt is disabled.
edbfmi1



Joined: 18 Jul 2006
Posts: 103

View user's profile Send private message

PostPosted: Thu Jun 18, 2015 5:47 pm     Reply with quote

Thanks for the quick reply.

I left the office so I can't post the full code.

I am just confused that it compiled and ran just fine until I added the 8 new int8 variables at the top. I didn't even use them yet. I was just declaring them to use them in the next part of the code I was writing.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 18, 2015 6:22 pm     Reply with quote

Yes, but post the timer interrupt routine that causes this error:
Quote:

Interrupts disabled during call to prevent re-entrancy: (@DIV1616)
edbfmi1



Joined: 18 Jul 2006
Posts: 103

View user's profile Send private message

PostPosted: Thu Jun 18, 2015 6:59 pm     Reply with quote

Thanks for the input!

I went back into the office and did a little more digging into my program with your suggestion about the timer interrupt in mind. I also dug into the forum a little deeper and found some good posts that had to do with division and interrupts. I was able to rewrite my code using simpler binary manipulations and got rid of a rather nasty division calculation in the interrupt routine.

That cleared up the warning.

Thanks again all for the quick replies. Now I will be able to get a decent nights sleep without stewing on it all night.

You all are the best!!
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Fri Jun 19, 2015 1:59 am     Reply with quote

I see you've sussed it , but it probably doesn't hurt saying it again:

It's not an "error" it's a "warning". There's a difference.

The warning is telling you that a routine, 16 by 16 bit integer divide, is used in both an ISR and the main code. As routines cannot be re-entrant, and thus cannot be interrupted by something that might re-enter the routine, the compiler has disabled interrupts around the sections of main code that have the routine, making them critical sections.

Your code will compile and run "correctly" with the warnings. If it was an error, the code wouldn't even compile. Whether the probably slight performance hit is a problem for you, only you can say. In general I try to avoid such warnings.

Be aware that in this case this is not a routine you've written (though the same will happen with your own code), its a maths routine used by the compiler to implement a particular form of division.
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