在线时间13 小时
UID2078946
注册时间2014-3-13
NXP金币0
该用户从未签到
注册会员

- 积分
- 83
- 最后登录
- 1970-1-1
|
本帖最后由 gaoqian01 于 2016-11-10 16:35 编辑
大家好,我用k64的芯片,用SDK2.0建的带rtos的工程,擦除片上flash时,异常
void test(void)
{
uint32_t startAddr = flashDriver.PFlashTotalSize / 2 - flashDriver.PFlashSectorSize;//第一个block,最后一个sector起始地址
//uint32_t startAddr = flashDriver.PFlashTotalSize / 2;
//PRINTF("------test----startAddr=0x%x-----\r\n", startAddr);
FLASH_Erase(&flashDriver, startAddr, flashDriver.PFlashSectorSize, kFLASH_apiEraseKey);
PRINTF("TEST FLASH END.\r\n");
}
/*!
* @brief Task responsible for printing of "Hello world." message.
*/
static void hello_task(void *pvParameters) {
//for (;;) {
PRINTF("Hello world.\r\n");
/* Add your code here */
test();
PRINTF("TEST FLASH END.\r\n");
//vTaskSuspend(NULL);
// }
}
void InitMcuFlash(void)
{
memset(&flashDriver, 0, sizeof(flash_config_t));
FLASH_Init(&flashDriver);
//addby gq
/* Check security status. */
flash_security_state_t securityStatus = kFLASH_securityStateNotSecure;
uint32_t result = FLASH_GetSecurityState(&flashDriver, &securityStatus);
}
/*!
* @brief Application entry point.
*/
int main(void) {
/* Init board hardware. */
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
PRINTF("RCM->SRS0=0b%08b, RCM->SRS1=0b%08b\r\n", RCM->SRS0, RCM->SRS1);
PRINTF("\r\n");
PRINTF("\r\n");
PRINTF("starting testing...\r\n");
InitMcuFlash();
/* Add your code here */
test();//main擦除block0的最后一个sector正常
/* Create RTOS task */
xTaskCreate(hello_task, "Hello_task", configMINIMAL_STACK_SIZE, NULL, hello_task_PRIORITY, NULL);
//在task里面,调用test,擦除block0的最后一个扇区,就重启,擦除block1的任何扇区都正常
vTaskStartScheduler();
test();
for(;;) { /* Infinite loop to avoid leaving the main function */
__asm("NOP"); /* something to use as a breakpoint stop while looping */
}
}
----------------------------------------------------------------------------------------------------------------
现象:
1、在main函数,擦除片上flash的扇区都正常
2、在task里面,擦除block0的任何扇区就重启,擦除block1的正常。重启后打印RCM的寄存器值,显示复位源是Core LockUp
请问这是那里的问题?task要怎么设置?谢谢!!!
最佳答案
gaoqian01 发表于 2016-11-11 11:39
谢谢
楼主可以是使用vPortEnterCritical和vPortExitCritical将Flash erase过程的代码作为临界区代码保护起来
|
|