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

nRF52832 No accurate 4MHz PWM output with SoftwateDevice 332 in SDK11.0.0

SDK:11.0.0

MCU:nRF52832

Using example:ble_ant_app_hrm

SoftwateDevice Version:s332

PWM is turned on and accurate 4MHz is available before entering ble_stack_init();

PWM is unstable after enterd SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL); in ble_stack_init();

How to keep 32MHz external crystal always running with SoftwateDevice Version:s332?

How can I keep accurate 4MHz PWM output after enterd ble_stack_init();?

I really need ACCURATE 4MHz PWM output.

Waiting online,Thanks for help

Parents
  • If you see variable frequency on the PWM after enabling the SoftDevice and start advertising or in a connection, it may be because the clock source is changing between the crystal and the internal oscillator. You can keep the crystal running with the sd_clock_hfclk_request() function:

    uint32_t p_is_running = 0;
    sd_clock_hfclk_request();
    while(! p_is_running) {                             //wait for the hfclk to be available
        sd_clock_hfclk_is_running((&p_is_running));
    }
    
  • Thanks for help!Keep external 32MHz crystal is the right direction! Where should I put those codes? I tryed to put it here but the code got block at while(! p_is_running)

    static void ble_stack_init(void) { uint32_t err_code = NRF_SUCCESS; uint32_t p_is_running = 0; sd_clock_hfclk_request(); while(! p_is_running) { //wait for the hfclk to be available sd_clock_hfclk_is_running((&p_is_running)); } nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;

    // Initialize the SoftDevice handler module. SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);

Reply
  • Thanks for help!Keep external 32MHz crystal is the right direction! Where should I put those codes? I tryed to put it here but the code got block at while(! p_is_running)

    static void ble_stack_init(void) { uint32_t err_code = NRF_SUCCESS; uint32_t p_is_running = 0; sd_clock_hfclk_request(); while(! p_is_running) { //wait for the hfclk to be available sd_clock_hfclk_is_running((&p_is_running)); } nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;

    // Initialize the SoftDevice handler module. SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);

Children
No Data
Related