Need Help !! P18f4520 Buzzer program

Status
Not open for further replies.

Tragedy

Newbie level 1
Joined
Jun 14, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
1. Generating a tone of certain frequency (using C program statements)
2. Generating a tone of certain frequency continuously for a certain duration (using C program statements)
3.Generating different frequency tones(using C program statements)

#include <p18f4520.h>
#include <delays.h>

void main ()
{
char i = 0; //declarations
ADCON1 = 0x0f;
TRISE = 11100000;
PORTE = 0;

for (i=0;i<500;i++)
{
PORTEbits.RE2 =~ PORTEbits.RE2 // toggled wave
Delay10TCYx(10); //?????
PORTEbits.RE2 = 0;
Delay10TCYx(1);
}
for (i=0;i<250;i++)
{
PORTEbits.RE2 = 1;
Delay10TCYx(1);
PORTEbits.RE2 = 0;
Delay10TCYx(4);
}
}

this is a program made and i am suppose to explain number 1,2,3 . how do we generate a tone of certain frequency and with duration ? i have no idea how to explain my program and every step written. can someone please enlighten me ? your help is greatly appreciated . it would help me understand and score in my schoolwork
 

1. produce a pwm wave of a certain frequency to the Port
2. use a loop and produce the frequency
3. use a loop and produce the frequency. the different tone is done by delay. the delay will produce the different frequency.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…