ADC ISR pinned in a specific core

ernane
Posts: 2
Joined: Wed Mar 30, 2022 11:06 pm

ADC ISR pinned in a specific core

Postby ernane » Wed Mar 30, 2022 11:33 pm

I have been use Esp32 in several applications. Wifi and bluetooth resources are very interesting and work very well, which increases the cost-benefit of this device. However, my first disappointment with this device was the impossibility of the use of floating point instructions inside ISR's. This is very bad limitation and reduces the aplications of this device. After the implementation of the IOT part, I was forced to change my calculations to fixed point to take the advantage of the part I have already implemented.

In another application using 16 analog inputs, I was surprised by the impossibility to use any kind of radio (wifi, bluetooth and espnow). I had to include another unit, one for 16 analog inputs and other for wifi, exchanging data by i2c, in order to get data by web pages. During this development, I found out that some analog inputs are multiplexed with strapping pins (boot configuration), so I have to include an external multiplex chip. It would be interesting in next designs that Espressif do not multiplex analog inputs with strapping pins.

Besides the non linearities we have in adc, we don't have enough information to implement the direct control of adc converter. We can see in a simpler microcontroller, like Atmega328P, a way to trigger adc by a timer and get the results using an ISR requested by adc. This is a best way to sample data. However I have to use functions like ad1_get_raw() to sample data in Esp32, because I don't have information to control the adc directly, as I have done for Atmega328p or TMS28379. It's frustrating when you don't have enough information available to design our own routines if we want to. I don't know if Esp32 doesn't have these resources (like to create a sequence of channels to be sampled in a timer trigger) or this is a simple lack in documentation.

Another point that is very important is to provide clearly a way to pin an ISR to a specific core.

I would appreciate if someone can indicate a way to overcome the difficulties I have mentioned above. At the end, I want to know if it is possible to sample a sequence of channels by a single timer trigger, and get the results using an adc ISR pinned in a specific core.

Thanks in advance

ESP_Sprite
Posts: 9591
Joined: Thu Nov 26, 2015 4:08 am

Re: ADC ISR pinned in a specific core

Postby ESP_Sprite » Thu Mar 31, 2022 1:27 am

To answer your main question: the ADC ISR (and ISRs in general) can't be migrated between cores, so they're defacto 'pinned' to a core already. (The core is the one that installs the interrupt. Installing the interrupt generally happens when you install the driver, so the ISR is 'pinned' to the task of the core that does that.)

If you're looking for low-level register data, it tends to be in the TRM. If you want to write your own driver, it may also be helpful to look at the ADC low level routines in ESP-IDF.

ernane
Posts: 2
Joined: Wed Mar 30, 2022 11:06 pm

Re: ADC ISR pinned in a specific core

Postby ernane » Thu Mar 31, 2022 12:14 pm

ESP_Sprite, thank you so much for the fast answer.

Related to ADC low level routines in ESP-IDF, obviously, I need to go deep in this code, but it seems that I can set a table with the sequence of channels I intend to convert. However I saw the "start of conversion" only by software, no timer trigger, and there is nothing about the existente of an adc interrupt in this code. I have to check the end of conversion by software handshaking. This implies a limited use of the Esp32 adc, even compared with a simpler microcontroller.

Related to the ISR, I don't want to migrate it between cores. In fact, I want to install it in a specific core. I have to try this in ESP-IDF, but considering a code in Arduino IDE, I installed a task in core 0 using xTaskCreateStaticPinnedToCore function, and this task programmed timer0 and installed the respective timer0 ISR, but the ISR ran in core 1. Independently of the core I have programmed the timer and its ISR, the ISR runs in core 1.

The chapter about the ADC in ESP32 Technical Reference Manual is very short, and I need to test codes in the dark to see if it works. This is a hard and not proficuous work. I haven't see any code in github, as instance, that uses adc interrupt.

In general sense, it seems that the ESP32 has a great potential which haven't been exploit yet because the poor documentation.

ESP_Sprite
Posts: 9591
Joined: Thu Nov 26, 2015 4:08 am

Re: ADC ISR pinned in a specific core

Postby ESP_Sprite » Fri Apr 01, 2022 1:35 am

The ADC actually does have multi-channel, DMA etc functionality, but the ESP32 uses the I2S peripheral to do that (essentially the ADC is seen as an I2S input that way). Later chips make the ADC a standalone peripheral. Suggest you look there, perhaps you'll find what you're looking for.

Who is online

Users browsing this forum: No registered users and 147 guests