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.

Launchpad LED's Blink(at 1Hz) with PWM mode

Hi,

Here is the my setup,

Hardware: EK-TM4C123GL

Objective: Want to Blink one of the LEDs(PF2) on the board with PWM capture compare mode(32Bit instead of 16 Bit). so that we can Load the high value in order to achieve 1 HZ.

Reference: Driver Library, Forum.

Code snippet:

       ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
        GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);

        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0 );

        GPIOPinConfigure(GPIO_PF2_T1CCP0);
        GPIOPinTypeTimer(GPIO_PORTF_BASE, GPIO_PIN_2);

        SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
        TimerConfigure(TIMER1_BASE, TIMER_CFG_A_PERIODIC|TIMER_CFG_A_PWM);
        TimerLoadSet(TIMER1_BASE, TIMER_A, ROM_SysCtlClockGet());
  
        TimerMatchSet(TIMER1_BASE, TIMER_A, ROM_SysCtlClockGet()/2);
        TimerEnable(TIMER1_BASE, TIMER_A);

Problem:

        I'm not seeing Blue color LED blink which is connected with PF2. Have probed this pin and not seeing pulse it just went high. If I configure the timer with TIMER_CFG_SPLIT_PAIR instead of TIMER_CFG_A_PERIODIC and different load value can see the frequency.

I assume CCP can support 32 bit mode and achieve 1 HZ time interval.

Am I wrong?

Really appreciate your help.

-Durai

  • Thanks! I got figured it out. Need to use the Prescale. Below is the working code @ 500ms ON/OFF

           SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
           SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

           GPIOPinConfigure(GPIO_PF2_T1CCP0);
           GPIOPinConfigure(GPIO_PF3_T1CCP1);

           GPIOPinTypeTimer(GPIO_PORTF_BASE,GPIO_PIN_2 | GPIO_PIN_3);

           TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM | TIMER_CFG_B_PWM);

           TimerLoadSet(TIMER1_BASE,TIMER_A, SysCtlClockGet());
           TimerPrescaleSet(TIMER1_BASE,TIMER_A,122);
           TimerMatchSet(TIMER1_BASE,TIMER_A, SysCtlClockGet()/2);
        

           TimerLoadSet(TIMER1_BASE,TIMER_B, SysCtlClockGet());
           TimerPrescaleSet(TIMER1_BASE,TIMER_B,122);
           TimerMatchSet(TIMER1_BASE,TIMER_B, SysCtlClockGet()/2);
         

        
         TimerEnable(TIMER1_BASE, TIMER_A | TIMER_B);

    -Durai