You are currently viewing How to Interface Buzzer with DSPIC Evaluation Board

How to Interface Buzzer with DSPIC Evaluation Board

Spread the love

The DsPIC30F4011 Evaluation Board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through USB port.

Microchip’s dsPIC30F (dsPIC30F4011), Evaluation Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 16-bit Microcontrollers.


Buzzer is an electrical device, which is similar to a bell that makes a buzzing noise and is used for signaling. Typical uses of buzzers and beepers include alarm devices, timers and confirmation of user input such as a mouse click or keystroke.

Interfacing Buzzer

Fig. 1 shows how to interface the Buzzer to microcontroller. A piezoelectric element may be driven by an oscillating electronic circuit or other audio signal source, driven with a piezoelectric audio amplifier. Sounds commonly used to indicate that a button has been pressed are a click, a ring or a beep. When the input port pin from microcontroller is changed, the sound wave is changed in Buzzer.

Interfacing Buzzer to dspic
Interfacing Buzzer to Microcontroller

Interfacing Buzzer with dsPIC30F4011

A small piezoelectric buzzer on the dsPIC30F Evaluation Kit, by pulling pin PORTB.0 low, current will flow through the buzzer and a relatively sharp, single-tone frequency will be heard.

The alternative ADC feature of pin PORTB.0 can be used to modulate the buzzer to oscillate around different voltages. Then the volume of the sound will be changed by alternating the voltage. The buzzer can be disconnected by FRC cable, and this is also the default connection since the buzzer sound can be quite annoying if always left on.

Pin Assignment for Interface Buzzer with dsPIC30F4011

dsPIC30F Output Connections
PORTB.0 Choose Any one from 1 to 6. The Corresponding Action Will Be carried out. * Connect PORTB.0 with CONN (BUZZER) via FRC bus or using wire * Turn ON TXD1 and RXD1 Pins of CONFIG_SWITCH SW1 * Connect Serial cable between USART1 Section in the Board and PC , open HyperTerminal @ 9600 * Press RESET Once.

Circuit Diagram for Interface Buzzer with dsPIC30F

circuit diagram for Interface Buzzer with DSPIC Evaluation Board

Source Code

The Interfacing Buzzer with dsPIC30F4011 program is very simple and straight forward. We now want to generate a sound in DsPIC30F4011 Evaluation Board by using a buzzer. The C programs are developed in Mplab software.

C Program to generate sound in dsPIC30F using Buzzer

#include "p30f4011.h"
#include "delay.c"
#define XTFREQ 10000000
#define FOSC XTFREQ/4
#define BAUDRATE 9600
#define BRGVAL ((FOSC/BAUDRATE)/16)-1 void Serial_init(void);
unsigned char Receive(void);
void main()
unsigned int RecDat;
TRISB = 0x0000;
ADPCFG= 0xffff;
LATB = 0xffff;
printf("Press A to Turn ON\n\rPress B to Turn OFF\n\r");
RecDat = Receive();
case 'A':LATB=0x00;
case 'B':LATB=0x01;
printf("%c ",RecDat);
void Serial_init(void)
U1MODE= 0x8000;
U1STA = 0x8400;
IFS0bits.U1TXIF = 1;
void putch(unsigned char SendDat)
U1TXREG = SendDat;
unsigned char Receive(void)
return U1RXREG;

To compile the above C code you need the Mplab software & Microchip C30 Compiler. They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In Mplab, you want to develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without DsPIC30F4011 Evaluation Board.

The PICKIT2 software is used to download the hex file into your microcontroller IC dsPIC30F through USB.

Testing the Buzzer with dsPIC30F4011

Give +9V power supply to DsPIC30F4011 Evaluation Board; the Buzzer is connected with DsPIC30F4011 Evaluation Board. When the program is downloading into dsPIC30F4011 in Evaluation Board, the Buzzer output is working that the Buzzer is creating some sound.

If you are not getting any sound from Buzzer, then you just check the jumper connections & check the Buzzer is working or not. Otherwise you just check it with debugging mode in Mplab. If you want to see more details about debugging just see the videos in below link.

  • How to create & Debug a Project in Mplab using dsPIC30F.

General Information

  • For proper working use the components of exact values as shown in Circuit file. Use new components.
  • Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.
  • Use the exact value crystal shown in schematic.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.