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.

Problem with LPC2148 programming

Status
Not open for further replies.

ghegde

Member level 1
Member level 1
Joined
Jul 12, 2010
Messages
32
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
Singapore
Activity points
1,502
Dear friends,
I am new to ARM microcontrollers. I wrote a code to blink the LED connected to pin P1.24(of LPC2148).The hex file is downloaded and verified successfully using Flash Magic.But the LED is not blinking!!!!!!!!!.I used Keil IDE.What may be the problem?
The C code is as follow........

/*******************************************************************************
Header files
*******************************************************************************/
#include "LPC214x.h"

/*******************************************************************************
MAIN
*******************************************************************************/
int main (void) {
// for loop variable declaration
int j,i;

// P1.24 output
IODIR1 = 0x01000000;

// endless loop to toggle the led
while (1) {
for (j = 0; j < 30; j++ )
{
for (i = 0; i < 50000; i++ ); //Delay Loop
}
//Turn ON LED
IOSET1 = 0x01000000;

for (j = 0; j < 30; j++ )
{
for (i = 0; i < 50000; i++ ); //Delay Loop
}

//Turn OFF LED
IOCLR1 = 0x01000000;
}

}
 

first of all, I would define the pin (as 0x01000000) and program around that so you can easily change pin assignment later.

in your case, it could be due to the delay loop being too short, or your compiler optimizes it out of the execution as the loop does nothing in the eyes of the compiler.
 

Hi,

Had you checked your hardware? if it's ok then simulate your code in keil check whether particular port pin blinks or not. Also check the delay by single step debugging, you will get to know that how long is your delay loop is..

NIKS
 

@niks
yes i tested the hardware and it is proper.i also went through single step debugging using the Keil IDE.Simulation shows no error!!!! the delay is about 3 seconds.what happens after programming is ,the led is just turned on (that too not bright).the output pin is connected to transistor which drives the led.

Added after 3 minutes:

@millwood
the loop is executed during simulation(single step debugging).the delay is abt 3sec not too short.
 

well, maybe then the led driver is faulty. do you observe changing output on the pin?
 

@millwood
No. I haven't observed any changes on the pin.I also connected the led to P1.10 and also to P1.11,but nothing happens :(
 

I cannot tell you more but the following works as expected. and it is (almost) identical to yours.

Code:
/******************************************************************************* 
Header files 
*******************************************************************************/ 
#include "LPC214x.h" 

#define LED		0x01000000		//led's on
#define LED_PORT	IOPIN1
#define LED_DDR		IODIR1
#define IO_SET(port, bits)	port |= (bits)	//set bits on port
#define IO_CLR(port, bits)	port &=~(bits)	//clear bits on port
#define IO_FLP(port, bits)	port ^= (bits)	//flip bits on port
#define IO_OUT(ddr, bits)	ddr |= (bits)	//put bits in output
#define IO_IN(ddr, bits)	ddr &=~(bits)	//bits as input

void delay(unsigned int dly) {
	unsigned int i;

	for (; dly; dly-- ) 
	{ 
	for (i = 0; i < 50000; i++ ); //Delay Loop 
	} 
}
/******************************************************************************* 
MAIN 
*******************************************************************************/ 
int	main (void) { 
	// for loop variable declaration 
	//int j,i; 
	
	// P1.24 output 
	//IODIR1 = 0x01000000; 
	IO_OUT(LED_DDR, LED);
	
	// endless loop to toggle the led 
	while (1) { 
		//Turn ON LED 
		//IOSET1 = 0x01000000; 
		IO_FLP(LED_PORT, LED);		//flip led

		delay(30);					//delay loop
		
		//for (j = 0; j < 30; j++ ) 
		//{ 
		//for (i = 0; i < 50000; i++ ); //Delay Loop 
		//} 
		
		//Turn OFF LED 
		//IOCLR1 = 0x01000000; 
		
	} 

}

I also connected the led to P1.10 and also to P1.11,but nothing happens

well, that's the way it is supposed to work - you apparently do NOT understand what your code is supposed to do.
 

Thanks to all:) the problem was with the chip..............i replaced it with the new one and everything works fine!!!!!!!!!!!!!!!!!!!!!!!!!!!
 

hi,
m new to ARM programming in Keil C.
I have downloaded MDK3.24 & uVision 4.
Is there any Manual where programming fundamentals are explained for Keil C for ARM?

Please help.

Thanks.
 

@rushabhoo13
Hey read this book,u will get some idea about how to use KEIL IDE........
 

Attachments

  • lpc-ARM-book_srn.pdf
    5.8 MB · Views: 109
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top