Hello Alan,

It is better with DMA. I think there is an error in sam_dmac.c line 140 I
had to change aligned to aligned_data, otherwise I get
error: expected declaration specifiers or '...' before numeric constant

static struct dma_desc_s g_base_desc[SAMD2L2_NDMACHAN]
locate_data(".lpram"), aligned(16);
static struct dma_desc_s g_writeback_desc[SAMD2L2_NDMACHAN]
locate_data(".lpram"), aligned(16);
to
static struct dma_desc_s g_base_desc[SAMD2L2_NDMACHAN]
locate_data(".lpram") aligned_data(16);
static struct dma_desc_s g_writeback_desc[SAMD2L2_NDMACHAN]
locate_data(".lpram") aligned_data(16);

Still in the same file, changed the configuration of the Channel Control B
Reg.
Instead of DMAC_CHCTRLB_TRIGACT_BEAT by DMAC_CHCTRLB_TRIGACT_TRANSACT it
works also with DMAC_CHCTRLB_TRIGACT_BLOCK.

With DMAC_CHCTRLB_TRIGACT_BEAT I get only one pulse every 20ms (application
delay)

With DMAC_CHCTRLB_TRIGACT_TRANSACT or DMAC_CHCTRLB_TRIGACT_BLOCK I get:
- a reset >80µs
- 13 bits. The bits are packed. However I think it should be 24bits. Maybe
I saturate the DMA because of the reset which take many bytes??
- Led 1 is turning on and off but with green color only

[image: dso_01_01_02_59_38.png]
Regards,
Bert.

Le lun. 30 oct. 2023 à 18:57, Alan C. Assis <acas...@gmail.com> a écrit :

> Hi Bert,
>
> On 10/30/23, Bert Voldenuit <bertvolden...@gmail.com> wrote:
> > Hi Alan,
> > Thanks for adding Brennan to the discussion.
> >
> > My answers below.
> >
> > Le lun. 30 oct. 2023 à 16:09, Alan C. Assis <acas...@gmail.com> a écrit
> :
> >
> >> Hi Bert,
> >>
> >> I'm CC Brennan (the original author) and Victor (the author of the
> >> other driver using ESP32 RMT) they have more experience with WS2812.
> >>
> >> On 10/29/23, Bert Voldenuit <bertvolden...@gmail.com> wrote:
> >> > Hi Alan,
> >> >
> >> > Thanks to your advices, I was able to find why
> >> > board_ws2812_initialize()
> >> > was not in System.map.
> >> > Now it mounts and opens ws2812 driver.
> >> >
> >>
> >> Great, what was the issue?
> >
> > --> I forgot to activate board_late_initialized
> > --> By default the ws2812 driver allocate memory for each color (8bits)
> for
> > RGBW (4 colors). My leds are RGB only so I had to change 4->3. I will try
> > to add a parameter instead of a fixed value.
> >
> >>
> >> > Indeed the SPI is not a piece of cake. I think I have it almost right
> >> > but
> >> > MOSI pin is idling high which is a problem for the reset which must be
> >> low
> >> > and I can' get it to the right timing.
> >> >
> >>
> >> Exactly, using SPI to control the WS2812 seems challenging, you will
> >> need to fiddling with it a little bit until get things working.
> >>
> >> > SPI frequency is set to 6MHz
> >> >
> >> > In ws2812.c
> >> > I had to change WS2812_ONE_BYTE. I added one more 1 to fit the timing
> >> > for
> >> > SK6812
> >> >             Target                 Measured (see Scope figure 1)
> >> > T0H 0  0.3μs ±0.15μs        0.34µs
> >> > T1H 1  0.6μs ±0.15μs        0.68µs
> >> > T0L 0   0.9μs ±0.15μs        0.86µs
> >> > T1L 1   0.6μs ±0.15μs        0.52µs
> >> > Reset   80µs                      20µs (Not Good)
> >> >
> >>
> >> I'm not sure you need to change the number of bits, AFAIK it should be
> >> only the frequency you should play with. SAMD21 (and many others SAM
> >> chips) has a very advanced clock system (even compared with some
> >> advanced processor)
> >>
> > --> True! I will try to fit the target by changing the clock without
> > changing the bits
> >
> >
> >> > I Changed WS2812_RST_CYCLES for 80µs but I still get 20µs, so it look
> >> like
> >> > it has no effect AND it is idling High (see Scope figure 2).
> >> >
> >> > Questions:
> >> >
> >> > - On Scope Figure 1, is it normal SPI is idling for 2.2µs between each
> >> > byte?
> >> >
> >>
> >> It could be caused by the driver itself. Maybe using SPI with DMA will
> >> reduce this idle time.
> >
> > --> Ah! I thought it was already using DMA. Now I understand that the
> delay
> > should be the cpu time needed to send the next bit.
> > --> Yes using the DMA would definitely improve the driver. I checked on
> > another library that it is possible to loop on DMA so when there is no
> data
> > to send, it sends zeros forever at no cpu cost.
> > --> I have no idea how to handle and allocate DMA. I saw a DMA trigger in
> > the SPI option, will it be necessary to activate? I will try to add the
> DMA
> > option in the driver.
> >
>
> The SPI driver already supports DMA, you just need to use
> CONFIG_SAMD2L2_SPI_DMA
>
> BR,
>
> Alan
>

Reply via email to