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/LAUNCHXL-CC1310: Factory Reset of collector board using HwI

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: UNIFLASH, CC1310

Tool/software: Code Composer Studio

Hey guys,

we use sensor/collector 15.4Stack example and we'd like to automatically factory reset the collector. Basically I want to apply a rising edge on DIO12 causing a HWI to exectue. In the ISR I want to trigger an event and processing the event I want 3 things/functions to happen/execute:

  • Inform the user by printing something via System_printf
  • Csf_clearAllNVItems();
  • SysCtrlSystemReset();

At the beginning I just wanted to see if the HWI works and execute all three functions within the ISR. This is what goes wrong.

  1. The DIO12 is floating and the HWI is triggered when I put a jumper cable on the pin, which is floating, too, since the other side of the jumper cable is not connected to anything.. I guess I have wrong PIN settings.
  2. When I connect the 3V pin of the launchpad with DIO12 I sometimes get an interrupt but not always (I guess the same issue as number 1)
  3. I can see, that the application is resetted, because the red LED stops blinking, but the collector never comes back to life (LED stays off and no restart-prints via uart)
  4. The messages are only printed if I comment out the other two functions, I guess the reset prevents the system from printing

This is how I configure the PIN and interrupt

/* Pin interrupt  */
static PIN_Config intrPinTable[] =
{
    Board_HWI_Factory_Reset   | PIN_INPUT_EN | PIN_NOPULL | PIN_HYSTERESIS,
    PIN_TERMINATE
};
const PIN_Config BoardGpioInitTable[] = {

    CC1310_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,       /* LED initially off          */
    CC1310_LAUNCHXL_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,       /* LED initially off          */
    CC1310_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low       */
    CC1310_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low       */
    CC1310_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,  /* External flash chip select */
    CC1310_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN,                                              /* UART RX via debugger back channel */
    CC1310_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,                         /* UART TX via debugger back channel */
    CC1310_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master out - slave in */
    CC1310_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master in - slave out */
    CC1310_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN,                                             /* SPI clock */
    //________________MY CHANGE START_____________________
    CC1310_LAUNCHXL_DIO12 | PIN_INPUT_EN  | PIN_NOPULL | PIN_HYSTERESIS,
    //________________MY CHANGE END_______________________
    PIN_TERMINATE
};
    // Configure GPIO interrupt
    Board_intr_initialize();
    PIN_registerIntCb(intr_handle, &intr_HwiFxn);
    PIN_setConfig(intr_handle, PIN_BM_IRQ, Board_HWI_Factory_Reset | PIN_IRQ_POSEDGE);
void Board_intr_initialize(void)
{
    /*** Pin interrupt ***/
    // Configure GPIO interrupt
    intr_handle = PIN_open(&intr_state, intrPinTable);
}

void intr_HwiFxn(PIN_Handle hPin, PIN_Id pinId)
{
    System_printf("HWI detected. Initiating factory reset sequence.\r\n");
    //Csf_clearAllNVItems();
    System_printf("NV deleted!ByeBye!\r\n");
    //Task_sleep(100000); // = 1s
    //SysCtrlSystemReset();
}

This is basically all what I've done, of course I have also assigned IOID_12 to "Board_HWI_Factory_Reset".

.

I think issue 1 and 2 can be solved by correctly configuration of the PIN 12 and issue 4 by using Collector Events. Any comment on that?

Any idea what functions I might have to add to get the application running after setting SysCtrlSystemReset(); or this is the exact equivalent to pressing the "reset" button?

kind regards

Slev1n

  • Hello Slev1n,

    The reason why it does not print unless you comment those lines is because those printF calls do not print at that moment. In order for the system to be real time and not get affected by printing functions, those calls buffer those messages and wait until the CPU is not busy (e.g. idle task), since you are calling the reset API right after the device does not get a chance to ever go to the idle task. 

    I cannot call  task_sleep form the context of a HWi, I recommend you create a new event, and set such event from this HWi (you can keep the print functions).

    This new event will

    //Csf_clearAllNVItems();

    //Task_sleep(100000); // = 1s

    //SysCtrlSystemReset();
    and the HWi will:
    System_printf("HWI detected. Initiating factory reset sequence.\r\n");
         System_printf("NV deleted!ByeBye!\r\n");
    Set_Event(....);
    Regards,
    AB
  • Hey, I've already changed the code but didnt have time to test it yet.

    In collector_process() the event looks like this:

        if(Collector_events & COLLECTOR_HWI_FACTORY_RESET)
        {
            /* All NV items are cleared */
            Csf_clearAllNVItems();
    
            /* The system is reset */
            SysCtrlSystemReset();
    
            /* Clear the event */
            Util_clearEvent(&Collector_events, COLLECTOR_HWI_FACTORY_RESET);
        }

    Do you think I need the sleep time or will the NV definitely be cleared before the system reset?

    The HWI Callback function only contains the print commands to see if HWI is actually triggered.

    However some questions still remain,

    1. How can I set my PIN correctly and prevent it from floating, so that connecting this pin to 3V source actually triggers the HWI? currently connecting this PIN with a floating jumper cable triggers the HWI...
    2. And are this actually all functions we need to factory reset the collector?

    kind regards

    Slev1n

  • For the PIN, instead of using PIN_NOPULL you should use PIN_PULDOWN (if the interrupt is triggered by HIGH) or PIN_PULLUP (if interrupt is triggered by LOW).

    Yes that is all you need to factory reset the device, I recommend putting a task_sleep in between clearAll and the sysreset.

    Regards,

    AB

  • Ok, so I basically got it to work.

    I've added a 1s sleep timer in the collector event between erasing the NV and resetting the system. I also recommend to disable the HWI Pin in the ISR or many interrupts will be thrown.

    However, I noticed one strange behavior. If the board is flashed and I want to trigger the HWI the ISR is called and the red LED goes off, but the system does not restart. I have messages printed in Void appTaskFxn(UArg a0, UArg a1) indicating a system boot but I dont get the message and the launchpad stays "dead". If I then press the reset button, it starts just fine (not a "restart" but "start" is printed indicating the NV erase and system shutdown from before worked but not the restart...) and all subsequently triggered HWI factory resets perform without any issues. 

    Any idea why the first factory reset triggered by HWI (the ones using the buttons works) is not performing as expected when the board is freshly flashed?

  • I guess I have to revive this post since two issues are still open or have occured recently.

    1. No reboot performed the first time after the software reset is performed after flashing the board

    I found this thread discussing the same topic. Currently this is fine, because after flashing the board via USB cable using either CCS, flashProgrammer or UniFlash the collector board is unplugged from the laptop and connected to the raspi. Thus, the board is disconnected from the debugger and works fine.

    What happens if we flash the board using the linux bootloader example on a raspi?! Will the same problem occur is the board not in debug mode afterwards?

    2. Randomly thrown HWI

    On my test cc1310 launchpad I've connected the HWI pin with gnd and no HWIs are thrown randomly. On another LP I checked the pin using a multimeter because resets were occuring pretty often. Although the pin was not connected to anything, I could see that the voltage eventually increased to 1V. So this brings me to 2 questions.

    • The HWI is thrown if a rising edge is detected. At which voltage level is a rising edge defined? From 0V to 1V, 2V or 3V?
    • The pin on the LP is initialized to PIN_PULLDOWN. Do I have to set the opponent Raspi GPIO to a certain setting? (currently the raspi pin is set low at the beginning and set high for 0.5s to create a rising edge and throw a HWI. Note that the level is 3.3V and the LP is powered by the raspi, so both gnd should be on the same level)

    kind regards and thanks for the help

    Slev1n