Hi team:
CCS version: CCS9.1. BIOS version: 5.42.1.09.
In theory, the semaphore of a task should be 0 or 1, but it will change to 45 after running for a period of time. What is the cause of this problem?
It is a semaphore for the task of communicating with the lower computer. There are three tasks in my project, which are: communication function with lower computer, communication function with upper computer and storage operation of SD card. The cycle is 2ms 2ms 4ms.
Before the problem occurs, the SD card reading and writing operations are generally carried out, and there is no fixed time. After the problem occurs, only the tasks communicating with the lower computer cannot be scheduled, and the other two are normal.
What's more, the task execution time of operating SD card sometimes exceeds 4ms. Is it related to this? The scheduling logic is as follows:
while((0xFFFF != GenTaskInfoTable[cnt16_1].taskID))
{
if((0 == (sysTime % GenTaskInfoTable[cnt16_1].period))
&& (SEM_count(GenTaskInfoTable[cnt16_1].taskSEM) < 2))
{
SEM_post(GenTaskInfoTable[cnt16_1].taskSEM);
}
cnt16_1 ++;
}
//The tasks with problems are as follows:
void TaskHardwareCommunicationRun(void)
{
while(1)
{
SEM_pend(&SEM_HardwareCommunication, SYS_FOREVER);
HardwareCommunicationProc();
}
}
When there is a problem, the value of "SEM_count(GenTaskInfoTable[cnt16_1].taskSEM" is 45, so it can't be "SEM_post" all the time. As a result, "TaskHardwareCommunicationRun" is stuck at "SEM_pend" all the time and cannot run.
Best Regards