Tool/software: Code Composer Studio
Hello, I need to generate five diferent signals of (10 20 30 40 45) KHz, I have configurate two PWM outputs to generate for me the 20 and 40 KHz signal, but at the output only the first signal have the right period, the second one have the same period of the first but with a duty cycle modification although I have configurate both with 50% of duty cycle. Here is the code:
#include <stdint.h> #include <stdbool.h> #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/fpu.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "driverlib/pwm.h" #include "driverlib/sysctl.h" #include "driverlib/timer.h" uint32_t g_ui32FlagsF; int main(void) { g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); SysCtlPWMClockSet(SYSCTL_PWMDIV_1); SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinConfigure(GPIO_PF0_M0PWM0); GPIOPinConfigure(GPIO_PF1_M0PWM1); GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_0); GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1); PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_SYNC); PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_SYNC); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 6000); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, 3000); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0,PWMGenPeriodGet(PWM0_BASE, PWM_GEN_0) / (2)); PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, true); PWMGenEnable(PWM0_BASE, PWM_GEN_0); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1,PWMGenPeriodGet(PWM0_BASE, PWM_GEN_1) / (2)); PWMOutputState(PWM0_BASE, PWM_OUT_1_BIT, true); PWMGenEnable(PWM0_BASE, PWM_GEN_1); while(1) { } }
I want to know if it is going to be possible to generate the 5 signals each with their respective period using PWM.