TI中文支持网
TI专业的中文技术问题搜集分享网站

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

我的代码功能如下:

串口收到配置数据,写入到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工程师帮我看看有什么问题。

Kanta He:

我找到了问题,但是还不知道怎么解决,就是easylink在mcu不断电的情况下,再次初始化的时候会卡住,这个是什么原因造成的?

Viki Shi:

回复 Kanta He:

easylink卡住?单独跑easylink测试过没?

Kanta He:

回复 Viki Shi:

单独跑没问题,复位正常,操作串口后,debug复位就出现这个问题

Kanta He:

回复 Kanta He:

测试了CC1310 SDK的nortos和rtos2.21的easylink,发现只要第一次下载代码,EasyLink_init(&easyLink_params)这个能正常执行,通过IAR对模块复位后,就执行不过,IAR版本是7.8和8.3都测试过。这是什么问题?

Viki Shi:

回复 Kanta He:

“通过IAR对模块复位后”是指软复位?通过板子硬复位有试过吗?
另外,请问你用的SDK是什么版本,建议使用release note里发布的IAR版本进行测试

Felix ZF:

回复 Kanta He:

你在IAR的reset按钮右边,点一下小箭头,在下拉菜单里选择board reset。

赞(0)
未经允许不得转载:TI中文支持网 » CC1310 通过串口给flash写数据,代码复位跑飞
分享到: 更多 (0)