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.

LPC2148 led flashing problem.....

Status
Not open for further replies.

rishi.iitk

Newbie level 3
Joined
Jul 3, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,316
hello friends i wrote the program in KEIL it compiles succesfulyy bt it doesnt works..I connected my led at port 0.22

program is here



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
45
46
47
48
49
50
51
// initialize system clock
 
#include "LPC214x.h"
void init() 
{
PLL0CFG=0x24;     // MSEL = 4,PSEL = 2
PLL0FEED=0xAA;     // Feed process    
PLL0FEED=0x55; 
 
PLL0CON=0x1;
PLL0FEED=0xAA;    // Feed process
PLL0FEED=0x55;
 
while(!(PLL0STAT & 0x400)) ; // Wait until PLL Locked
 
PLL0CON=0x3;     // Connect the PLL as the clock source
PLL0FEED=0xAA;     // Feed process
PLL0FEED=0x55;
 
MAMCR=0x2;     // Enabling MAM and setting number of clocks used for Flash memory fetch (4 cclks in this case)
MAMTIM=0x4;
 
VPBDIV=0x02;     // PCLK at 30 MHz
 
}
 
 
 
#include "LPC214x.h"    //header file for LPC2148
init();
int main(void){     // starting main loop
 
 
int j;      //variable declaration
    
 
 
IODIR0= 0x00400000; //setting port 0.22 as output
 
 
while(1){   //endless while loop
for (j=0;j<1000000;j++)
{   //delay loop
}
IOSET0= 0x00400000; //TURN ON LED AT PO.22
for (j=0;j<1000000;j++)
{   //delay loop
}
IOCLR0= 0x00400000; //Turn off led at P0.22
}
}




gyus i dont know whats the mistake here...so plz help me...it frustrates me too much...TIA
 
Last edited by a moderator:

your integer j needs to be volatile, otherwise, it wil optimized by the compiler as anything that do nothing.

if the rest of your code is correct, measure with a scope on your led pin, you wil see it flashes on very high frequency

if the led don't turns on, there is else something wrong as well. Maybe it freezes by the wile loop in your PLL setup. Maybe it's better to comment it out. You don't need that for a simple led-test.
 
Last edited:

ok thanx guys i got my programm working as there were some settings in keil that i forget to do before running the build program...anyways thanks for your suggestion...
 

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;
		}
}
 

Zip and upload the proteus .dsn file.
 

some one please explain this. port1 is working fine.. but in port0 it is not working........
Code:
#include <lpc213x.h>


int main(void)
{
	PINSEL0 = 0X00000000;
	PINSEL2 = 0X00000000;
	IO0DIR = 0X00000000;						//SWITCH P0.7
	IO0DIR |= 0X00000001;						//LED P0.0
	IO1DIR = 0X00000000;						//SWITCH P1.23
	IO1DIR |= 0X00010000;						//LED P1.16
	
	while(1)
	{
		if (IO0PIN & 0x00000080)
		{
			IO0SET |= (1<<0);
		}
		else IO0CLR |= (1<<0);
		if (IO1PIN & 0x00800000)
		{
			IO1SET |= (1<<16);
		}
		else IO1CLR |= (1<<16);
	}
}
Proteus design file: View attachment Design.rar
 

hello friends i wrote the program in KEIL it compiles succesfulyy bt it doesnt works..I connected my led at port 0.22

program is here



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
45
46
47
48
49
50
51
// initialize system clock
 
#include "LPC214x.h"
void init() 
{
PLL0CFG=0x24;     // MSEL = 4,PSEL = 2
PLL0FEED=0xAA;     // Feed process    
PLL0FEED=0x55; 
 
PLL0CON=0x1;
PLL0FEED=0xAA;    // Feed process
PLL0FEED=0x55;
 
while(!(PLL0STAT & 0x400)) ; // Wait until PLL Locked
 
PLL0CON=0x3;     // Connect the PLL as the clock source
PLL0FEED=0xAA;     // Feed process
PLL0FEED=0x55;
 
MAMCR=0x2;     // Enabling MAM and setting number of clocks used for Flash memory fetch (4 cclks in this case)
MAMTIM=0x4;
 
VPBDIV=0x02;     // PCLK at 30 MHz
 
}
 
 
 
#include "LPC214x.h"    //header file for LPC2148
init();
int main(void){     // starting main loop
 
 
int j;      //variable declaration
    
 
 
IODIR0= 0x00400000; //setting port 0.22 as output
 
 
while(1){   //endless while loop
for (j=0;j<1000000;j++)
{   //delay loop
}
IOSET0= 0x00400000; //TURN ON LED AT PO.22
for (j=0;j<1000000;j++)
{   //delay loop
}
IOCLR0= 0x00400000; //Turn off led at P0.22
}
}




gyus i dont know whats the mistake here...so plz help me...it frustrates me too much...TIA

What is the size of int in your compiler?

For 2byte integer variable, you can store a number in the range +32767 to -32768.
If in your compiler int is 2 Byte, then


Code C - [expand]
1
2
3
for (j=0;j<1000000;j++)
{   //delay loop
}


The above loop will produce an infinite loop.
j's value will swing between these values:-
0,1,2,-------32766,32767, -32768,-32767, -32766,-------- -2,-1,0
 

Code:
IO0SET |= 0X00000001;
IO0CLR |= 0X00000001;

IOSET and IOCLR set or clear any bit that has 1 and leave the others intact, there is no need for |=

Code:
IO0SET = 0X00000001;
IO0CLR = 0X00000001;
 

hello everyone ....
I am new to ARM... I am using a MINI ARM 7 LPC 2148 development board bought from NSK electronics.(Bangalore)
LED blink program is not working, i am using keil 4 and PHILIPS FLASH UTILITY as my compiler and programmer respectively..
I wrote a program of my own and also used the same program which you have uploaded but didn't work..
Can anyone help me with this??????????
 

Last edited:

**broken link removed**

This is the board which i am using ...
Does keil 4 works with this or should i use keil 3?
 

The keil version is not a problem , 4 works the same as v3
 

**broken link removed**

This is the board which i am using ...
Does keil 4 works with this or should i use keil 3?

Sorry! Schematic and manual links both are broken in the above link.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top