Part Number: TM4C1231H6PZ
Hello ,
i have an problem to understand pwm and prescaler ...
If i use the pwm without prescaler,
everything work as expected.
If i use the precaler, erverything went wrong ...
TimerPrescaleSet( TIMER0_BASE , TIMER_BOTH , 1 ) ;
I thought, that this will divide /2 .
The freq will be 1khz instead of 2khz, but the pwm dutycycle doesn't work anymore.
As i understood i will have an 24bit Counter ( 16bit + 8bit prescaler ), but what about the
the load and match, they are still 16bit ?
What i have to do, to use pwm with prescaler?
//PWM frequency in hz
uint32_t freq = 2000;
int tmain()
{
//Set system clock to 80Mhz
SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
SysTickbegin();
uint32_t Period, dutyCycle;
Period = SysCtlClockGet()/freq ;
dutyCycle = Period-2;
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlDelay(3);
GPIOPinConfigure(GPIO_PF1_T0CCP1);
GPIOPinTypeTimer(GPIO_PORTF_BASE, GPIO_PIN_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
SysCtlDelay(3);
TimerPrescaleSet( TIMER0_BASE , TIMER_BOTH , 1 ) ;
TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_B_PWM);
TimerLoadSet(TIMER0_BASE, TIMER_B, Period -1);
TimerMatchSet(TIMER0_BASE, TIMER_B, Period ); // PWM
TimerEnable(TIMER0_BASE, TIMER_B);
int i;
while(1)
{
for(i=1; i < ( Period ) -1; i++){
TimerMatchSet(TIMER0_BASE, TIMER_B, i);
SysCtlDelay(200);
}
}
}

