0

キーボードから割り込みを読み取り、pic を使用してブレッドボードから ADC の読み取り値を送信するように、usart をセットアップしました。割り込みは、シミュレートされたブレッドボード温度センサーの上限と下限を変更する、ユーザーが入力できるキーボード コマンドです。

私の問題は、usart がランダムにクラッシュすることがあります。フリーズして送信を停止します。これは、キーボード入力を入力しているときに発生し、文の途中 (printf の途中など) で何かを送信しているときに発生し、Enter キーを押すと、割り込みによって usart がクラッシュしたように見え、次のような画像が表示されます。 .

http://imageshack.us/photo/my-images/5/ftfk.png/

強調表示された行、つまりエンターを押した場所を見て、バッファを介して収集していた文字のストリームを出力すると、その出力が半分にカットされ、割り込み出力もスキップされたようです。

ここで何が問題になる可能性があり、何を探す必要がありますか?

以下のコードのサンプルを見つけてください

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);


}

以下は、ADC コンバーターから読み取り、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));       
4

1 に答える 1