Hallo,
Hi have EKS-LM4F232 eval board and I want to output a PWM signal from pin PF0 using Timer0 (T0CCP0).
Following some examples I wrote this:
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "driverlib/rom.h"
#include "driverlib/pin_map.h"
#include "driverlib/gpio.h"
#include "inc/lm4f232h5qd.h"
int main(void)
{
// Set the clocking to run directly from the crystal.
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
// Enable the peripherals used by this example.
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
// Configure GPIO pin as PWM output
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOF);
ROM_GPIOPinConfigure(GPIO_PF0_T0CCP0);
// ROM_GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_DIR_MODE_HW);
ROM_GPIOPinTypeTimer(GPIO_PORTF_BASE, GPIO_PIN_0);
// Configure the timer.
unsigned long uPeriod;
uPeriod = ROM_SysCtlClockGet( ) / 50000;
ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PWM);
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, uPeriod);
ROM_TimerMatchSet(TIMER0_BASE, TIMER_A, uPeriod>>1);
// Enable the timers.
ROM_TimerEnable(TIMER0_BASE, TIMER_A);
// Loop forever and blink the led while the timers run.
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);
while(1)
{
ROM_GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, GPIO_PIN_2);
ROM_SysCtlDelay(300000);
ROM_GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, 0);
ROM_SysCtlDelay(300000);
}
}
Unfortunately pin PF0 doesn’t move. The led on pin PG2 blink, so this firmware is running.
Where am I wrong? How to output the PWM signal on PF0?
Best regards
Max