Datasheet
Sound_Init
Sound_Play
422
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
Prototype
void Sound_Init();
Returns Nothing.
Description Configures the appropriate MCU pin for sound generation.
Requires
Global variables:
-
Sound_Play_Pin: Sound output pin
- Sound_Play_Pin_Direction: Direction of the Sound output pin
must be defined before using this function.
Example
// Sound library connections
sbit Sound_Play_Pin at PORTC.B3;
sbit Sound_Play_Pin_direction at DDRC.B3;
// End of Sound library connections
...
Sound_Init();
Prototype
void Sound_Play(unsigned freq_in_hz, unsigned duration_ms);
Returns Nothing.
Description
Generates the square wave signal on the appropriate pin.
Parameters :
-
freq_in_hz: signal frequency in Hertz (Hz)
- duration_ms: signal duration in miliseconds (ms)
Requires
In order to hear the sound, you need a piezo speaker (or other hardware) on
designated port. Also, you must call Sound_Init to prepare hardware for output
before using this function.
Example
// Play sound of 1KHz in duration of 100ms
Sound_Play(1000, 100);