Hi,
We want to generate frequency output in the range (1-1K Hz) with a fixed 50% dutycyle for our project using Tiva TM4C1294NCPDT uC.
I have configured general-purpose timer in 16-bit PWM mode. I am having issues with adjusting the timer period when using prescalor. I have set prescalor to 4 which allows maximum Load value to 327679 (0x4FFFF). For 50 % duty cyle the maximum Match value is 163839 so i set the prescalor Match value to 2. The PWM output is correct only when Load value is above 262143 (0x3FFFF) that is the maximum value with prescalor 3. With Load value less than 262144 both the period and dutycyle are false.
Does this means when using prescalor 4 I can only write load value in the range [327679,262144] and not less than 262144? Am I setting the prescalors correctly? Or are there any systematic details regarding setting prescalor for load and match values?
#include <stdbool.h>
#include <stdint.h>
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "inc/hw_gpio.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_timer.h"
#include "inc/hw_types.h"
int main(void) {
SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120E6);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
while (!SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER3)) {}
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
while (!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA)) {}
GPIOPinConfigure(GPIO_PA6_T3CCP0);
GPIOPinTypeTimer(GPIO_PORTA_BASE, GPIO_PIN_6);
TimerClockSourceSet(TIMER3_BASE, TIMER_CLOCK_PIOSC);
TimerPrescaleSet(TIMER3_BASE, TIMER_A, 4);
TimerPrescaleMatchSet(TIMER3_BASE, TIMER_A, 2);
TimerConfigure(TIMER3_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM);
uint32_t per= 327679;// 4FFFF
TimerLoadSet(TIMER3_BASE, TIMER_A, per);// Load Value
TimerMatchSet(TIMER3_BASE, TIMER_A, per / 2);// Match value
TimerEnable(TIMER3_BASE, TIMER_A);
while (1) {
}
}