Macropad Pixel Code Conflicts With Tone Generator (Arduino V

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
RufusVS2020
 
Posts: 62
Joined: Thu Nov 19, 2020 6:31 pm

Macropad Pixel Code Conflicts With Tone Generator (Arduino V

Post by RufusVS2020 »

After trying to enable the tone generation in the Arduino Macropad Example code and experiencing
total lockups, I experimented with the code and once I eliminated the Neopixel portions of the code,
the audio function worked as expected. I can only assume that the tone function somehow knocks
out and interrupt or register or memory the NeoPixel code uses (in the background).

I have attached the modified Macropad sketch I used to eliminate features hunting down this problem.

When you load this, you can press the 12 key (bottom right on Macropad) and generate tones. The
display, encoder, and i2c scanning all works as in the original demo.
Attachments

[The extension ino has been deactivated and can no longer be displayed.]


User avatar
RufusVS2020
 
Posts: 62
Joined: Thu Nov 19, 2020 6:31 pm

Re: Macropad Pixel Code Conflicts With Tone Generator (Ardui

Post by RufusVS2020 »

Following up: It appears both the NeoPixel code and the Tone generator code DO use the PIO of the RP2040 (which I was happy to find out!).
I was able to make it work by modifying the NeoPixel library file rp2040.c to have it use PIO1 instead of PIO0. I don't know what that will break
in the rest of the library, as I don't know what uses PIO1.

It seems to me they should be able to coexist, as they are both blocking functions (tone and show), if more analysis is done.

If anyone wants the changed rp2040.c code, I have attached the file here. Replace your library version (after backing it up somewhere) and try it out.

People more familiar with the rp2040 Macropad Arduino project, please pipe in with pio1 conflicts.
Attachments
rp2040.c
(1.2 KiB) Downloaded 15 times

User avatar
RufusVS2020
 
Posts: 62
Joined: Thu Nov 19, 2020 6:31 pm

Re: Macropad Pixel Code Conflicts With Tone Generator (Ardui

Post by RufusVS2020 »

I may be mistaken about blocking, as they probably don't wait for the PIO FIFOs to empty. More research required...

Locked
Please be positive and constructive with your questions and comments.

Return to “AdaBox! Show us what you made!”