Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Some worthless talk, A request and Need help

2005-12-14 by Rob Jansen

Mahbub1833,

feel like Alice in Wonderland ???

>I am newbie in microcontroller world as well as in great ARM world.
>
>WORTHLESS TALK:
>Although I know that ARM microcontrollers are for the professionals; 
>  
>

Welcome in the wonderfull world of ARM microcontrollers, defenitely not 
only for the professionals.
With different not-too-expensive boards and free Gnu C compiler it is a 
real nice target for hobbyists also.

>BLOODY REQUEST:
>My request goes to all great professionals of this group. Please 
>make a starting point for us (newbie). More examples and projects 
>are needed to learn programming LPC series smoothly. Especially step 
>by step tutorial with code would be great. (Please give me some link 
>if there any). 
>  
>
It should not be that hard if you start from the IAR examples - I guess 
they have a "Hello World" in the form of a flashing LED or something 
similar. These are always nice examples to start from.
There is also a good book from Hitex (called something like "The 
insiders guide to the ARM7") to start with.

>NEED HELP:
>
>I have IAR LPC2148 development kit and J-Link adapter. I tried 
>example codes using IAR workbench and those run fine. But I couldn't 
>understand the coding with my little PC based programming knowledge. 
>Now my questions are- 
>
>1. How would I learn C language specified for this particular 
>microcontroller? 
>  
>
There is nothing special or magical about C for the lpc21xx series. It 
is just standard (ANSI compliant) C.
You just have to remember that you do not have all resources as you have 
on a PC. For printf() you need a console - most development environments 
will support this.
For file I/O you need a storage device - not standard available so 
forget this for the time being.
Accessing stuff like the LEDs and other I/O on the board need the 
different peripheral blocks in the chip. Check out the Philips website 
(www.semiconductors.philips.com) and get the datasheet and - more 
important - the user manual for your chip.
This user manual contains detailed information on the meaning of all the 
bits in the I/O registers.

Note: all I/O is memory mapped an can be read and written using a 
standard C pointer, but it has to be declared volatile - otherwise the 
compiler may optimize this out ...

Okay, you got all this ...
Take your simplest Keil example and try to add code to light an LED on 
the board.

Now you need some hardware knowledge of the board:
    When is the LED lit? when the output port is tied to ground or to 3.3V ?
    What is the output bit ?

Assume the LED is lit when tied to ground, you need to program a 0 level 
in the output bit.
Assume the output bit is P0.20.

Start reading the user manual of the 2148.
Chapter 8.4.1 shows the meaning and content of the IODIR register, this 
register determines if a bit is an input or output bit. You have to set 
bit 20 to make P0.20 an output port:

    IO0DIR |= (1<<20);  // Perform a logical OR of IODIR to set bit 20 to 1

(note: IO0DIR can also be called IODIR0, it is defined in the lpc21xx.h 
- or similar - include file)

Now all you have to do is set the P0.20 bit to 0, there are two ways to 
do this. See 8.4.3, 8.4.4 and 8.4.5
You can write all bits using the IO0PIN register (you need to apply a 
mask to set or reset the bits you want), use IO0SET to set any bits to 1 
or IO0CLR to clear any bits (set bits to 0).
Read the manual: "Writing a 1 produces a low level at the corresponding 
port pins"

    IO0CLR = (1<<20);

You don't need any mask or whatever, just writing a 1 is enough - as is 
stated in the manual.

Now compile the program and download it to your board.
You may want to check that you compile and download into RAM, not in Flash.
Flash has a limited number of write cycles - do not worry too much about 
this, it's a large number but for these simple tests it is just a waste 
to program flash.
Then download and run using the IAR debugger.

Please check the IAR / J-Link manuals on this.

>5. Somebody please upload or link few more codes to learn step by 
>step. 
>  
>
The problem is that we all have our favorite environment.
I use a board from Embedded Artists and they have their own make 
environment, farily well documented in the manual.
That manual is available via their web page and an example can be found 
somewhere on my ARM page (http://www.myvoice.nl/electronics/)
Check out "Timing your programs" that one contains a simple piece of 
code to read a timer and print data on the serial port (UART0).


>6. Suppose I want to interface a LDR to the circuit and want to show 
>the value in the LCD display. Now which pin (AD) would I use to 
>connect the LDR? And what would be the program? 
>  
>
Read the manual, as far as I know all AD ports are the same. It just 
depends on which pin is still available on your board for your own I/O.

The program is simple:

    1) initialize A/D (and UART)
    2) start A/D conversion
    3) wait for A/D conversion to be complete
    4) print out value of the UART
    5) repeat ...

Just start reading the user manual carefully. It's all there - Best is 
to read and then drop your detailed questions in this group again.

>I apologize for my kiddy questions in the professional group. I need 
>your help to go ahead in the microcontroller world.
>
we all have to start somewhere. I started about 25 years ago with a home 
built 6502 kit from Elektor, meanwhile I have no problems reading 
datasheets and user manuals for chips like the lpc2148.
But I do have problems with standard Windows programming and that kind 
of things. Programming web tablets, telephones and telephone exchanges 
is what I did, but do not ask me to write a Visual C (or Basic) version 
of a calculator ...

Oh, this group is mixed with professionals and hobbyists on all sorts of 
levels. So all levels of Questions are welcome!
In time you will be able to tell other how to ...

Good Luck,

    Rob

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.