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.

MSP430FR5989: FlowESI code generated incorrectly.

Part Number: MSP430FR5989

Hi everyone,

I am working on an ESI project, and we have generated the design skeleton and files using the FlowESI GUI version 1_01_00_04.
We have found some possible errors that we would like to share with you. We need to know if they are errors and how they have to be fixed:
1º. According to this file ../ESIConfig/esiCalibration.c
...
sensorState = ESI_getLatchedComparatorOutput(CHANNEL_0_PPU_SELECT | CHANNEL_1_PPU_SELECT);
switch(sensorState)
{
    case 0x00:
        afe2MaxDACCH0 += ESI_getAFE2DACValue(CHANNEL_0_DAC2_UPPER_REGISTER);
        break;
    case 0x01:
        afe2MinDACCH1 += ESI_getAFE2DACValue(CHANNEL_1_DAC2_LOWER_REGISTER);
        break;
    case 0x02:
        afe2MaxDACCH1 += ESI_getAFE2DACValue(CHANNEL_1_DAC2_UPPER_REGISTER);
        break;
    case 0x03:
        afe2MaxDACCH0 += ESI_getAFE2DACValue(CHANNEL_0_DAC2_UPPER_REGISTER);
        break;default:    break;
}
...
 
These two cases are the same, therefore we have the suspicion that they are wrong, but we don't know they have to be changed.
I would like to understand why for example afe2MaxDACCH1 is placed after the case 0x02. I need to understand that in order to check that is the right place. I don't know if I have to change this or not. Basically, we need to understand what sensorState means.
...
case 0x00:
    afe2MaxDACCH0 += ESI_getAFE2DACValue(CHANNEL_0_DAC2_UPPER_REGISTER);
    break;
...
For this:
...
case 0x00:
    afe2MinDACCH0 += ESI_getAFE2DACValue(CHANNEL_0_DAC2_LOWER_REGISTER);
    break;
...
2º. According to the same file ../ESIConfig/esiCalibration.c
...
// this for loop is to find an initial DAC value for ch0 and ch1
for(i = 0; i<fsParam->range; i++) // test "rangeNum" times as 12 bit DAC
{

    __bis_SR_register(LPM3_bits+GIE);   // wait for the ESISTOP flag


    if(fsParam->channel0Enabled==true){
        if (!(ESI_getLatchedComparatorOutput(ESI_AFE2_CHANNEL1_SELECT))){
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_0_DAC2_UPPER_REGISTER) + dACBit,CHANNEL_0_DAC2_UPPER_REGISTER);
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_0_DAC2_LOWER_REGISTER) + dACBit,CHANNEL_0_DAC2_LOWER_REGISTER);
        } else{
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_0_DAC2_UPPER_REGISTER) - dACBit,CHANNEL_0_DAC2_UPPER_REGISTER);
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_0_DAC2_LOWER_REGISTER) - dACBit,CHANNEL_0_DAC2_LOWER_REGISTER);
        }
    }

    if(fsParam->channel1Enabled==true){
        if (!(ESI_getLatchedComparatorOutput(ESI_AFE2_CHANNEL2_SELECT))){
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_1_DAC2_UPPER_REGISTER) + dACBit,CHANNEL_1_DAC2_UPPER_REGISTER);
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_1_DAC2_LOWER_REGISTER) + dACBit,CHANNEL_1_DAC2_LOWER_REGISTER);
        } else {
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_1_DAC2_UPPER_REGISTER) - dACBit,CHANNEL_1_DAC2_UPPER_REGISTER);
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_1_DAC2_LOWER_REGISTER) - dACBit,CHANNEL_1_DAC2_LOWER_REGISTER);
        }
    }

    if(fsParam->channel2Enabled==true){
        if (!(ESI_getLatchedComparatorOutput(ESI_AFE2_CHANNEL3_SELECT))){
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_2_DAC2_UPPER_REGISTER) + dACBit,CHANNEL_2_DAC2_UPPER_REGISTER);
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_2_DAC2_LOWER_REGISTER) + dACBit,CHANNEL_2_DAC2_LOWER_REGISTER);
        } else {
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_2_DAC2_UPPER_REGISTER) - dACBit,CHANNEL_2_DAC2_UPPER_REGISTER);
            ESI_setAFE2DACValue(ESI_getAFE2DACValue(CHANNEL_2_DAC2_LOWER_REGISTER) - dACBit,CHANNEL_2_DAC2_LOWER_REGISTER);
        }
    }


    dACBit >>= 1;
}

}
...
We think that they have to be: ESI_AFE2_CHANNEL0_SELECT instead of ESI_AFE2_CHANNEL1_SELECT and so on. Would you mind checking that and tell us what is the right code?
Thank you very much for your help.
Best regards.
  • Hello,

    These two cases are the same, therefore we have the suspicion that they are wrong, but we don't know they have to be changed.
    I would like to understand why for example afe2MaxDACCH1 is placed after the case 0x02. I need to understand that in order to check that is the right place. I don't know if I have to change this or not. Basically, we need to understand what sensorState means.

    The order of the states seem to match the states defined in the LC Sensor Rotation Detection With MSP430 Extended Scan Interface (ESI). The state machine diagram in Figure 14 may help.

    ...
    case 0x00:
        afe2MaxDACCH0 += ESI_getAFE2DACValue(CHANNEL_0_DAC2_UPPER_REGISTER);
        break;
    ...
    For this:
    ...
    case 0x00:
        afe2MinDACCH0 += ESI_getAFE2DACValue(CHANNEL_0_DAC2_LOWER_REGISTER);
        break;

    That's correct. This was discussed in the following thread.

    FLOWESI-GUI: MSP430FR6989 - Generated Code Seems Wrong

    We think that they have to be: ESI_AFE2_CHANNEL0_SELECT instead of ESI_AFE2_CHANNEL1_SELECT and so on. Would you mind checking that and tell us what is the right code?

    The SELECT labels appear to be shifted by N+1. I've seen that sometimes to make it more intuitive - such as 1, 2, 3 versus 0, 1, 2. If that's consistent across the code, it should be okay. The if() statement checks if the comparator is inactive before configuring the DAC.

  • Hi James,

    Thank you very much in advance for your help.

    According to ESI_AFE2_CHANNEL1_SELECT, it seems to be that it is an error:

**Attention** This is a public forum