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.

EVM430-FR6047: I2C slave

Part Number: EVM430-FR6047

hi,

i am receiving a stop bit interrupt USCI_I2C_UCSTPIFG start of my code, even though i do not enable the stop bit interrupt. i tried disabling the stop bit interrupt too.  UCB0IE &= ~(UCTXIE0 | UCRXIE0 | UCSTPIE). i though that might help.

any thoughts

thanks,

  • Hi Ephraim,

    You are saying that you disable the TX, RX, and STP interrupts using the line above, and you still enter the ISR with a UCSTPIE interrupt? Have you tried additionally clearing the interrupt statuses before globally enabling interrupts?

    Are you checking this using polling? If so, you may want to make sure that you are checking the Errata sheet, specifically errata USCI52, to make sure you are utilizing the indicated workaround.

  • hi Dylan,

    1.

    if you could explain more how to do this for the stop bit interrupt only, this is the loop in the ERRATA

    volatile unsigned short flag; do { flag = UCA0IG; }while ((flag & UCRXIFG) == 0x00);

    2.

    i will try this tomorrow:

    // Disable the Stop bit interrupt
    UCB0IE &= ~UCSTPIE; // Clear the Stop bit interrupt enable

    // Clear any pending Stop bit interrupt flags
    UCB0IFG &= ~UCSTPIFG; // Clear the Stop bit flag if previously set

    __bis_SR_register(LPM3_bits | GIE); 

    your comments are most appreciated.

    Ephraim

  • hi Dylan,

    after further investigation i see the following: note the inserted code:

        __bis_SR_register(LPM3_bits | GIE); // Enter LPM3 w/ interrupts, will wake up via i2c command 0x81 from Nordic
    //    UCB0IE &= ~(UCTXIE0 | UCRXIE0 | UCSTPIE); //disable i2c interrupts while initializing
        UCB0IE &= ~(UCTXIE0 | UCRXIE0); //disable i2c interrupts while initializin
    
        // Register PLL unlock event
        USS_registerHSPLLInterruptCallback(USS_HSPLL_Interrupt_PLLUNLOCK,
                                           &handlePllUnlockEvent);
    
        USSCode = USS_configureUltrasonicMeasurement(&gUssSWConfig);
        //checkCode(code, USS_message_code_no_error);
    
    #if((USS_ALG_ABS_TOF_COMPUTATION_MODE == USS_ALG_ABS_TOF_COMPUTATION_MODE_LOBE_WIDE) || \
        (USS_ALG_ABS_TOF_COMPUTATION_MODE == USS_ALG_ABS_TOF_COMPUTATION_MODE_HILBERT_WIDE))
        // Reference binary pattern are only needed by
        // USS_Alg_AbsToF_Calculation_Option_lobeWide and
        // USS_Alg_AbsToF_Calculation_Option_hilbertWide AbsToF computation options
        if((USS_Alg_AbsToF_Calculation_Option_lobeWide ==
                gUssSWConfig.algorithmsConfig->absToFOption)
           || (USS_Alg_AbsToF_Calculation_Option_hilbertWide ==
                   gUssSWConfig.algorithmsConfig->absToFOption))
        {
    #if defined(__MSP430_HAS_SAPH_A__)
            if(USS_measurement_pulse_generation_mode_multi_tone ==
                    gUssSWConfig.measurementConfig->pulseConfig->pulseGenMode)
            {
                code = USS_generateMultiToneBinaryPattern(&gUssSWConfig);
                checkCode(code, USS_message_code_no_error);
            }
    #endif
            if(USS_measurement_pulse_generation_mode_multi_tone !=
                    gUssSWConfig.measurementConfig->pulseConfig->pulseGenMode)
            {
                code = USS_generateMonoDualToneBinaryPattern(&gUssSWConfig);
                checkCode(code, USS_message_code_no_error);
            }
        }
    
    #if (APPLICATION_ENABLE_BINARY_PATTERN_SIZE_SCALING == true)
        gUssSWConfig.algorithmsConfig->binaryPatternLength =
                (gUssSWConfig.captureConfig->sampleSize / APPLICATION_BINARY_PATTERN_SCALE_FACTOR);
    #endif
    
    #endif
    
    
        // Application must ensure no application level interrupts occur while
        // verifying HSPLL Frequency
        //disableApplicationInterrupts();
    
        USSCode = USS_verifyHSPLLFrequency(&gUssSWConfig, &testResults);
        //checkCode(code, USS_message_code_no_error);
    
        // Application can re-enable interrupts after HSPLL verification
        //enableApplicationInterrupts();
    
        gUssSWConfig.algorithmsConfig->clockRelativeError = _IQ27div((int32_t)(testResults.actualTestCount -
                testResults.expectedResult),testResults.expectedResult);
    
        USSCode = USS_initAlgorithms(&gUssSWConfig);
        //checkCode(code, USS_message_code_no_error);
    
    #if (APPLICATION_ENABLE_SIGNAL_GAIN_CALIBRATION == true)
        code = USS_calibrateSignalGain(&gUssSWConfig);
        checkCode(code, USS_message_code_Signal_Gain_Calibration_successful);
    #endif
    
    #if (APPLICATION_ENABLE_ABSTOF_DTOF_OFFSET_CALIBRATION == true)
        code = USS_calculateOffsets(&gUssSWConfig, &abstoFDtofTestResults,
                                    &abstoFDtofTestConfig);
        checkCode(code, USS_message_code_no_error);
    
        code = USS_updateAdditionalCaptureDelay(&gUssSWConfig,
              ((abstoFDtofTestResults.upsAbsToFOffset + abstoFDtofTestResults.dnsAbsToFOffset) /2.0f) -
              APPLICATION_ABSTOF_REFERENCE);
        checkCode(code, USS_message_code_no_error);
    
        code = USS_updateDtoFOffset(&gUssSWConfig, (-1.0f *abstoFDtofTestResults.dToFOffset));
        checkCode(code, USS_message_code_no_error);
    
    #endif
    
        // Set the background timer period to 1 second  USS_SYS_MEASUREMENT_PERIOD
        USS_configAppTimerPeriod(&gUssSWConfig, gUssSWConfig.systemConfig->measurementPeriod);
        //finished initializing statics
    

    when i go to LPM3 in the beginning of main. It works fine i am asleep until i receive a I2C interrupt.

    However, after initializing the USS. i cannot go into LPM3 or LPM0, something is taking me out of the sleep mode.

    your thoughts.

    thanks,

    Ephraim

  • Can you elaborate on what you mean by "after initializing USS"? Do you mean just before the beginning of the while(1) loop?

    During the while(1) loop, the device is actively performing ultrasonic measurements and then running its algorithms. It already includes features to put the device into low power mode when these actions are complete, before the beginning of the next one.

    Also, how are you determining whether the device has entered a sleep mode?

  • hi Dylan,

    in the code snippet above, line 1, right after main (not shown) is where i go into LPM3. to answer your last question, i am stuck there until i get an interrupt from my I2C and clear the __bic then i move down the code.

    line 3 i disable I2C interrupts not to bother me while i am initializing the USS

    line 6 down to line 83 is a series of USS functions initializing the library.

    if i try to go into LPM3 after anywhere in code, after line 83 the code steps on the function and leaves, and i am in the following line after the LPM3 instruction.

    i conclude from this behaviour that one of the USS initialization function, affects the LPM3, or any other LPMx behaviour.

    thanks,

  • Hi Ephraim,

    Thanks for the additional information. I'd say your conclusion is correct and that it makes sense that the device isn't going into sleep mode as the device needs to stay awake to perform the ultrasonic measurements and calculations. As I mentioned earlier the example code has built in functionality to go into sleep mode as soon as possible inside the main application loop. I am sure you could dig through the code to disable the ultrasonic measurements and put the device to sleep before taking the measurement but I do not see why you would do this is the end goal is still to have it take periodic measurements and have it sleep in between. Just increase the UPS0 to UPS1 gap in order to increase the sleep time. 

    Additionally, I realize I never replied to the first statement about using the STP IFG in the errata. You should be able to just replace UCRXIFG with the define for the RX IFG with the define for the STP IFG, so USCI_I2C_UCSTPIFG.

  • hi Dylan,

    regarding the stop bit workaround this is what i did

    volatile unsigned short flag;
    do
    {
    flag = UCB0IFG; 
    } while ((flag & USCI_I2C_UCSTPIFG) == 0x00);

    kindly confirm.

    thanks,

  • Hi Dylan,

    to update i put the above code into the system_pre_init.c file, after the I2C configuration, and i don't reach the main of the program, removing it, the software reaches the main. your thoughts.

    thanks,

  • Ephraim, 

    Can you confirm that you are actually affected by errata USCI52? Please read the document.

    The loop you posted looks fine but it is meant to replace your current polling loop, it is not meant to just be inserted somewhere in the code. If you are using polling then replace your current polling loop with an implementation that buffers the interrupt status, as described in the errata. 

  • hi Dylan,

    so, my issue of receiving stop bit interrupt still when the stop bit interrupt was not set, is still happening.

    note that i was wrong to conclude that going into ISR will take me out of LPM mode and not return, until i physically call the set LPM3 again.

    thanks,

  • If you need to stop receiving the stop bit interrupt, please try using the debugging feature, such as debug trace, and just stepping through, to see when you are getting the I2C stop interrupt. It should occur when your device is communicating with another device and it detects a stop bit. Then when you get the interrupt you can double check the register values and make sure that the stop bit interrupt is still disabled. If it has become enabled again, then you need to step through the code and check where it becomes enabled. If the register view shows that it is disabled when you get the interrupt, please let me know.

  • hi Dylan

    which register should i be looking at?

    thanks,

**Attention** This is a public forum