Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Moved] Buzzer Program for LPC 2148

Status
Not open for further replies.

Gopikrissh

Newbie level 5
Joined
Jan 25, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,340
Can anyone tell me how to ring a buzzer in lpc2148 using embedded c program???
 

Re: Buzzer Program for LPC 2148

Can anyone tell me how to ring a buzzer in lpc2148 using embedded c program???

That depends on the type of "buzzer" and how it is properly interfaced with the ARM.

Can you post your schematic and code of the design?

BigDog
 

Re: Buzzer Program for LPC 2148

you can use 2 methods.

1. you can continuously monitor the port pin which is connected with the switch. Untill the switch is pressed, you can enable the buzzer
2. you can use the external interrupt and in the service routine, you can enable the buzzer for some time and disable

Thanks
 

Re: Buzzer Program for LPC 2148


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||;
;||                                                                                          ||;
;|| Title       : Buzzer.c                                                                   ||;
;|| Status      : Completed!                                                                 ||;
;|| Features    : ON/Off  buzzer with time  delay intervals                                  ||;
;|| Description : Buzzer Port    :  P0.7                                                     ||;
;||               Oscillator     :  12MHz                                                    ||;
;||               Enable Buzzer, Put Jumper JP1 to 'E' Mode.                                 ||;
;||                                                                                          ||;
;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||;
/***********************************************************************************************/
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<      DIRECTIVES       >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
#include <LPC214x.h>
#include <stdio.h>
 
#define BUZZ 7
 
void Delay(void);
void Wait(void);
 
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   Code Begins Here    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
void Delay()
{
    unsigned int i,j;
    for(i=0;i<1000;i++)
        for(j=0;j<700;j++);
}
 
 
void main()
{
    PINSEL0 =   0x00;                   //Configure Port0.7 as GPIO
    IODIR0  =   3 << BUZZ;              //Configure Port0.7 as OutPut pin
    while(1)
    {
        IOSET0 = 1 << BUZZ;
        Delay();
        IOCLR0 = 1 << BUZZ;
        Delay();
        
    }
}

 
Last edited by a moderator:

Re: Buzzer Program for LPC 2148

i'm using switch and led.. when i press the switch i want the led to glow... for this i cant use port 0 but in port1 it is working fine.... why port0 is not working.. please reply with suitable solution.... i have connected the led in p0.0 and switch i p0.7..
Code:
#include <lpc213x.h>

int main(void)
{
		PINSEL0 = 0X00000000;
		IO0DIR |= (1<<0);

		while(1)
		{
			if (IO0PIN & 0X00000080)
			{
				IO0SET |= 0X00000001;
			}
			else IO0CLR |= 0X00000001;
		}
}
 

Mr. Gopi,
You have not answered imporant questions asked by BigDog. You simply used the term buzzer. buzzer or beeper is an audio signalling device, which may be mechanical, electromechanical, or piezoelectric. Again a piezoelectric buzzer can be driven by an oscillating electronic circuit which may come with the buzzer inside the housing or may not. Also depending on the connection with the micro the sound level may vary.
Sounding a buzzer by making a micro pin go high ---its not "always" as simple as that.

Also, Pin 0.7 is a GPIO pin. The GPIO pins on the LPC2148 -- in fact the entire LPC2000 family -- can only safely supply or sink (pull to GND) a maximum of 4mA each. Check datasheet for total source or sink current.

see **broken link removed**
 
Last edited:

Re: led Program for LPC 2148

#include <LPC214x.h>
#include <stdio.h>
#define LED 0
#define Switch 7

void Delay(int);


int main(void)
{
unsigned char Status=1;

PINSEL0 &= 0x00000000; //Configure P0.0 - P0.31 as GPIO


IO0DIR = 0x00 << Switch; //Configure 0.0 Input
IO0DIR |= 0x01 << LED; //Configure as Output

IO0PIN = 0;

while(1)
{
Status = 1;
IOSET0 = 0x01 << LED;
Delay (10);Delay (10);
IOCLR0 = 0x01 << LED;
Delay (10);Delay (10);Delay (10);

while (~Status)
{
Status = ((IO0PIN & (0x01 << Switch)) >> Switch);
IO0PIN = ((~Status) << LED);
}

}
}

void Delay(int n)
{
int p,q;

for(p=0;p<n;p++)
{
for(q=0;q<0x9990;q++);
}
}
this program will work for led to port 0.0 and switch to port 0.7
 

Send me the .dsn file and LPC2148 Proteus Library files.
 

please tell me this program correct or not
Code:
#include <lpc213x.h>


int main(void)
{
	PINSEL0 &= 0X00000000;
	IO0DIR = 0X00000000;						//SWITCH P0.7
	IO0DIR |= 0X01;						//LED P0.0
	
	while(1)
	{
		if ((IO0PIN & 0x80) == 0)
		{
			IO0CLR |= (1<<0);
		}
		else IO0SET |= (1<<0);
		
	}
}
[ATTACH=CONFIG]76537._xfImport[/ATTACH]
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top