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

Attachment code,After sending the data about 52832 or 51822 module bluetooth connection drops?

How do you do The attachment is a problem in the previous code, please help to debug it, thanksble_app_uart_pwm.rar E:\nordic\nRF5_SDK_12.2.0\examples\ble_peripheral\ble_app_uart_pwm\pca10040\s132\arm5_no_packs

  • Hi,

    You calling motor_pwm() 2 times in your application. The first time is before you enter the main loop, and the second time is when you receive data over BLE and the flag pwm_flag_ble is set to 1.

    The 2nd time you are calling motor_pwm(), the function nrf_drv_pwm_init() will return NRF_ERROR_INVALID_STATE since the driver was already initialized the first time you called motor_pwm(). You will then enter the error-handler, and the BLE link will disconnect.

    A solution could be to remove the first call to the motor_pwm() function, if you don't want to start the PWM before you receive data over BLE.

  • Also note that you should not use

     __WFE();
    
    // Clear the event register.
    __SEV();
    __WFE();
    

    with the SoftDevice. Use the function power_manage() instead.

Related