HW PWM disturbance

Hi!

I'm developing for nrf52832 using zephyr. I'm using the nordic hal driver in order to use the PWM with EasyDMA. The PWM is used to control a piezo buzzer. The PWM is working and to my understanding the CPU should not be able to interfere when using the PWM with EasyDMA. But we are having some typ of interference. If I have the BLE enabled the sound of the buzzer is a bit "blurry" but if I disablde the BLE or lowering the advertising interval (BT_GAP_ADV_SLOW_INT_MIN, BT_GAP_ADV_SLOW_INT_MAX) the sound is better.

Regardless of the settings on the BLE, once every 7-8 second i get like a interruption on the buzzer, just like something are interfering.

Is there something that can interfere with the PWM using EasyDMA?

Best regards Jonas

  • Hi!

    The Bluetooth stack will request the HFXO when it uses the RADIO, so you might see some small jitter when HFCLK changes between HFINT and HFXO.

    You can call this function below to request HFXO to be used all the time, and see if you see any changes:

    int clocks_start(void)
    {
    	int err;
    	int res;
    	struct onoff_manager *clk_mgr;
    	struct onoff_client clk_cli;
    
    	clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
    	if (!clk_mgr) {
    		LOG_ERR("Unable to get the Clock manager");
    		return -ENXIO;
    	}
    
    	sys_notify_init_spinwait(&clk_cli.notify);
    
    	err = onoff_request(clk_mgr, &clk_cli);
    	if (err < 0) {
    		LOG_ERR("Clock request failed: %d", err);
    		return err;
    	}
    
    	do {
    		err = sys_notify_fetch_result(&clk_cli.notify, &res);
    		if (!err && res) {
    			LOG_ERR("Clock could not be started: %d", res);
    			return res;
    		}
    	} while (err);
    
    	LOG_DBG("HF clock started");
    	return 0;
    }

  • Hi!

    Thanks for the answer. Tried the solution and it became much better :)

    Could this have any impact on the power consumption? 

    BR Jonas

  • JonasS said:
    Thanks for the answer. Tried the solution and it became much better :)

    Great to hear!

    JonasS said:
    Could this have any impact on the power consumption? 

    Yes, from the PS we have that the Run current for HFINT is 60uA, while the run current for HFXO is 250uA.

  • Ok, that was quite big difference.

    Our product is dependent on the power consumption so I have another questions.

    Is it possible, when we need to drive the PWM controlling the buzzer, lock it so that it not using the HFINT. And then when we not using the PWM anymore switch back letting the system switch again between the clocks?

    Best regards Jonas

  • Hi!

    JonasS said:
    Is it possible, when we need to drive the PWM controlling the buzzer, lock it so that it not using the HFINT. And then when we not using the PWM anymore switch back letting the system switch again between the clocks?

    Yeah, absolutely. 

    Use 
    err = onoff_cancel_or_release(clk_mgr, &clk_cli);

    when the PWM is not being used.

Related