Hello,
I'm evaluating the LM4F232 with the evalboard EKK-LM4F232. I'm testing the PWM module for the moment on PG2 (LED of the evalboard) and I have some questions about the PWM divisor. The MCU is working at 80MHz but I tested with others frequencies.
If I set the PWM divider at specific values before the enable of the PWM, I feel that the MCU refuse to start (UART0 or SSI0 for example do not respond).
If I write the following lines :
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
ROM_SysCtlPWMClockSet(SYSCTL_PWMDIV_xx); with xx = 1 or 2 it works well but not with divisor from 4 to 64.
I tried with differents SYSCTL_SYSDIV (just in case) without success.
To have the divisor which works with all values, I have to set the PWM divider after ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1); If done before, the MCU seems to be blocked.
I tried to set config registers directly without better results
//SYSCTL_RCC_R = 0x078E3D51;
SYSCTL_RCC_R = (SYSCTL_RCC_SYSDIV_M /*| SYSCTL_RCC_USEPWMDIV | SYSCTL_RCC_PWMDIV_2*/ | SYSCTL_RCC_PWRDN | SYSCTL_RCC_BYPASS /*| SYSCTL_RCC_XTAL_16MHZ | SYSCTL_RCC_OSCSRC_INT | SYSCTL_RCC_MOSCDIS*/);
//SYSCTL_RCC_R = 0x07900D40;
SYSCTL_RCC_R = (SYSCTL_RCC_SYSDIV_M | /*SYSCTL_RCC_USEPWMDIV | SYSCTL_RCC_PWMDIV_2 |*/ SYSCTL_RCC_BYPASS | SYSCTL_RCC_XTAL_16MHZ);
//SYSCTL_RCC2_R = 0xC1004800;
SYSCTL_RCC2_R = (SYSCTL_RCC2_USERCC2 | SYSCTL_RCC2_DIV400 | SYSCTL_RCC2_SYSDIV2_2 | SYSCTL_RCC2_USBPWRDN | SYSCTL_RCC2_BYPASS2 | SYSCTL_RCC2_OSCSRC2_MO);
//SYSCTL_RCC_R = 0x07D00D40;
SYSCTL_RCC_R = (SYSCTL_RCC_SYSDIV_M | SYSCTL_RCC_USESYSDIV | SYSCTL_RCC_USEPWMDIV | SYSCTL_RCC_PWMDIV_4 | SYSCTL_RCC_BYPASS | SYSCTL_RCC_XTAL_16MHZ);
while ((SYSCTL_RIS_R & SYSCTL_RIS_PLLLRIS) != SYSCTL_RIS_PLLLRIS) {} // Waiting for the stabilization of the PLL
//SYSCTL_RCC2_R = 0xC1004000;
SYSCTL_RCC_R = (SYSCTL_RCC_SYSDIV_M | SYSCTL_RCC_USESYSDIV | SYSCTL_RCC_USEPWMDIV | SYSCTL_RCC_PWMDIV_4 | SYSCTL_RCC_XTAL_16MHZ);
SYSCTL_RCC2_R = (SYSCTL_RCC2_USERCC2 | SYSCTL_RCC2_DIV400 | SYSCTL_RCC2_SYSDIV2_2 | SYSCTL_RCC2_USBPWRDN | SYSCTL_RCC2_OSCSRC2_MO);
With SYSCTL_RCC_PWMDIV_1 or SYSCTL_RCC_PWMDIV_2 it works but not with others values (MCU stopped too).
On the page 1274, it's recommended to clock the PWM before making changes in the PWM divisor but it's weird that it works with divider equal to 1 or 2 and block the MCU with the other values. From my experience on the LM3S6965, I can clock the PWM after setting the PWM divisor.
Best regards,
Sébastien