Tool/software: TI-RTOS
Hello, I have a problem with writing data to the SD card. When I using Hwi and Swi in my application, these threads interrupt my critical section when I writing data to my SD card and my data crashed.
When I don't use DSP (DSP evokes Swi) and Hwi_disable() and set task priority for other task with higher priority the problem does not occur.
How to put a critical section in the application where occur Hwi, Swi and higher priority tasks?
if(1) { sprintf(fname, "Data_test%i.txt", licz); licz++; hwiKey = Hwi_disable(); //Disable all hardware interrupt int i; for(i = 0; i <200; i++) { taskPri3 = Task_setPri(taskMain_8, -1); //Disable taskMain //Critical section if ((fres = f_open(&fil, fname, FA_OPEN_APPEND | FA_READ | FA_WRITE)) == FR_OK) { f_write(&fil, SD_BUFF_TEST, sizeof(SD_BUFF_TEST), &cnt); f_close(&fil); //The end of the critical section Task_setPri(taskMain_8, taskPri3); //Enable taskMain } } }
When I using Swi_disable() occure I problem:
ti.sysbios.knl.Semaphore: line 222: assertion failure: A_pendTaskDisabled: Cannot call Semaphore_pend() while the Task or Swi scheduler is disabled. xdc.runtime.Error.raise: terminating execution
When I using Hwi_disable() and Hwi_restore(key_hwi) after critical section my data also crashed...