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.
Hello,
I'm trying to control the dead band width of pwm in the code below, but the delay between the two LEDs lighting up doesn't seem to change no matter what I write in the function: PWMDeadBandEnable(PWM1_BASE, PWM_GEN_3, 10000, 10000); instead of 10000. Even if I write 0, or 65536.
Thank you for your time in advance.
#include <stdint.h>
#include <stdbool.h>
#include <math.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include <inc/hw_ints.h>
#include "driverlib/timer.h"
#include "driverlib/pwm.h"
#include "driverlib/pin_map.h"
#include "driverlib/adc.h"
#include "driverlib/debug.h"
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_64|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); //3,125 MHz
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
SysCtlPWMClockSet (SYSCTL_PWMDIV_64);
GPIOPinTypePWM (GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3);
GPIOPinConfigure (GPIO_PF2_M1PWM6);
GPIOPinConfigure (GPIO_PF3_M1PWM7);
PWMGenConfigure (PWM1_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
PWMDeadBandEnable(PWM1_BASE, PWM_GEN_3, 10000, 10000);
PWMGenPeriodSet (PWM1_BASE, PWM_GEN_3 , 65535) ;
PWMPulseWidthSet (PWM1_BASE, PWM_OUT_6 ,32267) ;
PWMGenEnable (PWM1_BASE, PWM_GEN_3);
PWMOutputState (PWM1_BASE, PWM_OUT_6_BIT | PWM_OUT_7_BIT , true);
}
Hello Zahid,
I see what you are trying to achieve here, but unfortunately the dead-band generator won't quite work for what you are looking to do.
You comments indicate you are trying to place a 16 bit value into the registers to try and get a notable change in the LED blinks.
However, the dead-band generator is only 12 bits wide, so you are actually getting changes in the dead band signal, but the blink rate difference is very hard to discern.
This is the PWM output with 1 loaded for each dead band:
And this is the PWM output with 0xFFF loaded for each dead band:
I can notice at least that the blinks for the latter are a little faster than the former, but its a subtle difference.
So its working properly, but it isn't making enough of an impact for you to be able to clearly visually notice it.
Best Regards,
Ralph Jacobi
I thought there might be that kind of a limit to that register but I couldn't find it in the datasheet. Thank you very very much Mr. Ralph.