Using ws2812 with nrf52840

I am trying to control ws2812 LED (1 LED) with NRF52840 using nrf connect SDK, I was able to control it with no problem when I set building optimization to debug optimization, but when I set optimization to size or speed optimization I get a hard fault message when function 

led_strip_update_rgb(strip, pixels, STRIP_NUM_PIXELS); is called
[00:00:04.002,014] <err> os: ***** USAGE FAULT *****
[00:00:04.002,349] <err> os:   Attempt to execute undefined instruction
[00:00:04.002,777] <err> os: r0/a1:  0x01000002  r1/a2:  0x00000000  r2/a3:  0x0000001f
[00:00:04.003,295] <err> os: r3/a4:  0x07ffffff r12/ip:  0x00000100 r14/lr:  0x003d0900
[00:00:04.003,814] <err> os:  xpsr:  0x21000000
[00:00:04.004,*** Booting My Application v3.5.0-c1ab2163a399 ***
*** Using nRF Connect SDK v2.8.0-a2386bfc8401 ***
*** Using Zephyr OS v3.7.99-0bc3393fb112 ***
I am using nrf connect sdk 2.8.0
BR
M.ElSabagh
Parents
  • Here is how my overlay looks like 

    &spi3 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	pinctrl-0 = <&spi3_default_alt>;
    	pinctrl-1 = <&spi3_sleep_alt>;
    	// cs-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>; /* D4 */ 
        pinctrl-names = "default", "sleep";
    
    	led_strip: ws2812@0 {
    		compatible = "worldsemi,ws2812-spi";
    
    		/* SPI */
    		reg = <0>; /* ignored, but necessary for SPI bindings */
    		spi-max-frequency = <SPI_FREQ>;
    
    		/* WS2812 */
    		chain-length = <1>; /* arbitrary; change at will */
    		color-mapping = <LED_COLOR_ID_GREEN
    				 LED_COLOR_ID_RED
    				 LED_COLOR_ID_BLUE>;
    		spi-one-frame = <ONE_FRAME>;
    		spi-zero-frame = <ZERO_FRAME>;
    	};
    };
    
    
    
    spi3_default_alt: spi3_default_alt {
    		group1 {
    			psels = <NRF_PSEL(SPIM_MOSI, 0, 9)>;
    			low-power-enable;
    		};
    	};
    
    	spi3_sleep_alt: spi3_sleep_alt {
    		group1 {
    			psels = <NRF_PSEL(SPIM_MOSI, 0, 9)>;
    			low-power-enable;
    		};
    	};

Reply
  • Here is how my overlay looks like 

    &spi3 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	pinctrl-0 = <&spi3_default_alt>;
    	pinctrl-1 = <&spi3_sleep_alt>;
    	// cs-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>; /* D4 */ 
        pinctrl-names = "default", "sleep";
    
    	led_strip: ws2812@0 {
    		compatible = "worldsemi,ws2812-spi";
    
    		/* SPI */
    		reg = <0>; /* ignored, but necessary for SPI bindings */
    		spi-max-frequency = <SPI_FREQ>;
    
    		/* WS2812 */
    		chain-length = <1>; /* arbitrary; change at will */
    		color-mapping = <LED_COLOR_ID_GREEN
    				 LED_COLOR_ID_RED
    				 LED_COLOR_ID_BLUE>;
    		spi-one-frame = <ONE_FRAME>;
    		spi-zero-frame = <ZERO_FRAME>;
    	};
    };
    
    
    
    spi3_default_alt: spi3_default_alt {
    		group1 {
    			psels = <NRF_PSEL(SPIM_MOSI, 0, 9)>;
    			low-power-enable;
    		};
    	};
    
    	spi3_sleep_alt: spi3_sleep_alt {
    		group1 {
    			psels = <NRF_PSEL(SPIM_MOSI, 0, 9)>;
    			low-power-enable;
    		};
    	};

Children
No Data
Related