Using the PWM from the DSP is giving me Gray hair, I am usin the examples from the starter kit and now I have given up can't think of any other things to try.
It is a simple PWM with asymetrical output running 30Khz (not adjusted in the code yet).
Looking in the registers everything looks OK like expected, but the counter looks static, even if I change the emul mode to "stop after next clock" is is static, if I change the counter to a different value is stays there.
Looking after the power and clock on in the PSCx0DSP register and think I found it to be ON and clock ON.
The GPIO4-8 that the PWM1A is sharing pin with, have been tested chang the PinMux to GPIO and write the output low and high and that is indicating that the pin is there and working. I am using the Ti tool to make the PinMUX and PINMUX13 is 0X00022220 indicating that it should be EPWM1A on that pin.
This is the procedure cals I am running:
void PWMInit(void) {
PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_EHRPWM, PSC_POWERDOMAIN_ALWAYS_ON,
PSC_MDCTL_NEXT_ENABLE);
// EHRPWM1PinMuxSetup();
/* TimeBase configuration */
/* Configure the clock frequency */
EHRPWMTimebaseClkConfig(SOC_EHRPWM_1_REGS, SOC_EHRPWM_1_MODULE_FREQ/CLOCK_DIV_VAL , SOC_EHRPWM_1_MODULE_FREQ);
/* Configure the period of the output waveform */
EHRPWMPWMOpFreqSet(SOC_EHRPWM_1_REGS, SOC_EHRPWM_1_MODULE_FREQ/CLOCK_DIV_VAL,
(SOC_EHRPWM_1_MODULE_FREQ/CLOCK_DIV_VAL)/0xFF, EHRPWM_COUNT_UP, EHRPWM_SHADOW_WRITE_DISABLE);
/* Disable synchronization*/
EHRPWMTimebaseSyncDisable(SOC_EHRPWM_1_REGS);
/* Disable syncout*/
EHRPWMSyncOutModeSet(SOC_EHRPWM_1_REGS, EHRPWM_SYNCOUT_DISABLE);
/* Configure the emulation behaviour*/
EHRPWMTBEmulationModeSet(SOC_EHRPWM_1_REGS, EHRPWM_STOP_AFTER_NEXT_TB_INCREMENT);
/* Configure Counter compare cub-module */
/* Load Compare A value */
EHRPWMLoadCMPA(SOC_EHRPWM_1_REGS, 63, EHRPWM_SHADOW_WRITE_DISABLE,
EHRPWM_COMPA_NO_LOAD, EHRPWM_CMPCTL_OVERWR_SH_FL);
/* Load Compare B value */
EHRPWMLoadCMPB(SOC_EHRPWM_1_REGS, 191, EHRPWM_SHADOW_WRITE_DISABLE,
EHRPWM_COMPB_NO_LOAD, EHRPWM_CMPCTL_OVERWR_SH_FL);
/* Configure Action qualifier */
/* Toggle when CTR = CMPA OR CMPB */
EHRPWMConfigureAQActionOnA(SOC_EHRPWM_1_REGS, EHRPWM_AQCTLA_ZRO_DONOTHING, EHRPWM_AQCTLA_PRD_DONOTHING ,
EHRPWM_AQCTLA_CAU_EPWMXATOGGLE, EHRPWM_AQCTLA_CAD_EPWMXATOGGLE, EHRPWM_AQCTLA_CBU_EPWMXATOGGLE,
EHRPWM_AQCTLA_CBD_EPWMXATOGGLE, EHRPWM_AQSFRC_ACTSFA_DONOTHING);
/* Bypass dead band sub-module */
EHRPWMDBOutput(SOC_EHRPWM_1_REGS, EHRPWM_DBCTL_OUT_MODE_BYPASS);
/* Disable Chopper sub-module */
EHRPWMChopperDisable(SOC_EHRPWM_1_REGS);
/* Disable trip events */
// EHRPWMTZTripEventDisable(SOC_EHRPWM_1_REGS, EHRPWM_TZ_ONESHOT);
// EHRPWMTZTripEventDisable(SOC_EHRPWM_1_REGS, EHRPWM_TZ_CYCLEBYCYCLE);
/* Event trigger */
/* Generate interrupt every 3rd occurance of the event */
//EHRPWMETIntPrescale(SOC_EHRPWM_1_REGS, EHRPWM_ETPS_INTPRD_THIRDEVENT);
/* Generate event when CTR = CMPB */
//EHRPWMETIntSourceSelect(SOC_EHRPWM_1_REGS, EHRPWM_ETSEL_INTSEL_TBCTREQUCMPBINC);
/* Enable interrupt */
// EHRPWMETIntEnable(SOC_EHRPWM_1_REGS);
/* Disable High resolution capability */
EHRPWMHRDisable(SOC_EHRPWM_1_REGS);
EHRPWMClockEnable(SOC_EHRPWM_1_REGS);
// EHRPWMConfigureChopperDuty(SOC_EHRPWM_1_REGS, EHRPWM_CHP_DUTY_50_PER);
/* chopper freq DIV by 4 */
// EHRPWMConfigureChopperFreq(SOC_EHRPWM_1_REGS, EHRPWM_PCCTL_CHPFREQ_DIVBY4);
/* OSPW- div by 0xF */
// EHRPWMConfigureChopperOSPW(SOC_EHRPWM_1_REGS, 0xF);
/* Enable Chopper */
// EHRPWMChopperEnable(SOC_EHRPWM_1_REGS);
}
Anyone have the magic word?? Or have some one stolen the PWM modul or can't the DSP access it ??
CCS5.4 is a litle tricky to make display the MDSTAT_16 and MDSTAT_32 only the first register is displayed, is this a error? I get the information by asking to "View memory at address" and looking ahead and try to find the right register to monitor.
Claus.