This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to turn on 4 LEDs in BLE at nrf52832?

Hi, Everyone
How to turn on 4 LEDs in BLE ?
I am testing ble_app_uart on nrf52832 (softdevice s132).
Try to blink the four LEDs on the board do.
I have added to main()
bsp_board_led_invert (BSP_BOARD_LED_2);
bsp_board_led_invert (BSP_BOARD_LED_3);
LED 2 and 3 don't turn on

Can somebody guide me what could be the problem?

Parents Reply Children
  • Thank you for your quick response.
    int main(void)
    {
        uint32_t err_code;
    //	bool     erase_bonds;
    
        // Initialize.
        err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
    
        uart_init();
        log_init();
    
    #if 0
    //180227
    	buttons_leds_init(&erase_bonds);
    #else
    	bsp_board_leds_init();
    #endif
        ble_stack_init();
        gap_params_init();
        gatt_init();
        services_init();
        advertising_init();
        conn_params_init();
    
    //180223 SPI-S
        APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
        NRF_LOG_DEFAULT_BACKENDS_INIT();
        
        NRF_LOG_INFO("SPI example.");
    
        nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config.ss_pin   = SPI_SS_PIN;
        spi_config.miso_pin = SPI_MISO_PIN;
        spi_config.mosi_pin = SPI_MOSI_PIN;
        spi_config.sck_pin  = SPI_SCK_PIN;
        APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));
    //180223 SPI-E
    	
        printf("\r\nUART Start!\r\n");
        NRF_LOG_INFO("UART Start!");
        err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    
        while (1)
        {
            // Reset rx buffer and transfer done flag
            memset(m_rx_buf, 0, m_length);
            spi_xfer_done = false;
    
            APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, m_length, m_rx_buf, m_length));
    
    		nrf_delay_ms(200);
    
            while (!spi_xfer_done)
            {
                __WFE();
            }
    
            NRF_LOG_FLUSH();
    
    		bsp_board_led_invert(BSP_BOARD_LED_0);
    		bsp_board_led_invert(BSP_BOARD_LED_1);
    		bsp_board_led_invert(BSP_BOARD_LED_2);		
            bsp_board_led_invert(BSP_BOARD_LED_3);		
            nrf_delay_ms(200);
        }
    //180223 SPI-E	
    
    #if 0
        // Enter main loop.
        for (;;)
        {
            UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
        printf("\r\nUART Start!\r\n");
        NRF_LOG_INFO("UART Start!");		
            power_manage();
        }
    #endif	
    }
  • What is the LEDS_NUMBER symbol set to in your board header file? Which SDK version are you using? Are you testing this on a nRF52-DK or some custom board? If custom board, which GPIO are the LEDs connected to?

  • SDK version is nRF5_SDK_14.2.0_17b948a

    Board is PCA10040(nRF52830) no custom board

    SoftDevice is s132

    #define LEDS_NUMBER 4

    I tried the test by adding only the following sentence to main () in "examples\ble_peripheral\ble_app_uart".

    bsp_board_led_invert(BSP_BOARD_LED_0);

    bsp_board_led_invert(BSP_BOARD_LED_1);
    bsp_board_led_invert(BSP_BOARD_LED_2);
    bsp_board_led_invert(BSP_BOARD_LED_3);

    The result is that only LED0 and LED1 blink

    LED2 and LED3 no action

  • Could you try configuring and toggling the LEDs manually using the GPIO abstraction functions, to check if there are some issues in the code or with the board?

    #include "nrf_gpio.h"
    
    #define BOARD_LED_3 19
    #define BOARD_LED_4 20
    
    nrf_gpio_cfg_output(BOARD_LED_3);
    nrf_gpio_cfg_output(BOARD_LED_4);
    nrf_gpio_pin_set(BOARD_LED_3);
    nrf_gpio_pin_set(BOARD_LED_4);
    
    while(1)
    {
        nrf_delay_ms(1000);
        nrf_gpio_pin_toggle(BOARD_LED_3);
        nrf_gpio_pin_toggle(BOARD_LED_4);
    }

  • Thank you for your kind and quick reply. I have a mistake in pin assignment. LED3 and 4 are well controlled.

Related