Author Topic: WS2812B library support in atmel studio  (Read 561 times)

0 Members and 1 Guest are viewing this topic.

Offline katlinTopic starter

  • Newbie
  • Posts: 1
  • Country: in
WS2812B library support in atmel studio
« on: February 23, 2021, 04:05:38 pm »
Hi all,

I am trying to work with WS2812B RGB LED(GPIO Controlled) + SAML21 in Atmel studio.

Board: SAML21 Xplained Pro
Sensor: WS2812B RGB LED
IDE: Atmel studio

Looking for WS2812B Library which supports ATMEL Studio.  I could not find any reference library online.

How do I do this? If anyone can help, that would be great.

I have tried to port the Arduino library below libraries. But no outcome.

* https://github.com/adafruit/Adafruit_NeoPixel%C2%A0
* https://github.com/kitesurfer1404/WS2812FX

Thanks in Advance.
 

Offline sigma_xi

  • Contributor
  • Posts: 24
  • Country: at
  • PhD student.
Re: WS2812B library support in atmel studio
« Reply #1 on: May 29, 2021, 07:07:38 am »
I don't know about library support for Atmel studio. However, you can write your own driver using the SAML21's DMA capabilities. I did the same thing using an STM32 with DMA and Timer in PWM mode, but it can also be done via SPI.

Some implementations of the DMA+Timer solution can be found online, see https://github.com/benwilliam/equinox_clock for example.

The basic workflow is:
1) Initialize Peripherals (GPIO, DMA for memory->peripheral transfer, Timer in PWM mode but disabled)
2) Have your colour data stored in memory.
3) Convert colour data to Timer compare values according to the WS2812B's timing requirements for 0/1 bit.
4) Start the transfer via DMA (enable DMA, enable timer). Now the DMA controller automatically streams the converted colour data to the Timer. At the end of the transfer: disable timer.

(An important note: You must ensure that the timer compare value is updated by DMA before the next PWM cycle starts, otherwise it won't work. For the STM32 this is done by enabling OC preload)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf