This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS / MSP430FR5994:MSP-EXP430FR5994

Part Number: MSP430FR5994


Tool/software: Code Composer Studio

Hello, 

I have a problem using while loop comined with an if-instruction. The if-instruction in the while-loop isn't called, even though the "volotile unsigned int Sampling == 1"" -> the condition is true.

while(1)
{
__delay_cycles(1); // DCO clock cycles
if(Sampling == 1)
{
Start = 1;

ADC12CTL0 |= ADC12ENC | ADC12SC; // Start sampling/conversion
Spannung = Spannung_func(Messwert);
Messwert_ppm = Messwert_ppm_func(Spannung);
ADC12CTL0 &= ~ADC12ENC; // Disable conversion
Sampling = 0;
// For debugger
}
__bis_SR_register(LPM0_bits | GIE); // LPM0, ADC12_ISR will force exit //muss hier in while Schleife stehen bleine, sonst geht gar nichts
__no_operation();
}

  • How do you know that the if() block isn't being executed? 

    Are you using the compiler Optimizer? That can create some illusions in the debugger.

    > ADC12CTL0 &= ~ADC12ENC; // Disable conversion

    Depending on how long those two functions take to run, this might be stopping the conversion in the middle. The effects of doing this vary based on your ADC configuration [Ref User Guide (SLAU367O) Sec 34.2.8.6], but none of the cases is very useful. My suggestion is to not do this at all -- rather wait for the ADC to finish.

  • For the source file that contains this code ...

    user6336085 said:
    The if-instruction in the while-loop isn't called, even though the "volotile unsigned int Sampling == 1"" -> the condition is true.

    ... please follow the directions in the article How to Submit a Compiler Test Case.

    Thanks and regards,

    -George