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

BLE_App_Uart + ADC + PWM

Hi everyone.

I know this is gonna be a long story, thank you for your patience...

I have successfully utilized a few examples in the SDK15.3 directory on my PCA10056 including the PWM driver, BLE_APP_UART and SAADC.

Also I could merge the PWM driver example and the BLE_APP_Uart.

now that I have tried to add the SAADC example to my code, everything stops working, e.g. all the LEDs that are controlled by the buttons and the PWM driver and the UART output on my terminal... only a blank line is added on each loop. (neither log or printf work).

the code is built and flashed on the core successfully without any errors.

when I try to debug my code using Keil5 it shows that the program stops somewhere like "NRF_BREAKPOINT_COND", I am not aware what it is for. Here it is:

The code is quite large in the main.c file but as its built without any error I only add main function here:

int main(void)
{
    bool erase_bonds;
uint32_t err_code;

    // Initialize.
    uart_init();
    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
			//mig//
			printf("\r\n  .UART + PWM Periph \r\n");
	    printf("\r\nUART started.\r\n");

//	    uint32_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();

    ret_code_t ret_code = nrf_pwr_mgmt_init();
    APP_ERROR_CHECK(ret_code);

    saadc_init();
    saadc_sampling_event_init();
    saadc_sampling_event_enable();
    NRF_LOG_INFO("SAADC HAL simple example started.");

	
	   //init app_button module, 50ms detection delay (button debouncing)
    err_code = app_button_init((app_button_cfg_t *)app_buttons,
                                   NUM_OF_BUTTONS,
                                   APP_TIMER_TICKS(50));//, APP_TIMER_PRESCALER));
    APP_ERROR_CHECK(err_code);

    err_code = app_button_enable();
    APP_ERROR_CHECK(err_code);
	
    // Start execution.
  
    NRF_LOG_INFO("Debug logging for UART over RTT started.");
    advertising_start();
		    pwm_init();

    pwm_update_duty_cycle(DS);
    //demo2();
    // Enter main loop.
    for (;;)
    {
				nrf_delay_ms(300);
			  printf("\r\nLoop.\r\n");
	  		NRF_LOG_FLUSH();

        nrf_pwr_mgmt_run();
        
    }
}

Parents
  • Check your call stack, there should be error info in there.

    What does your log say?

  • Hi Haakonsh,

    I see a "app_error_fault_handler" function in the call stack tab , nothing more ...

    also I don't receive the log through COM port at all.

    there are two other suggestions:

    1: as mentioned here the error occurs while debugging might be totally deceiving.

    2: I suspect that enabling the nrf_log module while using the UART module in the BLE example might bring about some conflicts though I have no idea why it should cause the MCU stop working.

  • Thank you Haakonsh,

    I have posted the main.c in my previous replies, here is the code around line 1074, its actually an error process call function and before that, we have conn_param_init()

        conn_params_init();
    			//mig//
    			printf("\r\n  .UART + PWM Periph \r\n");
    	    printf("\r\nUART started.\r\n");
    
    //	    uint32_t err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);   --->1074

    And something more, I have checked the link You sent about hardware restrictions when utilizing softdevice, it says even "NVIC"  module is not available! that may be the root of my problem, because I didnt change anything about it when adding the "SAADC" example to the BLE example. seems like there are many issues for joining non-BLE examples to a BLE example...

  • Neuro_Rouh said:
    I have posted the main.c in my previous replies, here is the code around line 1074, its actually an error process call function and before that, we have conn_param_init()

    But what function assigned the error code that was sent to APP_ERROR_CHECK()?
     

    Neuro_Rouh said:
    And something more, I have checked the link You sent about hardware restrictions when utilizing softdevice, it says even "NVIC"  module is not available! that may be the root of my problem, because I didnt change anything about it when adding the "SAADC" example to the BLE example. seems like there are many issues for joining non-BLE examples to a BLE example...

    That won't be a problem as long as the SAADC driver is configured with an interrupt priority of 6 or 7 (default is 6 I think). So if you've just merged the SAADC example, with the same sdk_config.h settings then you're fine. 

  • Found the issue, you need to zero-initalize the variable err_code to NRF_SUCCESS, who's value is zero. 

  • Oh your replies just loaded for me! I used to receive email notifications on thread updates, things changes rapidly in Nordic semi world... I will check your solution very soon...

    And could you please provide some information about using  the softdevice APIs for restricted peripherals?? For example I f I have to abandon Timer0, should I disable it in the CMSIS wizard? or  how can I manage NVIC (both configurations and utilization) when using a peripheral like SAADC together with softdevice enabled?

  • Neuro_Rouh said:
    For example I f I have to abandon Timer0, should I disable it in the CMSIS wizard?

     That works. You don't really have to do anything except not use it when the SoftDevice needs it. 

    Neuro_Rouh said:
    how can I manage NVIC (both configurations and utilization) when using a peripheral like SAADC together with softdevice enabled?

    See SoftDevice NVIC API and Interrupt model and processor availability- >Interrupt priority levels

    In general the SDK is setup such that if you use a peripheral, like the saadc driver, with its default IRQ priority it will not affect the operation of the SoftDevice. 

Reply Children
No Data
Related