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.

CC3200-LAUNCHXL: SW3 is not responding when we press it.

Part Number: CC3200-LAUNCHXL

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.

  • Hi Omar,

    Did you ensure to ungate the clock to the GPIO_A1 peripheral before calling those three GPIO functions to set the buzzer PWM pin to GPIO? You should have a MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK); call at some point to enable the GPIO A1 peripheral.

    Regards,

    Michael

  • Hi Michael,

    Yes of course I am calling MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK) in PinMuxConfig() before executing the tasks, and the button SW3 is working just fine (until I call the Buzzer disable module and execute those three GPIO functions).

    Here are the functions I used to control the buzzer:

    void vBuzzer_InitModule(void)
    {
        /*PWM Output signal for PIN_64, using a Timer*/
        MAP_PinTypeTimer(ucPin_BUZZER, PIN_MODE_3);
    
        // Initialization of timers to generate PWM output
        MAP_PRCMPeripheralClkEnable(BUZZER_TIMER_PRCM, PRCM_RUN_MODE_CLK);
    
        // Set GPT - Configured Timer in PWM mode.
        MAP_TimerConfigure(BUZZER_TIMER_BASE, BUZZER_TIMER_COUNTING_MODE);
        MAP_TimerPrescaleSet(BUZZER_TIMER_BASE, BUZZER_TIMER,0);
    
        // Inverting the timer output if required
        MAP_TimerControlLevel(BUZZER_TIMER_BASE, BUZZER_TIMER, 0);
    }
    
    void vBuzzer_SetFrequency(uint32_t u32Frequency)
    {
    	MAP_TimerDisable(BUZZER_TIMER_BASE, BUZZER_TIMER);/*In case we apdate the frequency*/
    
    	MAP_TimerLoadSet (BUZZER_TIMER_BASE, BUZZER_TIMER, TIMER_INTERVAL_RELOAD(u32Frequency));
    	MAP_TimerMatchSet(BUZZER_TIMER_BASE, BUZZER_TIMER, TIMER_INTERVAL_RELOAD(u32Frequency/2));
    
    	MAP_TimerEnable(BUZZER_TIMER_BASE, BUZZER_TIMER);
    }
    
    void vBuzzer_DisabletModule(void)
    {
        // Disable the peripherals
        MAP_TimerDisable(BUZZER_TIMER_BASE, BUZZER_TIMER);
    
        MAP_PRCMPeripheralClkDisable(BUZZER_TIMER_PRCM, PRCM_RUN_MODE_CLK);
    
        /*Re-config 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);
    }
    
    
    void vBuzzer_PlayToneHBTMOK(void)
    {
    	vBuzzer_InitModule();
    
    	vBuzzer_SetFrequency(BUZZER_FREQUENCY1_HZ);
    	vTaskDelay(100);
    
    	vBuzzer_SetFrequency(BUZZER_FREQUENCY2_HZ);
    	vTaskDelay(200);
    
    	vBuzzer_DisabletModule();
    }

    I also added  MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK); after disabling the module but same result.

    Best Regards.
    Omar.

     

  • Hi Omar,

    As long as you're calling MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK); at some point then you should be good.

    At this point, it looks like I will need to work on replicating your setup to see this bug in action for myself and then note down what fixes might need to be made. For the replication effort, are the these the steps that you have?

    1. Enable SW3 as input with callback
    2. Enable pin 64 as PWM
    3. Disable pin 64 as PWM
    4. Reconfigure pin 64 as GPIO input

    Please let me know if there are other reproduction steps needed.

    Regards,

    Michael

  • Hi Michael,

    Yes, indeed, just to be sure, for the 4th step is Reconfigure pin 64 as GPIO output and not as GPIO input.

    Best Regards,
    Omar.

  • Hi Omar,

    Thanks for the catch and pointing out that the pin should be reconfigured into a GPIO output. I will work on reproducing this, and will give you an update when I do so, hopefully over the next few days.

    Regards,

    Michael

  • Hi Michael,

    is there any news, it has been two weeks since the last discussion ??

    Best Regards,
    Omar.