Hello. I'm playing with the PWM mode at the TIVA Launchpad, to light a LED with a PWM pulse. I'm using this program:
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/pin_map.h" // Include para poder configurar el pin como salida PWM
#define PWMCYCLE 60000
#define DUTYCYCLE99 PWMCYCLE*0.99
#define DUTYCYCLE75 PWMCYCLE*0.75
#define DUTYCYCLE25 PWMCYCLE*0.25
int main(void) {
uint32_t ui32Period, ui32DutyCycle;
// System clock to 40MHz (PLL-200MHz/5=40MHz)
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
//SysCtlClockSet(SYSCTL_USE_OSC | SYSCTL_OSC_INT30); // DON'T USE LFIOSC!! --> TIVA DEBUG problems (use LMFLASHPROGRAMMER to unlock)
// PWM Square wave definition
ui32Period = PWMCYCLE ; // PWM period
ui32DutyCycle = DUTYCYCLE99;// PWM Duty cycle
// Port configuration (LEDS)
// Enable GPIOF port
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
// LED connected pins as outputs
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
// Switch off LEDs
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0);
// PF1 pin as PWM output at Timer0B (T0CCP1)
GPIOPinConfigure(GPIO_PF1_T0CCP1);
GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1);
// Timer configuration
// Enable Timer0
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
// Split Timers A and B, to allow TimerB to work as PWM
TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_B_PWM);
// Load timer period
TimerLoadSet(TIMER0_BASE, TIMER_B, ui32Period);
// Load duty cycle
TimerMatchSet(TIMER0_BASE, TIMER_B, ui32DutyCycle);
// Enable Timer
TimerEnable(TIMER0_BASE, TIMER_B);
while(1) {
SysCtlDeepSleep();
}
}
When I switch from SleepMode to DeepSleepMode, LED can be seen blinking. That should be OK, because in DeepSleepMode clock is changed to LFIOSC at 30KHz...
But I also tried a System Clock configuration at 30KHz from the beginning ( SysCtlClockSet(SYSCTL_USE_OSC | SYSCTL_OSC_INT30); --> BEWARE: this configuration will lock your TIVA, so you need LMFLASHProgrammer to unlock it), and the blinking rate is clearly slower than when configuring a 40MHz System clock. I supposed that 40MHz clock becomes inactive in DeepSleep Mode, so using this mode blinking rate should be the same for a System Clock at 40MHz, and a System Clock at 30KHz (considering that, in the first case, system clock switchs to 30KHz when entering DeepSleepMode)
Am I missing something?
Thanks in advance