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

PWM Differential output

Would you please tell me how to use the nrf52832 PWM interface to implement differential output to spkr?

Here is my PWM interface configuration code:

NRF_PWM0->PSEL.OUT[0] =   (PWM_IO << PWM_PSEL_OUT_PIN_Pos) | (PWM_PSEL_OUT_CONNECT_Connected << PWM_PSEL_OUT_CONNECT_Pos);
NRF_PWM0->PSEL.OUT[1] =   (0 << PWM_PSEL_OUT_PIN_Pos) | (PWM_PSEL_OUT_CONNECT_Disconnected << PWM_PSEL_OUT_CONNECT_Pos);
NRF_PWM0->PSEL.OUT[2] =   (1 << PWM_PSEL_OUT_PIN_Pos) | (PWM_PSEL_OUT_CONNECT_Disconnected << PWM_PSEL_OUT_CONNECT_Pos);
NRF_PWM0->PSEL.OUT[3] =   (2 << PWM_PSEL_OUT_PIN_Pos) | (PWM_PSEL_OUT_CONNECT_Disconnected << PWM_PSEL_OUT_CONNECT_Pos);

NRF_PWM0->ENABLE = (PWM_ENABLE_ENABLE_Enabled << PWM_ENABLE_ENABLE_Pos);
NRF_PWM0->MODE = (PWM_MODE_UPDOWN_Up << PWM_MODE_UPDOWN_Pos);
NRF_PWM0->PRESCALER = (PWM_PRESCALER_PRESCALER_DIV_1 << PWM_PRESCALER_PRESCALER_Pos);
NRF_PWM0->COUNTERTOP = (256/*16000*/ << PWM_COUNTERTOP_COUNTERTOP_Pos);
NRF_PWM0->DECODER =   (PWM_DECODER_LOAD_Common << PWM_DECODER_LOAD_Pos) | (PWM_DECODER_MODE_RefreshCount << PWM_DECODER_MODE_Pos);

NRF_PWM0->SHORTS = (PWM_SHORTS_LOOPSDONE_SEQSTART0_Disabled << PWM_SHORTS_LOOPSDONE_SEQSTART0_Pos);

Here is my PWM audio output code:

	NRF_PWM0->SEQ[0].PTR = ((uint32_t)(pwmdata) << PWM_SEQ_PTR_PTR_Pos);
	NRF_PWM0->SEQ[0].CNT = ((sizeof(pwmdata) / sizeof(uint16_t)) << PWM_SEQ_CNT_CNT_Pos);
	NRF_PWM0->SEQ[0].REFRESH = REFRESHBD;
	NRF_PWM0->SEQ[0].ENDDELAY = REFRESHBD * ((HALFLOOPPERIOD / REFRESHBD) - ((sizeof(pwmdata) / sizeof(uint16_t))));
	
	NRF_PWM0->LOOP = (0 << PWM_LOOP_CNT_Pos);
	NRF_PWM0->TASKS_SEQSTART[0] = 1;

Is it possible to achieve PWM differential output?

Thanks!

Related