Bonjour,
I'm a noob so I can't check the source to answer my question (I tried!).
I have a sketch running OK: it generates a sinus signal on the SAMD21 DAC pin A0, outputting tabulated values at regular intervals triggered by a TC5 interrupt; and at each second, I blink the onboard LED.
Everything runs smoothly on other boards (Feather M0 and Trinket M0, see https://www.youtube.com/watch?v=9mhznnQjukE) but my sinus is borked on the QT-Py.
When I comment out NeoPix lines, everything gets back to normal.
Why? And how can I fix it? Maybe I can fork the NeoPixel lib and tweak it for my usage? Or implement my own bit-bang to talk to the NeoPixel on pin 11 (PA18)? Here's the code for Feather/Trinket: https://git.sr.ht/~proflutz/SAMD21code/ ... cYears.ino
Merci pour tout indice!
QT-Py M0 NeoPixel library interfering with TC5?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- lutzray
- Posts: 13
- Joined: Fri Nov 06, 2020 12:02 pm
- lutzray
- Posts: 13
- Joined: Fri Nov 06, 2020 12:02 pm
Re: QT-Py M0 NeoPixel library interfering with TC5?
Well, I didn't dive into the bowels of Adafruit_NeoPixel but I read it is using ASM for tight timing... This is probably too much for me to chew on...
But Adafruit is publishing a DMA library for driving NeoPixels, maybe someone can indicate what SERCOM magick spell should I invoke to wire the SPI peripheral to QT-Py pin PA18 (where the on board WS2812B is soldered)? How should I modify this extract from their Adafruit_NeoPixel_ZeroDMA pins.h?
But Adafruit is publishing a DMA library for driving NeoPixels, maybe someone can indicate what SERCOM magick spell should I invoke to wire the SPI peripheral to QT-Py pin PA18 (where the on board WS2812B is soldered)? How should I modify this extract from their Adafruit_NeoPixel_ZeroDMA pins.h?
Code: Select all
#if defined(ADAFRUIT_QTPY_M0)
// We can't use SERCOM0 because Serial1 uses it so that rules out TX/A6/D6.
// That leaves 3 other possible SERCOM/pin combinations:
// * SERCOM1 + SDA/D4 (used for I2C)
// * SERCOM2 + MOSI/A10/D10 (used for SPI)
// * SERCOM3 + PIN_SPI1_MOSI/D16) (used for the SPI Flash chip that can be soldered
// onto the bottom)
// Since using those pins means giving up the associated peripheral,
// and since I2C is featured prominently on the QT Py, it makes the most
// sense to enable DMA Neopixels on the MOSI pins, though it means sacrificing
// either SPI peripherals or the (optional) flash chip. Sorry.
&sercom2, SERCOM2, SERCOM2_DMAC_ID_TX, MOSI, SPI_PAD_2_SCK_3, PIO_SERCOM_ALT,
&sercom3, SERCOM3, SERCOM3_DMAC_ID_TX, 16, SPI_PAD_0_SCK_1, PIO_SERCOM,
#endif
- lutzray
- Posts: 13
- Joined: Fri Nov 06, 2020 12:02 pm
Re: QT-Py M0 NeoPixel library interfering with TC5?
It's me again. I'll investigate in this direction (if no information appears here): Using ATSAMD21 SERCOM for more SPI, I2C and Serial ports from Adafruit Learning series and from Sparkfun: Adding More SERCOM Ports for SAMD Boards. Digging further... Noob 1st badge: for the SAMD21E pin number is off by one from I/O Pin name :-)
- lutzray
- Posts: 13
- Joined: Fri Nov 06, 2020 12:02 pm
Re: QT-Py M0 NeoPixel library interfering with TC5?
Well, This did the trick (thanks to additional info from StowLake.com). When adding the line
Code: Select all
&sercom3, SERCOM3, SERCOM3_DMAC_ID_TX, 11, SPI_PAD_2_SCK_3, PIO_SERCOM_ALT,
Code: Select all
#define PIN 11
#define NUM_PIXELS 1
Adafruit_NeoPixel_ZeroDMA strip(NUM_PIXELS, PIN, NEO_GRB);
// edited from https://github.com/adafruit/Adafruit_NeoPixel_ZeroDMA/blob/master/examples/strandtest/strandtest.ino
- lutzray
- Posts: 13
- Joined: Fri Nov 06, 2020 12:02 pm
Re: QT-Py M0 NeoPixel library interfering with TC5?
[RESOLVED] So, yes, the Adafruit_NeoPixel lib does interfere with my code (DDS on DAC pin A0 triggered by TC5) and the workaround (who does not like blinky boards?) is to use Adafruit_NeoPixel_ZeroDMA after editing ADAFRUIT_QTPY_M0 sercomTable[] entries in the file Adafruit_NeoPixel_ZeroDMA/pins.h to add " &sercom3, SERCOM3, SERCOM3_DMAC_ID_TX, 11, SPI_PAD_2_SCK_3, PIO_SERCOM_ALT, " (cf post above).
See for yourself:
Happy DMA blinking! Et un gros merci Adafruit for all the open sourced code.
See for yourself:
- My DAC output using Adafruit_NeoPixel, note the faint tone in the background between the beeps: buggy FSK audio.
- The same sketch output using Adafruit_NeoPixel_ZeroDMA, note now the silence between the beeps: OK FSK audio.
Happy DMA blinking! Et un gros merci Adafruit for all the open sourced code.
Please be positive and constructive with your questions and comments.