Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

ISR Corruption Issue

$
0
0

Hello, Clancy.  

We were having a problem with I2C (though realistically, it probably affects the whole commBuff ISR, regardless of whether it's I2C or SPI).  What we've narrowed it down to is a switch statement in the ISR.  

We are sending 8 commands per second via I2C and after a while (it ranges from a few minutes to half an hour), the chip appears to lockup.  However, on closer inspection, the chip itself is still running.  However, it appears that some variables in the ADC ISR are being corrupted/changed, causing our CalcDAC routine to fail to run anymore.  The basic code looks like this:

void commBuff_ISR (void) interrupt 6    using 3
{
        unsigned char commData;

EA = 0;    /* Added 04-23-13 */

        commData = COMBUF; /* Read Data from COMBUF */

        if((CommandState!=7)&&(CommandState!=8)&&(CommandState!=10)&&(CommandState!=11)&&(commData==0x24))
        {
                        CommandState = 0;
        }


        switch (CommandState)
        {
                case (0):
                        if (commData == 0x24) /* 0x24 = '$' */
                        {
                                CommandState +=1;
                        }

                        else if (commData == 0x62)      /* 0x62 = 'b' */
                        {
                                COMBUF = DigOut;
                        }
                        break;
                default:
                        break;
        }
EA = 1;    /* Added 04-23-13 */
}
This is just to display the functionality of the code (not the entirety of the code.  We actually have 14 additional switch cases that are not shown here).  What I found is that the switch statement seems to be causing some kind of issue that is causing corruption in the ADC ISR.  If I change the switch statement to an if statement instead, it seems to fix the issue.  
I posted about this in the keil forums (under the name of John Dough. I've had issues with the people in that forum in the past.  At this point, I don't give them my name there anymore):

http://www.keil.com/forum/22943/
 They seem to suggest it's related to the PGA400 itself rather than Keil (personally, I have a hard time believing that but I thought I would talk to you about it).  Do you know anything about this or why it would cause issues between the ISRs?
Any help you can give me would be appreciated.  Thanks!
-Jeremy

Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>