zephyr 2.9.0 led_pwm sample nrf52840 1sec blink fails

Hello,

When running the sample on nrf52840DK:

 <inf> main:   Cycle period not supported - on: 1 sec, off: 1 sec
[00:00:28.621,917] <inf> main:   Turned off, loop end
[00:00:28.642,456] <inf> main: Testing LED 0 - no label
[00:00:28.663,208] <inf> main:   Turned on
[00:00:29.682,861] <inf> main:   Turned off
[00:00:30.702,606] <inf> main:   Increasing brightness gradually
[00:00:32.744,445] <inf> main:   Blinking on: 0.1 sec, off: 0.1 sec
[00:00:37.766,326] <err> pwm_nrfx: Prescaler for period_cycles 32000000 not found.
[00:00:37.789,764] <err> main: err=-22
[00:03:56.759,429] <inf> main:   Cycle period not supported - on: 1 sec, off: 1 sec

How to change the sample so that the 1sec on 1sec off blink pattern works?

I guess it has to do with the prescaler, but how to change it?

Tested this on nrf52840DK and custom hardware with nrf52840, both zephyr 2.6.2 and 2.9.0

Parents
  • Hello,

    From first inspection it seems that the issue is that the requested cycle period is just not supported on the nRF52840. The valid prescaler values are listed here (product specification).

    First steps could be to find out if the value for period_cycles is found in the linked table, and then try to find out what the maximum value for period_cycles is from there.

    Let me know what you find out, and we'll go from there.

    Best regards,

    Maria

  • The nrfx_pwm example did what I wanted. I copied some lines below to show the essentials. I am calling  nrfx_pwm_uninit every time pwm_handler runs, and decide there if calling nrfx_pwm_init and nrfx_pwm_simple_playback again if repeated behaviour is desired.

    // example patterns:
    nrf_pwm_values_common_t pwm_val_slow_3x []=
    {
        //0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0
        0, 1000, 1000, 1000, 1000, 0, 1000, 1000, 1000, 1000, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
    };
    
    nrf_pwm_values_common_t pwm_val_fast []=
    {
        //0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0
        0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000
    };
    
    nrf_pwm_sequence_t seq =
    {
        .values = {pwm_val_fast},
        .length = NRFX_ARRAY_SIZE(pwm_val_fast),
        .repeats = VALUE_REPEATS,
        .end_delay = 0
    };
    
    nrfx_pwm_config_t config_yellow = NRFX_PWM_DEFAULT_CONFIG(15, 16, -1, -1);
    nrfx_pwm_config_t *pconfig = &config_yellow;
    seq.values.p_common = pwm_val_fast;
    seq.length = NRFX_ARRAY_SIZE(pwm_val_fast);
    
    nrfx_err_t status = nrfx_pwm_init(inst, pconfig, pwm_handler, inst);        
    NRFX_ASSERT(status == NRFX_SUCCESS);  
    
    nrfx_pwm_simple_playback(inst, &seq, PLAYBACK_COUNT, NRFX_PWM_FLAG_LOOP);

Reply
  • The nrfx_pwm example did what I wanted. I copied some lines below to show the essentials. I am calling  nrfx_pwm_uninit every time pwm_handler runs, and decide there if calling nrfx_pwm_init and nrfx_pwm_simple_playback again if repeated behaviour is desired.

    // example patterns:
    nrf_pwm_values_common_t pwm_val_slow_3x []=
    {
        //0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0
        0, 1000, 1000, 1000, 1000, 0, 1000, 1000, 1000, 1000, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
    };
    
    nrf_pwm_values_common_t pwm_val_fast []=
    {
        //0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0
        0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000
    };
    
    nrf_pwm_sequence_t seq =
    {
        .values = {pwm_val_fast},
        .length = NRFX_ARRAY_SIZE(pwm_val_fast),
        .repeats = VALUE_REPEATS,
        .end_delay = 0
    };
    
    nrfx_pwm_config_t config_yellow = NRFX_PWM_DEFAULT_CONFIG(15, 16, -1, -1);
    nrfx_pwm_config_t *pconfig = &config_yellow;
    seq.values.p_common = pwm_val_fast;
    seq.length = NRFX_ARRAY_SIZE(pwm_val_fast);
    
    nrfx_err_t status = nrfx_pwm_init(inst, pconfig, pwm_handler, inst);        
    NRFX_ASSERT(status == NRFX_SUCCESS);  
    
    nrfx_pwm_simple_playback(inst, &seq, PLAYBACK_COUNT, NRFX_PWM_FLAG_LOOP);

Children
No Data
Related