Hi guys,
I am using the Pin 64 as PWM output (PWM_OUT5) for the buzzer to create some tones for a short period (few milliseconds) and disable it after that, but sometimes I am not getting the wanted last state of PWM signal which is a low state and often it’s a High state and that causes a continuous annoying tone from the buzzer. So in order to resolve this problem I added this three lines to reconfigure the Pin 64 as a normal GPIO output and make it as low state, like that I am sure that the buzzer is not getting a high state when disabling the PWM signal.
#define ucPin_BUZZER (PIN_64) #define gpioPin_BUZZER (GPIO_PIN_1) #define gpioPort_BUZZER (GPIOA1_BASE) #define BUZZER_TIMER_BASE (TIMERA2_BASE) #define BUZZER_TIMER (TIMER_B) #define BUZZER_TIMER_PRCM (PRCM_TIMERA2) #define BUZZER_TIMER_COUNTING_MODE (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_PWM) void vBuzzer_DisabletModule(void) { // Disable the peripherals MAP_TimerDisable(BUZZER_TIMER_BASE, BUZZER_TIMER); MAP_PRCMPeripheralClkDisable(BUZZER_TIMER_PRCM, PRCM_RUN_MODE_CLK); /*Reconfigure Buzzzer pin as normal low output to avoid PWM wrong last state*/ MAP_PinTypeGPIO(ucPin_BUZZER, PIN_MODE_0, false); MAP_GPIODirModeSet(gpioPort_BUZZER, ucPin_BUZZER, GPIO_DIR_MODE_OUT); MAP_GPIOPinWrite(gpioPort_BUZZER, ucPin_BUZZER, ~ucPin_BUZZER); }
And now when the main problem occurs, the button SW3 is already configured as input and I am using it as interruption to turn On/Off (Hibernate) the LaunchPad, but after adding those three lines, I am not receiving any interruptions from SW3 any more, it’s like the board is not detecting the state changing when I press on SW3. And to be sure, I deleted those 3 configuration lines and everything went back to work very well again as expected.
Something to add, I used Pin 21 as PWM output and Pin 18 as button for input interruption, exactly same behavior, pin 18 is not responding any more when we press it.
Also I used Multimeter to measure the tension between two points, ground and pin 04, before adding the 3 lines for the reconfiguration of pin 64 and everything was fine, it shows 2.9V when SW3 is pressed but after adding those lines it shows 0.5V, maybe there is relation between those values and the behavior of SW3.
So the question is why the SW3 is not responding when I press it after I reconfigure the pin 64 as normal output pin?
Best Regards.
Omar.