Help Isolating ESP32-A2DP Code on Seperate Core #505
-
My ProblemI am working on a project where I am trying to emulate a cassette player that was an option in the first-generation Mazda 3s so that I can pass Bluetooth audio through the L/R/G inputs via a PCM5102 digital to analog converter. To do this I am using modified code from Krasutski's mazda_tape_deck_emulator project*. The emulator has to send and receive messages that make it look like there is a cassette unit present so that the radio will open the audio channels. The problem is that this code frequently calls interrupts to guarantee accurate timing when reading the messages sent by the radio. These interrupts seem to be stopping the transmission of data to the DAC for about a second which makes a loud buzzing noise which I assume is the DAC freaking out because there is no data incoming then it picks back up where it left off. It is very frustrating because it happens every ~10 seconds. My QuestionIs there a way for me to make it so that Bluetooth runs on a core separate from the emulator code so that the interrupts do not stop the Bluetooth data transmission? I have already tried the command a2dp_sink.set_task_core(); with both 0 and 1, but it didn't help. I also tried switching which cores Arduino and Events run on. I tried a lot of different combinations and it usually gave me a Watchdog Error. So is there a way to make it so that the two tasks are on separate cores? Some people online have mentioned using FreeRTOS to do it, but I don't know if that is possible with this library. I am having a lot of trouble because the ESP32-A2DP code is only called in the setup and the rest just runs through libraries so I can't actually see what tasks I need to separate. I am fairly new to the ESP-32 so help would be greatly appreciated. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
My project is quite similar, emulating a cd changer in old GMC trucks. I solved the problem with a second Arduino to handle the serial bus (j1850 in my case). It assembles the message, does the crc check, then sends it over to the esp32 over a uart connection (the esp32 has at least two of them). I used an ATtiny824, which costs about $0.89. CB. |
Beta Was this translation helpful? Give feedback.
-
Not sure if this will help: you can try to increase the I2S buffer, so that if there is a break, the audio is not running out... You would need to review the offending code of your emulator project to figure out what's going wrong |
Beta Was this translation helpful? Give feedback.
-
I solved the problem by rewriting a few functions to not use interrupts anymore. This library has been very helpful and I'm glad that I can use it for my projects. Thank you for the help guys. |
Beta Was this translation helpful? Give feedback.
Not sure if this will help: you can try to increase the I2S buffer, so that if there is a break, the audio is not running out...
The only thing this project does, is to start a task that receives Bluetooth events (and data) and sends the corresponding replies back.
You would need to review the offending code of your emulator project to figure out what's going wrong