Hey all I have my usart setup to read interrupts from the keyboard and transmit ADC readings from my breadboard using my pic. The interrupts are keyboard commands the user can enter that will change the upper and lower limits of my simulated breadboard temperature sensor.
My issue is sometimes my usart just randomly crashes. It freezes up and stops transmitting. This happens when I'm entering in my keyboard inputs, and even sometimes when it is transmitting something mid sentence (like halfway through a printf) and then I press enter and the interrupt seems to crash the usart resulting in an image like the one below.
http://imageshack.us/photo/my-images/5/ftfk.png/
Taking a look at the highlighted line, that is where i pressed enter, to output my stream of characters i had been collecting through the buffer, and it seems to have just cut that output in half and just skipped the interrupt output as well.
What could be the issue here, and what are things i should look for?
Please find samples of the code below
void mainNema( char *nemaSentence) //this function processes my output and prints it out
{
int i;
for (i = 0; i< 20; i++) {
GPGGA_Tokens[i] = '\0';
}
parseNemaSentence(nemaSentence);
i = 0;
while (strcmp(GPGGA_Tokens[i], msgEndOfSentence)!=0) {
printf("\r\ntoken %i: %s\r\n",i, GPGGA_Tokens[i]);
i++;
}
evaluateTokens();
changeNema(token1,token2,token3);
if (token2 == 1)
printf("your new upper limit for channel %i is %i", token1, token3);
else
printf("your new lower limit for channel %i is %i", token1, token3);
}
Below a snippet of the function that reads from ADC converters and prints out "readings" to the user through usart
ConvertADC(); //take value from potentiometer
while(BusyADC() == TRUE)
Delay1TCY();//wait until value is received
sampledValue = ReadADC(); //store value as sampledValue
setCurrentTemperatureForChannel(channelsel, sampledValue); //call function with channelsel and sampledValue
readSwitches(channelsel); //read inputs from pushbuttons
printf ("\n\rcurrent Temp of channel %i is %#x, highlimit is %i, low limit is %i \n\r", (channelsel+1), getCurrentTemperatureForChannel(channelsel),
getUpperLimitForChannel(channelsel),getLowerLimitForChannel(channelsel));