How to Use the Active Buzzer with Shakti Processor?

  • Post author:
  • Reading time:10 mins read
  • Post category:Tutorials
You are currently viewing How to Use the Active Buzzer  with Shakti Processor?

In this tutorial, the ACTIVE BUZZER is used with SHAKTI Processor. The active buzzer has a built-in oscillating source which creates the sound when power is supplied. It only requires an external DC voltage to create sound.

Active Buzzer


The protocol used here is the General Purpose Input/Output (GPIO)

Step 1: What You Will Need

For this you will need:-

  • Arty7 35t/100T board with either pinaka, parashu or vajra programmed on it.
  • shakti-sdk and shakti-tools installed or Platform IO installed and ready
  • Active Buzzer
  • Micro USB Cable.
  • Jumper Wires.

Note: shakti-sdk and shakti-tools are currently a private repository. Please login or sign up to Gitlab and request access here before using it.

Step 2: The Circuit

Connections of the ACTIVE BUZZER sensor:

  • S connects to the GND pin.
  • -ve connects to the GPIO0 pin.
The circuit diagram

Here we use Arty35t for instance, Also, the connections are the same in Arty100t boards. For better clarity, Check the device pin mapping for pinaka, parashu and vajra

Step 3: Code

Please click here and have a look at the code. When the code is executed successfully the active buzzer which has a built-in oscillating source would make sounds when electrified.

Code can be compiled and run using the following ways,

Step 4.1: Manual Method

4.1.1 Compile and build

  • Move to shakti-sdk
cd shakti-sdk
  • Compile using make software PROGRAM=? TARGET=?. Type make list_applns to list all the applications available in the SDK. Target can be either parashu, pinaka or vajra.

For instance, use target as parashu,

make software PROGRAM=active_buzzer TARGET=parashu

4.1.2 Execution:

Once the application is built, the executable is generated in the output folder. The executable is in ELF file format and they have the extension .shakti. Now, open three terminals, one for each of the following,

  • One terminal for UART terminal display (miniterm)
  • Another for GDB server.
  • And the last one for OpenOCD.

Terminal 1: Firstly, Connect to serial output by using miniterm or gtkterm with the baud rate of 19200.

For instance,

$ sudo /dev/ttyUSB1 19200


  • “/dev/ttyUSB1” – ttyUSB means “USB serial port adapter”
  • The “1” (“0” or “1” or “2”“here means the USB device number on your system. The FPGA board is connected to that USB device number.

Terminal 2: After that, Connect to the FPGA board by using the OpenOCD provided by shakti-tools and its respective configuration file.  (Read how OpenOCD and RISC-V GDB work together to establish a connection between our PC and the Microprocessor)

For instance, if we use parashu,

$ cd shakti-sdk
$ cd ./bsp/third_party/parashu
$ sudo $(which openocd) -f ftdi.cfg

For pinaka and vajra, Goto cd ./bsp/third_party/<pinaka or vajra>

Terminal 3:Now, open either 32bit or 64bit RISC-V GDB based on your architecture i.e riscv32-unknown-elf-gdb or riscv64-unknown-elf-gdb respectively from shakti-tools.

The output executable is created in <path-to-shakti-sdk>/software/examples/gpio_applns/active_buzzer/output as active_buzzer.shakti.

Load up the .shakti file by following the below steps. For Parashu,

$ riscv32-unknown-elf-gdb
(gdb) set remotetimeout unlimited
(gdb) target remote localhost:3333
(gdb) file path/to/executable
(gdb) load
(gdb) c

Step 4.1.3: Upload to flash

Steps to generate standalone user application:

The SHAKTI-SDK has a uploader tool that is used to load a content (such as ELF) to flash, after building the image.

  • Goto the right directory.
    cd shakti-sdk
  • The make upload command is used to build and upload the application to the flash automatically.
make upload PROGRAM = active_buzzer TARGET = parashu

PROGRAM is the new bare metal user application that is created. Target can be either parashu, pinaka or vajra. Type make list_applns to list all the applications available in the SDK.

Step 4.2: Using Platform IO

We can use IDE’s like Platform IO to compile, build, run, upload and debug. Please read the article on Platform IO on SHAKTI to understand the steps.

Miniterm Output

--- Miniterm on /dev/ttyUSB1: 19200,8,N,1 ---
--- Quit: Ctrl+]  |  Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---                  ((                                          
Booting… vspi1.0
Booting on Parashu! hart 0 
Parashu is a SoC build on top of Artix7 100T.
The core belongs to Shakti E class, 32 bit.
Supported ISA: RV32ACIMNU.
Processor Arch ID: 0.
Device ID 1 
extracted device id 2018 
. . . . . . .
Control transferred to RAM