I need to create a device for collecting data, whose task is to sample some GPIO and record the status of the GPIO and send it to the PC via UART to display on the PC. The algorithm I chose was (please correct me since I am very new to RTOS) to create a timer running on 1us and then poll the status of all the necessary GPIOs. For this, I used the timer in the freertos demo. And give a semaphore in the ISR timer, which should trigger a task that performs the rest of the job.
I don’t know why, but the code I edited does not work
My main()
int main(void) {
prvSetupHardware();
vSemaphoreCreateBinary(SemaphoreTask);
if( SemaphoreTask != NULL )
{
xTaskCreate( SemaphoreTakeTask, "SemaphoreTakeTask", 240, NULL , 3, NULL );
vTaskStartScheduler();
}
for(;;);
return 0;
}
Task 1 is a dummy function that I wrote to try if the semaphore works
void SemaphoreTakeTask(void* parameter){
vSetupTimerTest(10);
TRISEbits.TRISE6 = 0;
xSemaphoreTake( SemaphoreTask, 0 );
for(;;){
xSemaphoreTake( SemaphoreTask, portMAX_DELAY );
LATEbits.LATE6 ^= 1;
}
}
ISR Timer Handler
void vT2InterruptHandler(void) {
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
IFS0CLR = _IFS0_T2IF_MASK;
xSemaphoreGiveFromISR(SemaphoreTask, &xHigherPriorityTaskWoken);
if (xHigherPriorityTaskWoken != pdFALSE) {
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
}
}
ISR, , GPIO ( 1)
Iam RTOS, , , -
ISR
, , xSemaphoreGiveFromISR. vAssertCalled
xSemaphoreTake() pdFALSE