This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335X PWM setup

I'm trying to setup a PWM channel on a AM335x evkit, where I have problems when accessing some registers. I already searched the forums, but the answers I found did not help.

I perform the following operations to setup the channel:

HWREG(SOC_PRCM_REGS + CM_PER_EPWMSS0_CLKCTRL) |= CM_PER_EPWMSS0_CLKCTRL_MODULEMODE_ENABLE;

while ((HWREG(SOC_PRCM_REGS + CM_PER_EPWMSS0_CLKCTRL) & CM_PER_EPWMSS0_CLKCTRL_MODULEMODE) != CM_PER_EPWMSS0_CLKCTRL_MODULEMODE_ENABLE) {    }

while ((HWREG(SOC_PRCM_REGS + CM_PER_EPWMSS0_CLKCTRL) & CM_PER_EPWMSS0_CLKCTRL_IDLEST) != (CM_PER_EPWMSS0_CLKCTRL_IDLEST_FUNC << CM_PER_EPWMSS0_CLKCTRL_IDLEST_SHIFT)) {    }

HWREG(pwmOutConfig.m_pwmSubSystemBaseAddress + PWMSS_CLOCK_CONFIG) = PWMSS_EHRPWM_CLK_EN_ACK;

 HWREG(pwmOutConfig.m_pwmModuleBaseAddress + EHRPWM_TBCTL) &= EHRPWM_TBCTL_PHSEN;

HWREG(pwmOutConfig.m_pwmModuleBaseAddress + EHRPWM_TBCTL) |= (EHRPWM_TBCTL_SYNCOSEL_DISABLE << EHRPWM_TBCTL_SYNCOSEL_SHIFT);

HWREG(pwmOutConfig.m_pwmModuleBaseAddress + EHRPWM_TBCTL) &= ~EHRPWM_TBCTL_FREE_SOFT;

HWREG(pwmOutConfig.m_pwmModuleBaseAddress + EHRPWM_TBCTL) &= ~EHRPWM_TBCTL_CTRMODE;

HWREG(SOC_CONTROL_REGS + CONTROL_PWMSS_CTRL) = CONTROL_PWMSS_CTRL_PWMSS0_TBCLKEN;

HWREG(pwmOutConfig.m_pwmModuleBaseAddress + EHRPWM_TBCTL) |= EHRPWM_TBCTL_PRDLD;

HWREG(pwmOutConfig.m_pwmModuleBaseAddress + EHRPWM_TBCTL) &= ~EHRPWM_TBCTL_CLKDIV;

HWREG(pwmOutConfig.m_pwmModuleBaseAddress + EHRPWM_TBCTL) |= (clkDiv << EHRPWM_TBCTL_CLKDIV_SHIFT); 

HWREG(pwmOutConfig.m_pwmModuleBaseAddress + EHRPWM_TBCTL) &= ~EHRPWM_TBCTL_HSPCLKDIV;  

HWREG(pwmOutConfig.m_pwmModuleBaseAddress + EHRPWM_TBCTL) |= (hspClkDiv << EHRPWM_TBCTL_HSPCLKDIV_SHIFT);

Now I want to set the PWM period:

HWREG(pwmOutConfig.m_pwmModuleBaseAddress + EHRPWM_TBPRD) = periodCountRegValue;

This operation fails (program jumps to Abort/Undef Handler). The access of other registers (like e.g. EPWM0_CMPA) which follow this initialization also fail.

Is there something else I have to initialize the get the above access working?

 

Thanks

Thomas