WS2812B compilation problems.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

headhuntergr
Posts: 50
Joined: Fri Feb 28, 2014 7:25 am
Has thanked: 34 times
Been thanked: 5 times
Contact:

WS2812B compilation problems.

Post by headhuntergr »

Hello again.

I do have a weird problem on a STM32 discovery and a nucleo 144 board.

When i use the WS2812 component i cannot compile the program.

If i have the component on the dashboard but i don't use any component macro's it compiles fine

C:\Users\K\Desktop\WS2812b_STM32F746xx_25000000>arm-none-eabi-size -B "..\WS2812b.elf"
text data bss dec hex filename
4632 12 1540 6184 1828 ..\WS2812b.elf
Compilation successful

Launching the linker/assembler...
C:\Program Files (x86)\Flowcode v8\tools\DoNothing\DoNothing.exe


But if i use a component macro:

Launching the compiler...
C:\Program Files (x86)\Flowcode\Common\Compilers\starm\batch\F746Disco.bat "WS2812b" "C:\Users\K\Desktop\" "32F746xx" "F7" "stm32f.ld" "25000000" "1024K" "320K"
Project WS2812b
Device STM32F746xx
C:\Users\K\Desktop>arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -Os -DSTM32 -DSTM32F7 -DSTM32F746xx -DUSE_HAL_DRIVER -DHSE_VALUE=25000000 -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Device\ST\STM32F7xx\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc\Legacy -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\STM32746G-Discovery -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\Components -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\boards -fmessage-length=0 -fdata-sections -ffunction-sections -w -c "WS2812b.c" -o "WS2812b_STM32F746xx_25000000\WS2812b.o"
WS2812b.c:320:0: error: unterminated #if
/*========================================================================*\
^
Error(s) in build
C:\Program Files (x86)\Flowcode\Common\Compilers\starm\batch\F746Disco.bat reported error code 1
Autoclose turned off

WS2812b.fcfx
(8.09 KiB) Downloaded 217 times
Anything to get over this?

Best regards.

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: WS2812B compilation problems.

Post by mnf »

Strange - I compiled this without problem...

Then I ran an update - and afterwards got the same error. So looks like an error has crept into one of the files..

Martin

headhuntergr
Posts: 50
Joined: Fri Feb 28, 2014 7:25 am
Has thanked: 34 times
Been thanked: 5 times
Contact:

Re: WS2812B compilation problems.

Post by headhuntergr »

Mine is freshly installed and fully updated.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WS2812B compilation problems.

Post by Benj »

Hello,

Sorry for the problem, This should fix it for you. I'll get it pushed to the update system ASAP but for now here is the updated component file.

It needs to live here on your computer: C:\ProgramData\MatrixTSL\FlowcodeV8\Components
LED_WS2811.fcpx
(15.34 KiB) Downloaded 248 times

headhuntergr
Posts: 50
Joined: Fri Feb 28, 2014 7:25 am
Has thanked: 34 times
Been thanked: 5 times
Contact:

Re: WS2812B compilation problems.

Post by headhuntergr »

Thank you for your help Benj.
I am getting a different error now.


Launching the compiler...
C:\Program Files (x86)\Flowcode\Common\Compilers\starm\batch\F746Disco.bat "WS2812b" "C:\Users\K\Desktop\" "32F746xx" "F7" "stm32f.ld" "25000000" "1024K" "320K"

Project WS2812b
Device STM32F746xx


C:\Users\K\Desktop>arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -Os -DSTM32 -DSTM32F7 -DSTM32F746xx -DUSE_HAL_DRIVER -DHSE_VALUE=25000000 -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Device\ST\STM32F7xx\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc\Legacy -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\STM32746G-Discovery -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\Components -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\boards -fmessage-length=0 -fdata-sections -ffunction-sections -w -c "WS2812b.c" -o "WS2812b_STM32F746xx_25000000\WS2812b.o"

C:\Users\K\Desktop>arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -Os -DSTM32 -DSTM32F7 -DSTM32F746xx -DUSE_HAL_DRIVER -DHSE_VALUE=25000000 -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Device\ST\STM32F7xx\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc\Legacy -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\STM32746G-Discovery -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\Components -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\boards -fmessage-length=0 -fdata-sections -ffunction-sections -w -c "C:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Device\ST\STM32F7xx\Source\Templates\gcc\startup_STM32F746xx.s" -o "WS2812b_STM32F746xx_25000000\startup.o"

C:\Users\K\Desktop>arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -Os -DSTM32 -DSTM32F7 -DSTM32F746xx -DUSE_HAL_DRIVER -DHSE_VALUE=25000000 -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Device\ST\STM32F7xx\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc\Legacy -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\STM32746G-Discovery -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\Components -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\boards -fmessage-length=0 -fdata-sections -ffunction-sections -w -c "C:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Device\ST\STM32F7xx\Source\Templates\system_stm32F7xx.c" -o "WS2812b_STM32F746xx_25000000\system.o"

C:\Users\K\Desktop>arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -Os -DSTM32 -DSTM32F7 -DSTM32F746xx -DUSE_HAL_DRIVER -DHSE_VALUE=25000000 -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Device\ST\STM32F7xx\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc\Legacy -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\STM32746G-Discovery -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\Components -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\boards -fmessage-length=0 -fdata-sections -ffunction-sections -w -c "C:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\src\syscalls.c" -o "WS2812b_STM32F746xx_25000000\syscalls.o"

C:\Users\K\Desktop>arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -Os -DSTM32 -DSTM32F7 -DSTM32F746xx -DUSE_HAL_DRIVER -DHSE_VALUE=25000000 -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\CMSIS\Device\ST\STM32F7xx\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\STM32F7xx_HAL_Driver\Inc\Legacy -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\STM32746G-Discovery -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF7\Drivers\BSP\Components -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\boards -fmessage-length=0 -fdata-sections -ffunction-sections -w -c "C:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\src\MX_IRQs.c" -o "WS2812b_STM32F746xx_25000000\MX_IRQs.o"

C:\Users\K\Desktop\WS2812b_STM32F746xx_25000000>arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -Os -Wl,-T"C:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\link\stm32f.ld",--gc-sections -Xlinker --defsym=_ROMSIZE=1024K -Xlinker --defsym=_RAMSIZE=320K "ft5336.o" "MX_IRQs.o" "startup.o" "STM32746g_Discovery.o" "STM32746g_discovery_lcd.o" "STM32746g_discovery_sdram.o" "STM32746g_discovery_ts.o" "stm32f7xx_hal.o" "stm32f7xx_hal_adc.o" "stm32f7xx_hal_adc_ex.o" "stm32f7xx_hal_can.o" "stm32f7xx_hal_cec.o" "stm32f7xx_hal_cortex.o" "stm32f7xx_hal_crc.o" "stm32f7xx_hal_crc_ex.o" "stm32f7xx_hal_cryp.o" "stm32f7xx_hal_cryp_ex.o" "stm32f7xx_hal_dac.o" "stm32f7xx_hal_dac_ex.o" "stm32f7xx_hal_dcmi.o" "stm32f7xx_hal_dcmi_ex.o" "stm32f7xx_hal_dfsdm.o" "stm32f7xx_hal_dma.o" "stm32f7xx_hal_dma2d.o" "stm32f7xx_hal_dma_ex.o" "stm32f7xx_hal_dsi.o" "stm32f7xx_hal_eth.o" "stm32f7xx_hal_exti.o" "stm32f7xx_hal_flash.o" "stm32f7xx_hal_flash_ex.o" "stm32f7xx_hal_gpio.o" "stm32f7xx_hal_hash.o" "stm32f7xx_hal_hash_ex.o" "stm32f7xx_hal_hcd.o" "stm32f7xx_hal_i2c.o" "stm32f7xx_hal_i2c_ex.o" "stm32f7xx_hal_i2s.o" "stm32f7xx_hal_irda.o" "stm32f7xx_hal_iwdg.o" "stm32f7xx_hal_jpeg.o" "stm32f7xx_hal_lptim.o" "stm32f7xx_hal_ltdc.o" "stm32f7xx_hal_ltdc_ex.o" "stm32f7xx_hal_mdios.o" "stm32f7xx_hal_mmc.o" "stm32f7xx_hal_nand.o" "stm32f7xx_hal_nor.o" "stm32f7xx_hal_pcd.o" "stm32f7xx_hal_pcd_ex.o" "stm32f7xx_hal_pwr.o" "stm32f7xx_hal_pwr_ex.o" "stm32f7xx_hal_qspi.o" "stm32f7xx_hal_rcc.o" "stm32f7xx_hal_rcc_ex.o" "stm32f7xx_hal_rng.o" "stm32f7xx_hal_rtc.o" "stm32f7xx_hal_rtc_ex.o" "stm32f7xx_hal_sai.o" "stm32f7xx_hal_sai_ex.o" "stm32f7xx_hal_sd.o" "stm32f7xx_hal_sdram.o" "stm32f7xx_hal_smartcard.o" "stm32f7xx_hal_smartcard_ex.o" "stm32f7xx_hal_smbus.o" "stm32f7xx_hal_spdifrx.o" "stm32f7xx_hal_spi.o" "stm32f7xx_hal_spi_ex.o" "stm32f7xx_hal_sram.o" "stm32f7xx_hal_tim.o" "stm32f7xx_hal_tim_ex.o" "stm32f7xx_hal_uart.o" "stm32f7xx_hal_uart_ex.o" "stm32f7xx_hal_usart.o" "stm32f7xx_hal_wwdg.o" "stm32f7xx_ll_adc.o" "stm32f7xx_ll_crc.o" "stm32f7xx_ll_dac.o" "stm32f7xx_ll_dma.o" "stm32f7xx_ll_dma2d.o" "stm32f7xx_ll_exti.o" "stm32f7xx_ll_fmc.o" "stm32f7xx_ll_gpio.o" "stm32f7xx_ll_i2c.o" "stm32f7xx_ll_lptim.o" "stm32f7xx_ll_pwr.o" "stm32f7xx_ll_rcc.o" "stm32f7xx_ll_rng.o" "stm32f7xx_ll_rtc.o" "stm32f7xx_ll_sdmmc.o" "stm32f7xx_ll_spi.o" "stm32f7xx_ll_tim.o" "stm32f7xx_ll_usart.o" "stm32f7xx_ll_usb.o" "stm32f7xx_ll_utils.o" "syscalls.o" "system.o" "WS2812b.o" -o "..\WS2812b.elf" -lm
WS2812b.o: In function `FCD_06621_LED_WS2811__Refresh':
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0x32): undefined reference to `FCD_06621_LED_WS2811__OutputHigh'
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0x4a): undefined reference to `FCD_06621_LED_WS2811__OutputLow'
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0x6e): undefined reference to `FCD_06621_LED_WS2811__OutputHigh'
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0x84): undefined reference to `FCD_06621_LED_WS2811__OutputLow'
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0xbc): undefined reference to `FCD_06621_LED_WS2811__OutputHigh'
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0xd4): undefined reference to `FCD_06621_LED_WS2811__OutputLow'
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0xf8): undefined reference to `FCD_06621_LED_WS2811__OutputHigh'
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0x10e): undefined reference to `FCD_06621_LED_WS2811__OutputLow'
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0x148): undefined reference to `FCD_06621_LED_WS2811__OutputHigh'
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0x160): undefined reference to `FCD_06621_LED_WS2811__OutputLow'
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0x182): undefined reference to `FCD_06621_LED_WS2811__OutputHigh'
WS2812b.c:(.text.FCD_06621_LED_WS2811__Refresh+0x198): undefined reference to `FCD_06621_LED_WS2811__OutputLow'
collect2.exe: error: ld returned 1 exit status
Error(s) in build

C:\Program Files (x86)\Flowcode\Common\Compilers\starm\batch\F746Disco.bat reported error code 1

Autoclose turned off

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WS2812B compilation problems.

Post by Benj »

Aha sorry thanks again.

Here is the fixed component.
LED_WS2811.fcpx
(15.34 KiB) Downloaded 236 times

headhuntergr
Posts: 50
Joined: Fri Feb 28, 2014 7:25 am
Has thanked: 34 times
Been thanked: 5 times
Contact:

Re: WS2812B compilation problems.

Post by headhuntergr »

It seems to be compiling now fine.
Thank you so much.

patrick schoon
Posts: 74
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: WS2812B compilation problems.

Post by patrick schoon »

Hey Guys,

I like to hook up in this discussion with my little problem.

I'm using the WS2812B on a PIC16F18857 MCU with use of the internal oscillator running on 32MHz.

Using the WS1811 macro does not work in this setup. When running the compiler the first message is:


(1273) Omniscient Code Generation not available in Free mode (warning)
V1.0_20200704.c:
270: #warning WS2811 Timings are less than 10 instructions, timing may be incorrect at the current clock speed
^ (162) #warning: WS2811 Timings are less than 10 instructions, timing may be incorrect at the current clock speed (warning)



Checking with a probe at the MOSI pin gives now data..

The compiler does finish and the project is running fine except for the WS2812B..

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WS2812B compilation problems.

Post by Benj »

Hello,

Do you have access to a scope so you can see the specific timings the chip is outputting?

Might be worth setting the LED type to custom and playing with the timings. Maybe try reducing one of the various timings by 50% and seeing if that makes any difference, then repeat for other timings.

Let us know how you're getting on.

patrick schoon
Posts: 74
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: WS2812B compilation problems.

Post by patrick schoon »

Hi Ben,

Yes, tested with a scope but no data.

Made a test project with a different MCU.
Also no Scope data and still the warning message from the compiler.
Tested all LED_Controller variables.

Employing 18F4550 errata work-arounds:
* Corrupted fast interrupt shadow registers
Test WS2812B.c:
136: #warning WS2811 Timings are less than 10 instructions, timing may be incorrect at the current clock speed
^ (162) #warning: WS2811 Timings are less than 10 instructions, timing may be incorrect at the current clock speed (warning)

Regards,

patrick

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WS2812B compilation problems.

Post by Benj »

Hi Patrick,

Has your program changed since the last program? If so can you upload it for us.

If not then please can you try adding a loop and calling the refresh function inside the loop, also with a delay inside the loop so you're not constantly refreshing.

patrick schoon
Posts: 74
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: WS2812B compilation problems.

Post by patrick schoon »

Hi Ben,

I tested the macro more in a totaly clean project.
If the MCU clock is not in range of the macro expected clock you get no data from the MOSI pin.

If MCU clock is set right, tested in a software loop and by interupt macro, I get data from the mosi pin.
I did put the initialize call in a delayed loop and checked the data. Data is still out of range of the expected timing according to the data sheet.
Changing timing in the custom mode does not change the timing constants...

Checked now with three PIC mcu's. Wil do check with a ATMega..

Regards,

Patrick

patrick schoon
Posts: 74
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: WS2812B compilation problems.

Post by patrick schoon »

Hi Ben,

I also tested the macro on a AVR ATMega16 MCU, clock external 8MHz.

Checking the Initialize macro:
It gives in total 24 pulses. I assume all bits are set to zero. Analizing it on a scope the T0H and T0L are 480ns and 2.28ms.
T0L is far out of range according to the datasheet.
Selecting more leds do give the expected amount of bursts.
Selecting the custom or other WS chip does not change the data put out.

Only the Init and refresh macro do give data... SetAllLEDCollour does not give any data.

Regards,

Patrick.

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: WS2812B compilation problems.

Post by mnf »

SetAllLEDColour just sets the colours in an array buffer - the values are just written out in the call to refresh...

I've used the ws2812 LEDs extensively with Arduino and library seems pretty solid.

See https://matrixtsl.com/mmforums/viewtopi ... 26&t=21723 or
https://matrixtsl.com/mmforums/viewtopi ... 812#p98689 for some samples.

Martin

patrick schoon
Posts: 74
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: WS2812B compilation problems.

Post by patrick schoon »

Hi Martin,

I checked the LightBoard example and this works great on the Arduino Uno baord.
I also managed to let it work on a ATMega16 with 16MHz xtal. It does not work with a 8MHz xtal...

Testing with a PIC16F18877 is still not working. I tested with 8 and 16MHz xtals.
When starting up all leds ligt up white at initial and thats it...
Checked all kinds of fuse bits settings and i''m sure the clock is working right.

Suggestions?

Regards.

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: WS2812B compilation problems.

Post by mnf »

Looking at the code generated - the only place that data is written to the LEDs is Refresh. (Initialise calls SetallLEDColor(0,0,0) and then Refresh - to set all the LEDs to off)

Playing with ATTiny85 - with clock set to 16 and 8MHz - the delays have the same number of NOP instructions (5, 4, 0, and 6) which doesn't feel right - I'd expect half the number at half the clock rate to give the same timings... So it might be that the library doesn't compensate for clock speed correctly?

One solution - which I used on a project a while back - is to rewrite Refresh using correct timings. This requires use of an oscilloscope - look at the data sent out and adjust them so TOH TOL etc are correct... This isn't quite so daunting as it sounds - simply copy the C code generated from the current code and then replace the Delay_T1H etc macros. Note that T0H etc can be a little bit more flexible in timings (see https://wp.josh.com/2014/05/13/ws2812-n ... know-them/)

This probably isn't a substitute for getting the library fixed :-(

It might be that 8MHz chips don't quite have the oomph - the Adafruit library uses some fairly complex assembly code to get the 8MHz chips working. I did have a brief attempt at getting this working under FC - but struggled getting the asm code to compile correctly (esp jumps)

Plan C - use APA102 pixels.

Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WS2812B compilation problems.

Post by Benj »

Hello,

If you change the target device or the clock speed it might be worth reloading the project to make sure the delays are being recalculated correctly.

There was no event to detect a device or clock speed change in the component so I have now added both of these and pushed to the update system.

Attached here is the source of the component if you want to try and do some digging into the problems. Shout if you find anything and I can re-export it for you.
LED_WS2811.fcfx
(242.02 KiB) Downloaded 146 times

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: WS2812B compilation problems.

Post by mnf »

Thanks Ben,

Will have a look - and will try the update too...

Martin

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: WS2812B compilation problems.

Post by mnf »

Looking back - my main idea was to make the byte order for the display into an array - this meant that Refresh could use a loop (for RGB or GRB) - this reduced the code dramatically - a single loop did all three bytes for either target (rather than two blocks of three 8 bit writes)

This is my code for Arduino Uno (so 16MHz ATMega328p) - I'd hard coded for WS2812B (as that was what I was using) - I'll see if I can fit it into the component... (Here I've added a test on DataOrder which seems to be how the component decides this?). The resulting code is a fair bit simpler - so should be easier to tweak for Patrick's setup?

Note that the code is duplicated with a different delay method for MX_CAL_PIC32 (this will be compiled out using pre-processor directives) - but I wonder if there is a way to just modify the delay that gets compiled here rather than duplicating the complete Refresh routine

if defined PIC32
delay()
else
Macro (nop; nop; ....)
endif

RefreshLEDStrip.fcm
(4.66 KiB) Downloaded 113 times
it would take a bit of work to incorporate into the component (I've added the check for RGB GRB selection here) - as my naming conventions were rather different (I'd also called the macro RefreshLEDStrip). I also don't have the MOSI / dataPin choice - I just toggled LEDPin - I'm not sure what happens in the component here - OutputHigh/Low are empty macros. The delays are also hard coded for 16MHz here - I'm not sure how the component calculates and defines them - but it would have to use those instead.

Martin

patrick schoon
Posts: 74
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: WS2812B compilation problems.

Post by patrick schoon »

Hi Martin/Ben,

Looking at Martin's solution in hard coding i started to check Martin's code on a PIC16F18877.

Checking the timing on my scope I discovered that even with one NOP the timing delay is still 780ns with it's internal clock of 32MHz.
Increasing the NOPS counts shows that it gets stable at 3 nops. After 3 nops or more you get an increase of approx. 13uS .
1 nop; 780ns
2 nops; 900ns
3 nops; 1,03us
4 nops; 1,16us

So getting it working on a PIC MCU will be hard..
Refresh.fcfx
(13.71 KiB) Downloaded 119 times

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: WS2812B compilation problems.

Post by mnf »

One nop giving 780ns is odd. On a 16mhz arduino it it's 62.5ns. The is the overhead for setting / the pin too..

Looking at some microchip forums it's seems that one instruction cycle on the pic is clock/4 so should be running 8mips one nop 125ns
Which looks about right with the increasing time per nop.

T0H - is the tightest timing at 500ns max - how about no delay here Just 1->Pin 0 -> Pin ?

Martin

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: WS2812B compilation problems.

Post by mnf »

Looking at my code - it looks like I used the wrong macros for the LOW pulse delays..

Probably still worked because of the slightly more relaxed timing constraints mentioned in the article above?

Martin

patrick schoon
Posts: 74
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: WS2812B compilation problems.

Post by patrick schoon »

Hi Martin/Ben,

I have been working at Martin's refresh code and tuned it to a working code for the PIC MCU.
PIC WS2812B Test.fcfx
(21.7 KiB) Downloaded 134 times
Using an output as MOSI function gives to much delay in the loop. Changed it in C-code and did some measurements.

Changed the amount of nops in Martin's Refresh macro and whala.

I put two C-code for the timing in the Refresh macro. One for 16Mhz Xtal use and one for 32MHz internal Osc use.

The SetAllLedColour macro has a fault. The local Index variable is not reset if macro is called!! I put a calculation to it.

Regards,

Patrick

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: WS2812B compilation problems.

Post by mnf »

Glad you got things working... I hadn't realised there as so much overhead to the SET_PORT_PIN macro (though I did a search for it's definition - I didn't manage to find it).

I'd use a 'for' loop (loop count) with .index for 'use variable as a count' - then the initialisation is handled automagically.

Martin

sundgau
Posts: 78
Joined: Mon Sep 26, 2011 4:18 pm
Has thanked: 5 times
Been thanked: 10 times
Contact:

Re: WS2812B compilation problems.

Post by sundgau »

Hello,
I am doing tests with a RGB WX2812B and an ECIO40. The test programs work, but the signals at the oscilloscope do not match at all.
Here is a statement for a ring of 8 LEDs all lit in red (G = 0, R = 255, B = 0). Everything seems correct but here are the measurements for the low states: T0H = 80ns, T0L = 1960ns and for the high state: T0H = 840ns, T0L = 1640ns.
The times are not at all in accordance with the datasheet but it works!

At compilation, I have the same message as above:
#warning WS2811 Timings are less than 10 instructions, timing may be incorrect at the current clock speed
^ (162) #warning: WS2811 Timings are less than 10 instructions, timing may be incorrect at the current clock speed (warning)
I also tested with an allcode; same message.
By cons, no compilation message with an ECIO40P16 but I do not have the material at home ... If someone wants to give it a try.

I have no better luck with Flowcode V9 which I just downloaded. No error message but the leds light up in white with times in the low state:: T0H = 1320ns, T0L = 4480µs and for the high state: T0H = 3240ns, T0L = 2960ns; completely outside the datasheet time!

Do you think you can solve this problem for Flowcode7 and Flowcode9.

Best regards.

Bruno
Attachments
Screen Shot 12-05-20 at 03.44 PM.JPG
Screen Shot 12-05-20 at 03.44 PM.JPG (14.56 KiB) Viewed 7525 times
Screen Shot 12-05-20 at 03.45 PM.JPG
Screen Shot 12-05-20 at 03.45 PM.JPG (14.01 KiB) Viewed 7525 times
Screen Shot 12-05-20 at 03.46 PM.JPG
Screen Shot 12-05-20 at 03.46 PM.JPG (8.62 KiB) Viewed 7525 times

Post Reply