RTC slows down, affecting DMA and serial output

judge2005
Posts: 2
Joined: Tue Apr 06, 2021 1:30 pm

RTC slows down, affecting DMA and serial output

Postby judge2005 » Tue Apr 06, 2021 2:51 pm

I am trying to track down an issue in a fairly complex application, but the symptom is very odd. The application is a clock, so one thing it does is display the time. It also plays sounds, which it reads from an SD card and streams to I2S using DMA (but it doesn't use the onboard DACs). It maintains an active WiFi connection and it synchronizes time using SNTP.

After some time, the RTC clock slows. The evidence for this is that the time display slows down, the sound output slows down (the music is played slower), the debug that is being output over serial becomes unreadable because the baud rate changes and the WiFi becomes unusable. It is especially a shame that the serial output becomes unreadable. I compiled with core debug and it is trying to output information.

So my question is, what could do this? It seems that the effect is at a very fundamental level to be affecting all of these different functions, so I doubt that any RTOS task could have this effect. Am I wrong?

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

Re: RTC slows down, affecting DMA and serial output

Postby ESP_Sprite » Wed Apr 07, 2021 9:30 am

Huh, that almost sounds like your 40MHz crystal is wonky. What hardware do you use? Do you have an idea by how much % the slowdown is? Any power management functions enabled if this is an ESP-IDF app?

judge2005
Posts: 2
Joined: Tue Apr 06, 2021 1:30 pm

Re: RTC slows down, affecting DMA and serial output

Postby judge2005 » Wed Apr 07, 2021 7:06 pm

I get this on multiple boards, I am using the Pico.

I now think this has something to do with interrupts relating to I2S. If I replace my I2S output code with something that just throws the samples away, there is no problem. If I2S were processing many interrupts, could this have all of the effects noted above? I note that i2s_intr_handler_default() is not exactly a light-weight function.

An additional strangeness is that if I run WiFi in soft AP mode, the problem also goes away. So no I2S is fine, and I2S+Soft_AP is fine, but I2S on its own shows this issue.

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

Re: RTC slows down, affecting DMA and serial output

Postby ESP_Sprite » Tue Apr 13, 2021 5:48 am

A busy interrupt could impact how everything else that is CPU bound runs, but I'm having a hard time explaining e.g. the baud rate change, as this is something set in hardware. Can I ask what hardware you are using, and would you be OK with sharing code that shows this effect?

Who is online

Users browsing this forum: No registered users and 52 guests