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.

CC1310 通过串口给flash写数据,代码复位跑飞

Other Parts Discussed in Thread: CC1190, CC1310

我的代码功能如下:

串口收到配置数据,写入到NVS,如果非配置数据,直接通过RF发送出去。

现在的问题是:串口收到配置数据写入到NVS中,写入能成功,复位后,代码卡死在easylink初始化中。

uart配置:

     UART_Handle uart0_handle;//全局变量

    UART_Params_init(&uartParams);

    uartParams.readMode = UART_MODE_CALLBACK;
    uartParams.readCallback = Uart_ReadCallback;
    uartParams.writeCallback = Uart_WriteCallback;
    uartParams.writeMode = UART_MODE_CALLBACK;
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;

    uartParams.baudRate = 9600;

    uart0_handle = UART_open(Board_UART0, &uartParams);

    if (uart0_handle == NULL) {
        System_abort("Error opening the UART");
    }

main函数:

int main(void)
{
  unsigned char i;
    /* Call board init functions */
    Board_initGeneral();
    // Board_initI2C();
    // Board_initSPI();
    Board_initUART();
    // Board_initWatchdog();

    /* Construct heartBeat Task  thread */
    Task_Params_init(&taskParams);
    taskParams.arg0 = 1000000 / Clock_tickPeriod;
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)echoFxn, &taskParams, NULL);

    /* Confirming the sector size on this device is 4096 */
     if (FlashSectorSizeGet() != 4096) {
         System_abort("Oops! The sector size is not 4096");
     }
                             
     NVS_init();
     nvsHandle = NVS_open(CC1310DK_7XD_NVS1F000, NULL);

     for(i=0;i <16;i++)
        custom_falsh_write_buffer[i]=1;

     /* + 1 to make sure to write the '\0' character */
     strSize = strlen(custom_falsh_write_buffer) + 1;
     /* make sure the buffer size is a multiple of 4 */
     strSize = (strSize + 4) & 0xFFFFFFFFC;
     for(i=0;i <16;i++)
        custom_falsh_write_buffer[i]=NULL;
    
     status = NVS_write(nvsHandle, 0, custom_falsh_write_buffer, strSize, NVS_WRITE_ERASE | NVS_WRITE_VALIDATE);
     if (status != NVS_SOK) {
         System_abort("NVS_write failed");
     }
     status = NVS_read(nvsHandle, 0, custom_falsh_read_buffer, MYBUFFERSIZE);
     if (status != NVS_SOK) {
         System_abort("NVS_read failed");
     }

    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, pinTable);
    if(!ledPinHandle) {
        System_abort("Error initializing board LED pins\n");
    }
    PIN_setOutputValue(ledPinHandle, Uart_Tx_LED, 1);
    PIN_setOutputValue(ledPinHandle, Uart_Rx_LED, 1);
   
    cc1190PinHandle = PIN_open(&cc1190PinState, cc1190pinTable);
    if(!cc1190PinHandle) {
        System_abort("Error initializing board cc1190 pins\n");
    }
    PIN_setOutputValue(cc1190PinHandle, CC1190PAEN, 0);
    PIN_setOutputValue(cc1190PinHandle, CC1190LNAEN, 0);   
    PIN_setOutputValue(cc1190PinHandle, CC1190HGM, 0);
   

    System_printf("Starting the example\nSystem provider is set to SysMin. "
                  "Halt the target to view any SysMin contents in ROV.\n");
    /* SysMin will only print to the console when you call flush or exit */
    System_flush();

    /* Start BIOS */
    BIOS_start();

    return (0);
}

串口写flash代码如下:

          case 0x20:
            status = NVS_read(nvsHandle, 0, custom_falsh_write_buffer, MYBUFFERSIZE);
            if (status != NVS_SOK) {
              System_abort("NVS_read failed");
            }         
            custom_falsh_write_buffer[0] = 0X55;
            custom_falsh_write_buffer[3] = UART_Rx_Buff[4];
            //write
            status = NVS_write(nvsHandle, 0, custom_falsh_write_buffer, strSize, NVS_WRITE_ERASE | NVS_WRITE_VALIDATE);
            if (status != NVS_SOK) {
              System_abort("NVS_write failed");
            }
            //read
            status = NVS_read(nvsHandle, 0, custom_falsh_read_buffer, MYBUFFERSIZE);
            NVS_close(nvsHandle);
            if (status != NVS_SOK) {
              System_abort("NVS_read failed");
            }
            read_buff_temp[1] = custom_falsh_read_buffer[3];
            read_buff_temp[0] = 0x20;
            UART_write(uart0_handle, read_buff_temp, 2);
            break;

如果不通过uart收到配置数据,写入到flash,正常透传是没问题。

我怀疑是串口收到数据写入到flash出的问题。

NVS配置是:

char myCopyBlock[4096];
const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[CC1310DK_7XD_NVSCOUNT] = {
{
        .block = (void *)(0x1d000 - 4096), // Flash sector to use is 4096 of flash on a 128K part
        .blockSize = 4096,
        .copyBlock = myCopyBlock,
        .isRam = true
    }
};

请TI工程师帮我看看有什么问题。