I am having trouble getting an audio signal using PWM with PD0 on the LM3S9B92 eval board. I had it working based on the example pwmgen.c using the motion control module, but was unable to get it working using the Capture/Compare/PWM0 functionality of the pin. Using the example pwm.c in the stellarisware, I wrote the following code. I am trying to get a 2kHz pulse.
unsigned long ulPeriod; // PWM period
// The clock is set elsewhere in the code before this point
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ulPeriod = MAP_SysCtlClockGet() / 2000; // Compute the PWM period based on the system clock and
MAP_GPIOPinConfigure(GPIO_PD0_CCP6); // Set PWM pin. It is used to output the audio signal.
GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_0);
TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_B_PWM);
TimerLoadSet(TIMER1_BASE, TIMER_B, ulPeriod);
TimerMatchSet(TIMER1_BASE, TIMER_B, ulPeriod/2); // This will be set to have different duty cycles later on depending on what I want to do, does the Timer have to be disabled when this is called?
//I then call
TimerEnable(TIMER1_BASE, TIMER_B);
//or
TimerDisable(TIMER1_BASE, TIMER_B);
//every 10ms depending on whether the audio should be on/off
Please note that I am using Timer 1B for the audio, while I am using Timer 1A for a frequency input, and Timer 0A for a output. I'm not sure if these would conflict in any way. Any and all help is appreciated.
I also had the motion control PWM working on a LM4F232H5QD board, but in both cases I am having problems with the CCP method. The Pin I am trying to use on the LM4F board is PC6 which has no motion control module.
Thank you