i wos working on creating a spwm using pb6 and pb7 but suddenly now whatever i do "even if i'm running an empty code or trying to set the to 0" the pins are always high even if i paused in the debugging mode
i could't find any direct short between the 3.3v and the pins
that's the code i used
#include <stdbool.h> #include <stdint.h> #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/pin_map.h" #include "driverlib/pwm.h" #include "driverlib/sysctl.h" uint16_t sinus[]={1,2,5,7,10,12,15,17,19,22,24,27,30,32,34,37,39,42, 44,47,49,52,54,57,59,61,64,66,69,71,73,76,78,80,83,85,88,90,92,94,97,99, 101,103,106,108,110,113,115,117,119,121,124,126,128,130,132,134,136,138,140,142,144,146, 148,150,152,154,156,158,160,162,164,166,168,169,171,173,175,177,178,180,182,184,185,187,188,190,192,193, 195,196,198,199,201,202,204,205,207,208,209,211,212,213,215,216,217,219,220,221,222,223,224,225,226,227, 228,229,230,231,232,233,234,235,236,237,237,238,239,240,240,241,242,242,243,243,244,244,245,245,246,246, 247,247,247,248,248,248,248,249,249,249,249,249,255,255,255,255,249,249,249,249,249,248, 248,248,248,247,247,247,246,246,245,245,244,244,243,243,242,242,241,240,240,239,238,237,237,236,235,234, 233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,217,216,215,213,212,211,209,208,207,205,204, 202,201,199,198,196,195,193,192,190,188,187,185,184,182,180,178,177,175,173,171,169,168,166,164,162,160, 158,156,154,152,150,148,146,144,142,140,138,136,134,132,130,128,126,124,121,119,117,115,113,110,108,106, 103,101,99,97,94,92,90,88,85,83,80,78,76,73,71,69,66,64,61,59,57,54,52,49,47,44,42,39,37,34,32,30, 27,24,22,19,17,15,12,10,7,5,2,1}; int x=0,en=true; long map(long , long , long , long , long ); void PWM0IntHandler(void) { PWMGenIntClear(PWM0_BASE, PWM_GEN_0, PWM_INT_CNT_LOAD); if(++x>311){x=0; en=!en;} if(en==true){ PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 0); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, map(sinus[x],1,255,0,535)); } else { PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 0); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, map(sinus[x],1,255,0,535)); } } int main(void) { SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); SysCtlPWMClockSet(SYSCTL_PWMDIV_1); SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB6_M0PWM0); GPIOPinConfigure(GPIO_PB7_M0PWM1); GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6); GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7); PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); // equation: N = (1 / f) * SysClk. PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 535); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 64); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 66); PWMOutputInvert(PWM0_BASE, PWM_OUT_0_BIT|PWM_OUT_1_BIT, true); IntMasterEnable(); PWMIntEnable(PWM0_BASE, PWM_INT_GEN_0); PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_0, PWM_INT_CNT_LOAD); IntEnable(INT_PWM0_0); IntEnable(INT_PWM0_1); PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, true); PWMGenEnable(PWM0_BASE, PWM_GEN_0); while(1) { } } long map(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }
thanks