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.

CC2640R2F: osal_snv_write() fail?

Part Number: CC2640R2F


Hi,

    I am trying to write a tag name using osal_snv_write(), but not successful. See, below. my SNVID_TAG_NAME is 0x8A. What could be causing osal_snv_write() failure? Could it be the same situation with my other post https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/t/597088, that I need to post and Event to wake up the application in order for the osal_snv_write() to work?

    

- kel

  • Do you define OSAL_SNV=1 in Predefined Symbols of Properties for BLE Stack?
  • YiKai Chen said:
    Do you define OSAL_SNV=1 in Predefined Symbols of Properties for BLE Stack?

    Yes.

    My program goes to "Test Mode". At "Test Mode" no BLE Profiles are initialized. To execute writing tag name, I type "tawr tagname" to Tera Term and press enter. During the initialization phase of "Test Mode" I am able to successfully do osal_snv_read() in this C function. I assume osal_snv_write() will work as well at this stage. 

    void Config__ReadNV(BYTE nvID, BYTE len, BYTE* data, BYTE* defData)
    {
        uint8_t status = 1;
        
        status = osal_snv_read(nvID, len, data);
        if (status == NV_OPER_FAILED)
        {
            while(1); 
        }
        else if(status != SUCCESS)
        {
            MEMCPY(data, defData, len);
            status = osal_snv_write(nvID, len, data);
        }
        else
        {
          //success
        }  
        return;
    }

    After "Test Mode" initialization both osal_snv_read() and osal_snv_write() does not work. After typing "tawr tagname", the program goes to these C functions below.

    void Config__WriteTagID (BYTE* data)
    {  
        uint8_t status;
        
        status = osal_snv_write(SNVID_TAG_NAME, XX_TAG_ID_LEN, data);
        if(status != SUCCESS)
        {
            while(1);
        }
    
    }
    
    void TestApp__WriteTagID(BYTE* msg) 
    {
        /* Ensure msg has valid lenght not greater than 12 */
        if (STRLEN(msg) <= XX_TAG_ID_LEN)
        {
          Config__WriteTagID((BYTE*)&msg[0]);
          UartApp__WriteString("Write Tag ID OK\r\n");
        }
        else
        {
          UartApp__WriteString("INV TAGID LEN\r\n"); 
        }                      
    
        return;
    }

    I am thinking that it is the same situation in the post link I shared. The program goes into "Standby Mode" or "Idle Mode" affecting osal_snv_read() and osal_snv_write() operations.

    - kel

  • I can use osal_snv_write/osal_snv_read in simple_peripheral application without problem but I don't have experience using it under "Test Mode". If you don't use use osal_snv_write in test mode, does it work?
  • Hi Yikai,

         I tried the osal_snv_read() and osal_snv_write() example code from CC2640R2 SDK docs and it works at simple peripheral. 

    static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
    {
      // Initialize application
      SimpleBLEPeripheral_init();
    
    #ifdef SNV_TEST
    
        uint8 status = SUCCESS;
    
        status = osal_snv_read(SNV_ID_APP, BUF_LEN, (uint8 *)buf);
        if(status != SUCCESS)
        {
         Display_print1(dispHandle, 0, 0, "SNV READ FAIL: %d", status);
         //Write first time to initialize SNV ID
         osal_snv_write(SNV_ID_APP, BUF_LEN, (uint8 *)buf);
        }
    
        //Increment first element of array and write to SNV flash
        buf[0]++;
        status = osal_snv_write(SNV_ID_APP, BUF_LEN, (uint8 *)buf);
        if(status != SUCCESS)
        {
         Display_print1(dispHandle, 0, 0, "SNV WRITE FAIL: %d", status);
        }
        else
        {
         Display_print1(dispHandle, 0, 0, "Num of Resets: %d", buf[0]);
        }
    
    #endif

    - kel

  • I suspect this is something related to UART code. Is it possible to disable UART and test again.
  • Hi Yikai,

    I will disable UART and see what happens.

    - kel
  • Hi Yikai,

        I had some other issues disabling UART at this point in Test Mode. But, I have confirmed that the reason for osal_snv_write() and osal_snv_write() not working, is because the main application went into Standby Mode. I tested osal_snv_write() and osal_snv_read() calling after Event_pend. The osal_snv_write() and osal_snv_read() passes 3x. But at the 4th time there are no more events and it went to Standby Mode.

    for (;;)
      {
        uint32_t events;
    
        // Waits for an event to be posted associated with the calling thread.
        // Note that an event associated with a thread is posted when a
        // message is queued to the message receive queue of the thread
        events = Event_pend(syncEvent, Event_Id_NONE, SBP_ALL_EVENTS,
                            ICALL_TIMEOUT_FOREVER);
    
        if (events)
        {

    The solution I did is post a queue message to wake up the main application and then call the C function that does the osal_snv_write() and osal_snv_read(). The solution is mentioned in this post below. But,  my solution seems seems to be not okay. Later on hopefully I can find a way to disable the application to going in Standby Mode, so I do not have to queue message to wake up the main application.

    - kel