I am using the Concerto control card that has the F28M35H52C1 micro .
The control card has a 20 MHz crystal so I set up clocking to have C28 core @ 150 MHz and m3 core a@ 75 MHz with the setup below:
// Sets up PLL, M3 running at 75MHz and C28 running at 150MHz
SysCtlClockConfigSet(SYSCTL_USE_PLL | (SYSCTL_SPLLIMULT_M & 0xf) |
SYSCTL_SYSDIV_2 | SYSCTL_M3SSDIV_2 |
SYSCTL_XCLKDIV_2);
then I setup ePWM to get a 1.5 KHz frequency on PWM1A like below:
EPwm1Regs.TBCTL.bit.CLKDIV = 0; // CLKDIV = 1
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 1; // HSPCLKDIV = 2
EPwm1Regs.TBCTL.bit.CTRMODE = 2; // up - down mode
EPwm1Regs.AQCTLA.all = 0x0006; // ZRO = set, PRD = clear
EPwm1Regs.TBPRD = 25000; // 1.5KHz - PWM signal
Based on my calculation and reading: Frequency 0f PWM = C28SYSCLK/(2*HSPCLKDIV*CLKDIV*TBPRD) = 150000000/(2*2*1*25000) = 150000000/100000 = 1500 HZ.
When I run my program, I get a 750 PWM.
What am I doing wrong? Is there another clock divider that I am missing ? OR Is my calculation wrong?