I need to make a data accusition device whose one task is to samples some GPIO’s and record the GPIO status and send it to PC via UART to display in PC. The algorithm i chose was (please correct me since iam very novice in RTOS) to create a timer running at 1us and then poll the status of all GPIO needed. For that i used a timer in the freertos demo. And give a semaphore in the timer ISR which should call a task which do all the remaining job.
Don’t know why but the code i edited dont work
My main() is
int main(void) {
/* Prepare the hardware to run this demo. */
prvSetupHardware();
vSemaphoreCreateBinary(SemaphoreTask);
if( SemaphoreTask != NULL )
{
xTaskCreate( SemaphoreTakeTask, "SemaphoreTakeTask", 240, NULL , 3, NULL );
vTaskStartScheduler();
}
for(;;);
return 0;
}
Task 1 a dummy function i wrote just to try out if semaphore is working
void SemaphoreTakeTask(void* parameter){
vSetupTimerTest(10); // Timer initialization function in FreeRtos DEMO
TRISEbits.TRISE6 = 0; // Set the GPIO as Output
xSemaphoreTake( SemaphoreTask, 0 ); // As mentioned in user guide just take the semaphore once to clear the semaphore at start
for(;;){
xSemaphoreTake( SemaphoreTask, portMAX_DELAY );
LATEbits.LATE6 ^= 1; // Toggle an IO to see whether its working
}
}
Timer ISR handler
void vT2InterruptHandler(void) {
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
/* Clear the timer interrupt. */
IFS0CLR = _IFS0_T2IF_MASK;
xSemaphoreGiveFromISR(SemaphoreTask, &xHigherPriorityTaskWoken);
if (xHigherPriorityTaskWoken != pdFALSE) {
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
}
}
When i put break point in the ISR handler it comes there but the GPIO is not toggling (which i placed in Task 1)
Iam a novice in RTOS so please pardon me if i missed any basic things in the code
I just need to give a semaphore from ISR handler