How to make the Synergy faster? (WS2812b LED Strip Library)

Hello everybody!

There are a lot of projects with the WS2812b LED using Raspberry Pi or Arduino out there.

But I wanted to start my own project with Synergy and in the end it should be an 16x16 LED-Matrix which shows me an frequency spectrum of an audio signal.

The FFT for the spectrum is already working on the Synergy via the CMSIS Library.

Of course the next step would be to put the results on some LEDs. The Problem now is that I dont get the timing for the LEDs. For my first steps I only wanted to toggle a port pin on the Synergy.

R_IOPORT3->PCNTR3 |=  0x00020000;       /* Output 301 - set low */

R_IOPORT3->PCNTR3 |=  0x00000002;       /* Output 301 - set high */

This is working fine but I only get a 5MHz frequency on the Oscilloscope.

I already used only the "hal_entry.c" - Thread but I dont get a higher frequency.

For the tests I am using the S7G2-SK so the CPU should not be an problem. I think there are some things working in the background which I cannot see at the moment.

I know there is a post where the GPT is used and the port pin is toggling with 60MHz but for the LEDs I need an asynchronous data signal.

Do I have to programm in Assembler to get faster output signals or are there any other solutions which I dont see at the moment?

Maybe someone can give me a hint which component of the Synergy Controller is the best to use.

  • I am curious, what frequency would you get by

    R_IOPORT3->PCNTR3 = 0x00020000;
    R_IOPORT3->PCNTR3 = 0x00000002;
  • In reply to CS Yep:

    Hey CS Yep,
    Thank you for your reply!

    I checked it and yes now I get 10MHz on the port.
    Of course it is faster when there is no operand in the code. I didn´t think about that.
  • In reply to ChrisBi:

    What speed are you running the processor? S7g2 csn run up to 240mhz, and most instructions take 1-2 clocks.

    Is the code running in flash or sram?

    Both iar and e2 have tools to measure cycles with the debugger.
  • In reply to larry_c_not_Renesas:

    The control registers for the IOPORT take a number of PCLKB clock cycles to access :-

     

    The max frequency of PCLKB is 60MHz. So toggling a GPIO pin via the CPU is not as fast as a pin that is controlled directly by a peripheral.

  • I have driven WS2812 leds using the following values. I have used S7G2 as well. I was using a transistor to level up to 5 volts so everything is inverse. I was driving 32 Leds strip. Obviously, you have to send 24 (RGB) setLedTo1() or setLedTo0() for each led.

    void setLedTo1(void)
    {
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x80008000;
    R_IOPORT1->PCNTR1 = 0x80008000;
    R_IOPORT1->PCNTR1 = 0x80008000;
    }

    void setLedTo0(void)
    {
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x00008000;
    R_IOPORT1->PCNTR1 = 0x80008000;
    R_IOPORT1->PCNTR1 = 0x80008000;
    R_IOPORT1->PCNTR1 = 0x80008000;
    R_IOPORT1->PCNTR1 = 0x80008000;
    R_IOPORT1->PCNTR1 = 0x80008000;
    R_IOPORT1->PCNTR1 = 0x80008000;
    }

    I hope that helps.

  • Hello ChrisBi.

    I believe it's better to use DMA (or DTC) with either SPI or timer in PWM mode to interface with WS2812b. Solution based on manual GPIO toggling may be not only challenging (considering existence of this forum post), but also have to be performed in critical section to avoid interference from interrupts.

    Best regards,
    Eighth
  • In reply to Eighth:

    Hello Together,
    thanks a lot for every answer :)
    I am working my way through every reply.
    At the moment I already have the SPI Framework working. I just have the problem when I connect the LEDs that the MOSI is not pulled low (~1V) when no data is transfered but I think I will solve this problem when I connect an level shifter IC. Synergy is working with 3.3V and the LEDs logic is working with 5V.
    The bitrate of the SPI is 2.500.000. Bit-time is 400ns. Every LED Bit needs three SPI-Bits. So if I want to light up one LED I need 72 SPI-Bits.
    For the future it would be nice to have just the MOSI-Pin working. I already checked it in the Synergy Configuration to disable the pins but the Configuration shows an error then. Maybe I can disconnect the other pins when I go to the driver or a layer below. I will check this in the next time.

    It would be nice to know how it works with the PWM-Timer, too. At the moment I have no idea how to get the timing of the LEDs. Of course it has to do with the duty cycle of the frequency. But I dont know if I can adjust the duty cycle so fast.
    Its something on my bucketlist to check.

    I will keep this post alive until I have a programm which works fine for my application. I will send some code then. Maybe someone is interested, too.

    Thanks for every help :)