Page 1 of 1

Functions to setup Buzzer attributes

Posted: Thu Jun 08, 2017 10:11 am
by dandavid3000
Hi,

I'd like to use a buzzer instead of a LED (I use the same gpio TIM2 for both LED, and buzzer) . I took a look at "td_tools_led.c" and "td_tools_led.h". There is a function named
Code: Select all
int TD_TOOLS_LED_SetPWM(uint8_t id,uint8_t period, uint8_t value);
, and I think it's a function to set up value (frequency), and period for the buzzer. However, when I tried this function I didn't success in managing the buzzer :( .

Is it the correct function ? If not, which functions of from the SDK can be use to manage the buzzer ?

Thank you,
Dan

Re: Functions to setup Buzzer attributes

Posted: Thu Jun 29, 2017 1:25 pm
by omlu
dandavid3000 wrote:Hi,

I'd like to use a buzzer instead of a LED (I use the same gpio TIM2 for both LED, and buzzer) . I took a look at "td_tools_led.c" and "td_tools_led.h". There is a function named
Code: Select all
int TD_TOOLS_LED_SetPWM(uint8_t id,uint8_t period, uint8_t value);
, and I think it's a function to set up value (frequency), and period for the buzzer. However, when I tried this function I didn't success in managing the buzzer :( .

Is it the correct function ? If not, which functions of from the SDK can be use to manage the buzzer ?

Thank you,
Dan


Hi,

I also used a buzzer in my circuit (TD1208). But I didn't use PWM to play different tones. I simply used GPIO's function like "ON" or "OFF"
Code: Select all
void buzzerInit(void) {
   GPIO_PinModeSet(ADC0_PORT, ADC0_BIT, gpioModePushPull, 1);
   GPIO_PinOutClear(ADC0_PORT, ADC0_BIT);
}

void buzzerBeep (void) {
   GPIO_PinOutSet(ADC0_PORT, ADC0_BIT);
   TD_RTC_Delay(T50MS);
   GPIO_PinOutClear(ADC0_PORT, ADC0_BIT);
}