Interrupt and task synchronization

Hello, I am new to FreeRTOS. I am using the dsPIC port for experimenting with tasks and interrupts synchronization. I tried first experimenting with low speed events like for example, when a button is pressed unblock the task and stuff. But what I really want to do is for example synchronize the DCI interrupt that gets samples from an audio codec and then unblock the task to process the input audio sample and then send the output audio sample. It sound pretty easy to do but, I have some doubts regarding to timing configuration, I mean, right now I have the default timing configuration of the port that is: configTICK_RATE_HZ = 1000 portTIMER_PRESCALE = 8 Does it means that the task timing is 1000/8 = 125 Hz? But let say if my codec is sampling at 16 KHz which means I need a 16 KHz timing to do the processing, I just have to put let say: configTICK_RATE_HZ = 16000 portTIMER_PRESCALE = 1 ?? Or is any other way to accomplish this kind of task with FreeRTOS? Thanks, Gabriel

Interrupt and task synchronization

I think you misunderstand a few things. First, portTIMER_PRESCALE doesn’t affect the interrupt rate, but is used to give the program a hint on how to setup the timer to get the desired interrupt rate. Some other ports of freeRTOS compute that value, but the dsPIC requires you to set the prescaler so it can find a valid value for the timer divider. Second, you do NOT need the timer running at your sampling rate. The proper solution would have the DCI module generate an interrupt, and unblock the task to consume the data (maybe by posting it to a queue). The RTOS timer is only used to measure timeout intervals and to time slice tasks of equal priority so all that need time can eventually get it.

Interrupt and task synchronization

Ok I understand now, I will try the blocking-unblocking the task by using a semaphore

Interrupt and task synchronization

Hey, now I have everything working as I espected, after some hours working with the RTOS I understand it better, thanks.