FreeRtos slow?
FreeRtos slow?
I need to read internal ADC1 values 1000 times per second. I was thinking of using FreeRtos but CONFIG_FREERTOS_HZ the fastest is 1,000. And the rest of the tasks never work.
How can I implement faster FreeRtos?
Also can't find what sample rate the ADC can operate. There are no settings. Maybe there is an opportunity to use DMA? Or have an example to retrieve values from ADC on interrupt from the timer.
How can I implement faster FreeRtos?
Also can't find what sample rate the ADC can operate. There are no settings. Maybe there is an opportunity to use DMA? Or have an example to retrieve values from ADC on interrupt from the timer.
Last edited by brp80000 on Sat Dec 08, 2018 7:32 am, edited 1 time in total.
-
- Posts: 9761
- Joined: Thu Nov 26, 2015 4:08 am
Re: FreeRtos slow?
You can use I2S to sample the ADC using DMA, suggest you refer to the I2S driver for more info.
Re: FreeRtos slow?
Does the I2S library work with built-in ADC1?
Re: FreeRtos slow?
Look into using the ULP.
It was designed to do exactly what you are asking.
Don't try to speed up FreeRTOS - that's the wrong approach.
It was designed to do exactly what you are asking.
Don't try to speed up FreeRTOS - that's the wrong approach.
Re: FreeRtos slow?
The fact that it is impossible to accelerate FreeRtos, I already knew.
I don't know what ULP has to do with it. I need to read and summarize the internal values of the four ADC1 channels 1000 times per second. One of the values should be squared and then the sum should be accumulated. And should receive the values 10 times per second.
I don't know what ULP has to do with it. I need to read and summarize the internal values of the four ADC1 channels 1000 times per second. One of the values should be squared and then the sum should be accumulated. And should receive the values 10 times per second.
Re: FreeRtos slow?
Why does ADC sampling need to be tied to FreeRTOS tick period? You can have the sampling task receiving a semaphore, and have a hardware timer ISR sending the semaphore. This can happen multiple times per tick, as long as you yield from the ISR.
Second, as ESP_Sprite said, I2S peripheral can be used to do DMA from internal ADC to memory.
Second, as ESP_Sprite said, I2S peripheral can be used to do DMA from internal ADC to memory.
Re: FreeRtos slow?
I created the interrupt on the ISR timer 1000 times per second as I needed and wrote the most needed code inside it.
When I use printf(...) everything works but when I want to save values in flash using fprintf(...) I immediately getGuru Meditation Error: Cache disabled but cached memory region accessed
I use IRAM_ATTR atribute for isr
When I use printf(...) everything works but when I want to save values in flash using fprintf(...) I immediately getGuru Meditation Error: Cache disabled but cached memory region accessed
I use IRAM_ATTR atribute for isr
- void IRAM_ATTR timer_group0_isr(void *para) //
{
int timer_idx = (int) para;
TIMERG0.hw_timer[timer_idx].update = 1;
TIMERG0.int_clr_timers.t1 = 1;
TIMERG0.hw_timer[timer_idx].config.alarm_en = TIMER_ALARM_EN;
num++;
adc_reading_Ua = adc1_get_raw(ADC1_CHANNEL_6);
if (Averag==3) { // среднеквадратичное RMS
sum_reading_Ua += adc_reading_Ua*adc_reading_Ua;
}
if (Averag==1) { // скользящее среднее mAverage
sum_reading_Ua += adc_reading_Ua;
}
if (num==SampleRate_char) { // == 160 80 или 40 значений накопятся
sampleNO++;
num=0;
S_Ua = sum_reading_Ua;
sum_reading_Ua = 0;
}
-
- Posts: 9761
- Joined: Thu Nov 26, 2015 4:08 am
Re: FreeRtos slow?
There's a lot of things you cannot do from an ISR (actually, you're supposed to only call functions that are specifically marked as such, like the FreeRTOS *FromISR functions) and doing a fprintf is amongst one of them. The way to go here would be to create a FreeRTOS queue and push the samples into that queue, so you can read them out and write them to storage in a separate task. Or just use the I2S driver for this, as we said earlier.
Re: FreeRtos slow?
It is impossible to read from the ADC1 during interrupt? Or it is impossible to summarize the values obtained during the interrupt? Record in flash I do in a separate task.
I'm making a real-time device and can't create queues. ADC data must be received exactly 1000 times per second on a timer and immediately used for monitoring and control. And 20 times a second I have to save the processed data to a flash.
I'm making a real-time device and can't create queues. ADC data must be received exactly 1000 times per second on a timer and immediately used for monitoring and control. And 20 times a second I have to save the processed data to a flash.
Re: FreeRtos slow?
You can use a semaphore or Task Notification to signal a task from the ISR. The task can perform ADC sampling and do any other things you need, and then block until the next event, using the same semaphore or task notification feature. The delay due to unblocking the task from ISR is usually on the order of few (<10) microseconds, and the delay is probably going to be the same every time, so sampling will happen at correct period.
However if you need absolutely exact period, it is best to use I2S to sample internal ADC and write data to DMA.
However if you need absolutely exact period, it is best to use I2S to sample internal ADC and write data to DMA.
Who is online
Users browsing this forum: No registered users and 70 guests