Sound Library - mikroElektronika PIC Microcontrollers PIC12 User Manual

Mikroc user's manual
Table of Contents

Advertisement

mikroC - C Compiler for Microchip PIC microcontrollers

Sound Library

mikroC provides a Sound Library which allows you to use sound signalization in
your applications. You need a simple piezo speaker (or other hardware) on desig-
nated port.
Library Routines
Sound_Init
Sound_Play
Sound_Init
Prototype
void Sound_Init(char *port, char pin);
Description
Prepares hardware for output at specified port and pin. Parameter pin needs to be within
range 0–7.
Example
Sound_Init(PORTB, 2);
Sound_Play
Prototype
void Sound_Play(char period_div_10, unsigned num_of_periods);
Description
Plays the sound at the specified port and pin (see Sound_Init). Parameter period_div_10
is a sound period given in MCU cycles divided by ten, and generated sound lasts for a
specified number of periods (num_of_periods).
Requires
To hear the sound, you need a piezo speaker (or other hardware) on designated port.
Also, you must call
Example
To play sound of 1KHz: T = 1/f = 1ms = 1000 cycles @ 4MHz. This gives us our first
parameter: 1000/10 = 100. Play 150 periods like this:
Sound_Play(100, 150);
page
264
// Initialize sound on RB2
to prepare hardware for output.
Sound_Init
MikroElektronika: Development tools - Books - Compilers
mikroC
making it simple...

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents