This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM: WideTimer0 PWM: No need for prescale ?

Part Number: TM4C123GH6PM

Hi, 

  I'm using EK-TM4C123 Launchpad and CCS 7 and doing some experiment on PWM with long period with short duty cycle.

  I'm using WTIMER0 as 2 half counter in PWM mode.   According to the datasheet of the MCU Tiva TM4CGH6PM (July 13, 2013 version), on page 713, we  have 24 bit each half counter. (TIMER_A, TIMER_B) . 

That means for count beyond that, we need to use the prescale register.   

   I'm using 80Mhz system clock, and setup the period to 16 sec.   For that, the initial count to load is  0x4C4B3FFF.

   If I understand the dataheet correctly, I would need to load   0x4B3FFF to TIMER_TAILR/TIMER_TBILR  and load 0x4C to the prescaler register TIMPER_TxPR and also need to load the match, and prematch registers accordingly. 

   However, I did not have to do that in my code when I was doing the experiment.

   Here is my code:

        

#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/debug.h"
#include "driverlib/pwm.h"
#include "driverlib/pin_map.h"
#include "inc/hw_gpio.h"
#include "driverlib/rom.h"
#include "driverlib/interrupt.h"
#include "driverlib/timer.h"
#include "inc/hw_timer.h"

uint32_t g_ui32Period;

void main(void) {
SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlDelay(3);
GPIOPinConfigure(GPIO_PC5_WT0CCP1);
GPIOPinTypeTimer(GPIO_PORTC_BASE, GPIO_PIN_5);
GPIOPinConfigure(GPIO_PC4_WT0CCP0);
GPIOPinTypeTimer(GPIO_PORTC_BASE, GPIO_PIN_4);

SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0);
SysCtlDelay(3);

TimerConfigure(WTIMER0_BASE,TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM|TIMER_CFG_B_PWM);


g_ui32Period =16*(SysCtlClockGet()); // 8*(SysCtlClockGet() / 1) /1 ;//

TimerLoadSet(WTIMER0_BASE, TIMER_A, g_ui32Period-1);
TimerMatchSet(WTIMER0_BASE, TIMER_A, g_ui32Period*0.5-40);


TimerLoadSet(WTIMER0_BASE, TIMER_B, g_ui32Period-1);
TimerMatchSet(WTIMER0_BASE, TIMER_B, g_ui32Period*0.5+40);
TimerControlLevel(WTIMER0_BASE,TIMER_B,true);


HWREG(WTIMER0_BASE+TIMER_TBMR_TBMRSU) =1;//only updates after the next timeout
HWREG(WTIMER0_BASE+TIMER_TAMR_TAMRSU) =1;//only updates after the next timeout

TimerEnable(WTIMER0_BASE, TIMER_BOTH);

while(1){


}


}

 

      Please have a look at what I code and the register view below and advice me on this.

     Thanks in advance.