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

PWM individual decoder not working

Hi all,

I have two pwm pins I would like to have them run at two different duty cycles. My understanding is that we can do this by setting the decoder to individual. When I set this register to individual my output flat lines. Although, When I set it to grouped both of my PWM pins output a pwm at 60hz 50% duty cycle as expected.

Below is my code.

uint16_t pwm_doody[2]={0x250, 0x421};

NRF_PWM0->PSEL.OUT[0] = (PWM_PINA << PWM_PSEL_OUT_PIN_Pos)|(PWM_PSEL_OUT_CONNECT_Connected << PWM_PSEL_OUT_CONNECT_Pos);

NRF_PWM0->PSEL.OUT[1] = (PWM_PINB << PWM_PSEL_OUT_PIN_Pos)|(PWM_PSEL_OUT_CONNECT_Connected << PWM_PSEL_OUT_CONNECT_Pos);

NRF_PWM0->ENABLE = (PWM_ENABLE_ENABLE_Enabled << PWM_ENABLE_ENABLE_Pos); NRF_PWM0->MODE = (PWM_MODE_UPDOWN_Up);

NRF_PWM0->PRESCALER = (PWM_PRESCALER_PRESCALER_DIV_128);

NRF_PWM0->COUNTERTOP = (0x823);

NRF_PWM0->LOOP = (PWM_LOOP_CNT_Disabled);

NRF_PWM0->DECODER = (PWM_DECODER_LOAD_Individual << PWM_DECODER_LOAD_Pos)|(PWM_DECODER_MODE_RefreshCount << PWM_DECODER_MODE_Pos);

NRF_PWM0->SEQ[0].PTR = ((uint32_t)(pwm_doody) << PWM_SEQ_PTR_PTR_Pos);

NRF_PWM0->SEQ[0].CNT = ((sizeof(pwm_doody) / sizeof(uint16_t)) << PWM_SEQ_CNT_CNT_Pos);

NRF_PWM0->SEQ[0].REFRESH = 0;

NRF_PWM0->SEQ[0].ENDDELAY = 0;

NRF_PWM0->TASKS_SEQSTART[0] = 1;

Related