EmbeddedRelated.com
Forums

Where is the I/O ports in this LPC2148 Prototype Board

Started by essam November 5, 2011
> There are 2 chip documens: the User Manual and the Datasheet. Get these from NXP.
>
> The datasheet discusses phyical things like voltage levels and signal timing. This isn't nearly as useful as the User Manual.
>
> The User Manual discusses the device and every component included. Why is there a P0.xx and a P1.xx? There are (2) 32 bit ports (P0 and P1).
>
> When you read up on Pin Connect you will see how a single physical pin can be connected to multiple internal sources. A pin might be a digital IO, an analog input or something else depending on how it is programmed.
>
> Table 60 is the beginning of the tables that show how ins are configured. For example P0.1 can be a general purpose IO, the receive signal for UART0, a PWM output or and external interrupt input depending on how it is programmed.
>
> The User Manual is hard to read. It is BORING and terribly detailed! It is probably best to just skim through it quickly at first and then refer to specific sections as they are needed. I find myself printing out chapters while I set up a specific peripheral and then trashing the printouts after I have finished. At some point, every detail of the chapter will be important.
>
> On 2 of my computers I have dual displays. This is very handy when programming because I can keep the User Manual open on one screen.
>
> You will find that every board makes assumptions about the use of various pins. As a result, it may not be possible to use every feature of the chip due to the fact that external components are already connected. So, you need to verify that what you are attempting to do are even possible by referring to the board schematic. There are always limitations.
>
> Richard
>

thank you for your kind explanation.

i am a computer geek with 15 years of my life spent in reading various computer books as a hobby. i tried to learn many things in computer world but this is the first time ever i face something that has no book for beginners. i guess it is because it is meant primarily for engineers. well ,no complain :) it is still interesting for me . actually it is even more interesting now because maybe i will be able to write a book for beginners . you know guys nowadays anyone can write a book and sell it as an electronic book.

cheers.

An Engineer's Guide to the LPC2100 Series

--- In l..., "essam" wrote:
>
> i am a computer geek with 15 years of my life spent in reading various computer books as a hobby. i tried to learn many things in computer world but this is the first time ever i face something that has no book for beginners.

Try the Hitex Insider's Guides:

http://www.hitex.com/index.php?id=download-insiders-guides


This book is intended as a hands-on guide for anyone planning to use the Philips LPC2000 family of microcontrollers in a new design. It is laid out both as a reference book and as a tutorial. It is assumed that you have some experience in programming microcontrollers for embedded systems and are familiar with the C language.


Regards,
Chris Burrows
CFB Software

Astrobe: ARM Oberon Development System
http://www.astrobe.com

--- In l..., "cfbsoftware1" wrote:
>
> --- In l..., "essam" wrote:
> >
> > i am a computer geek with 15 years of my life spent in reading various computer books as a hobby. i tried to learn many things in computer world but this is the first time ever i face something that has no book for beginners.
>
> Try the Hitex Insider's Guides:
>
> http://www.hitex.com/index.php?id=download-insiders-guides
>
>
> This book is intended as a hands-on guide for anyone planning to use the Philips LPC2000 family of microcontrollers in a new design. It is laid out both as a reference book and as a tutorial. It is assumed that you have some experience in programming microcontrollers for embedded systems and are familiar with the C language.
> Regards,
> Chris Burrows
> CFB Software
>
> Astrobe: ARM Oberon Development System
> http://www.astrobe.com
>

thank you
this book is not for beginner :)

--- In l..., "essam" wrote:
>
> thank you
> this book is not for beginner :)
>

As pointed out, the assumption is that the reader has some experience with programming other microcontrollers. Implicit in the title is that the book is intended for engineers. Folks who have taken classes in programming and hardware.

I had seen it early in my use of the LPC2106 but never bothered to read it. If I were to read it today, I would read it from 10,000 feet. That is, not bother about the details, just try to get the broad brush outline of the device.

All that assembly language stuff in the first chapter is interesting, the pipeline is interesting, the fact that the PC is 8 byes ahead is CRITICAL (to the assembly language programmer) but, in the end, C programmers just don't get involved with such things very often.

Skim over the book and put it aside for reference. It is probably as good as anything out there other that the ARM manuals and they are really tough to read. Again, the difference between a tutorial and a reference book.

What you really need to do is get an LED to blink. This seems like a very simple goal, and it is, but it takes quite a bit of knowledge to get it to work.

First, you need to understand how to create a new project and target the LPC2148. This will bring in the startup code that is common to every project. Written in assembly language, it is something you don't need to understand right away.

Next you need to know how to create a file for main.c (this will almost ALWAYS be the name of the top level C file) and what header files you need to include. The IDE main add the include statement or you may need to do it yourself:
#include

You will also find that capitalization is important.

OK, you're ready to write (or copy) C code. From the schematic, you find out that one of the LEDs is on P0.10.

#define LED_BIT (10)

int main (void) {

int j;

IO0DIR |= (1 << LED_BIT);
IO0CLR = (1 << LED_BIT);

while (1) {
for (j = 0; j < 1500000; j++ )
;
IO0SET = (1 << LED_BIT);

for (j = 0; j < 1500000; j++ )
;
IO0CLR = (1 << LED_BIT);
}
}

From reading Table 65 of the User Manual, you will see that IO0DIR is used to set pins to input or output. Every bit that you set to '1' will become an output. IO0DIR retains previous setup information (initially all 0's) so we OR in the bit we want to change to output with the |= C operator.

Again, from Table 65, we see that IO0SET is used to set the output pin high and that IO0CLR sets the pin low. These registers NEVER use |= or &=, they always use just =. Setting a bit in one of the registers changes the state of the pin but does nothing to HOLD the pin in any state. You can directly control the state of the pin with IO0PIN but this is not commonly used.

You have to go back a ways with microcontrollers to find out with IO0CLR and IO0SET are so handy. In the old days we would have to read the port, mask in the new desired state and then write the state. This was called read-modify-write and was fraught with error. The value you read was not necessarily the value of the output flip-flop (due to electrical issues) and sometimes just reading a port would change things like interrupt signals. It was often necessary to create a mirror copy of the register in RAM, modify the RAM image and then just send the output. A lot of work that just isn't required on the ARMs.

From the schematic you will note that the LED is connected to 3.3V and applying a logic '0' to the output pin will turn the LED on. So, IO0CLR = (1 << LED_BIT) turns the LED on while IO0SET = (1<< LED_BIT) turns it off by applying 3.3V to the cathode. No voltage drop across the LED -> no light output.

Once the code is complete, it is time to build the project and create an output file for the JTAG device. There is a button on the toolbar for "Build Solution". If everything is correct, there will be no errors.

Then click the ! button to start without debugging and, with luck, the LED will blink. This is a HUGE step up the learning curve. The rest is just details. Seriously!

I'm not going to go through the details of Rowley CrossStudio because they do a better job:
http://www.rowleydownload.co.uk/documentation/arm_2_1/index.htm

Yes, there's a lot of reading to do. As I said a long time back on this thread, the learning curve for the ARM is high and steep. But it is worth it.

Richard

--- In l..., "rtstofer" wrote:
>
> --- In l..., "essam" wrote:
> >
> > thank you
> > this book is not for beginner :)
> > As pointed out, the assumption is that the reader has some experience with programming other microcontrollers. Implicit in the title is that the book is intended for engineers. Folks who have taken classes in programming and hardware.
>
> I had seen it early in my use of the LPC2106 but never bothered to read it. If I were to read it today, I would read it from 10,000 feet. That is, not bother about the details, just try to get the broad brush outline of the device.
>
> All that assembly language stuff in the first chapter is interesting, the pipeline is interesting, the fact that the PC is 8 byes ahead is CRITICAL (to the assembly language programmer) but, in the end, C programmers just don't get involved with such things very often.
>
> Skim over the book and put it aside for reference. It is probably as good as anything out there other that the ARM manuals and they are really tough to read. Again, the difference between a tutorial and a reference book.
>
> What you really need to do is get an LED to blink. This seems like a very simple goal, and it is, but it takes quite a bit of knowledge to get it to work.
>
> First, you need to understand how to create a new project and target the LPC2148. This will bring in the startup code that is common to every project. Written in assembly language, it is something you don't need to understand right away.
>
> Next you need to know how to create a file for main.c (this will almost ALWAYS be the name of the top level C file) and what header files you need to include. The IDE main add the include statement or you may need to do it yourself:
> #include You will also find that capitalization is important.
>
> OK, you're ready to write (or copy) C code. From the schematic, you find out that one of the LEDs is on P0.10.
>
> #define LED_BIT (10)
>
> int main (void) {
>
> int j;
>
> IO0DIR |= (1 << LED_BIT);
> IO0CLR = (1 << LED_BIT);
>
> while (1) {
> for (j = 0; j < 1500000; j++ )
> ;
> IO0SET = (1 << LED_BIT);
>
> for (j = 0; j < 1500000; j++ )
> ;
> IO0CLR = (1 << LED_BIT);
> }
> }
>
> From reading Table 65 of the User Manual, you will see that IO0DIR is used to set pins to input or output. Every bit that you set to '1' will become an output. IO0DIR retains previous setup information (initially all 0's) so we OR in the bit we want to change to output with the |= C operator.
>
> Again, from Table 65, we see that IO0SET is used to set the output pin high and that IO0CLR sets the pin low. These registers NEVER use |= or &=, they always use just =. Setting a bit in one of the registers changes the state of the pin but does nothing to HOLD the pin in any state. You can directly control the state of the pin with IO0PIN but this is not commonly used.
>
> You have to go back a ways with microcontrollers to find out with IO0CLR and IO0SET are so handy. In the old days we would have to read the port, mask in the new desired state and then write the state. This was called read-modify-write and was fraught with error. The value you read was not necessarily the value of the output flip-flop (due to electrical issues) and sometimes just reading a port would change things like interrupt signals. It was often necessary to create a mirror copy of the register in RAM, modify the RAM image and then just send the output. A lot of work that just isn't required on the ARMs.
>
> From the schematic you will note that the LED is connected to 3.3V and applying a logic '0' to the output pin will turn the LED on. So, IO0CLR = (1 << LED_BIT) turns the LED on while IO0SET = (1<< LED_BIT) turns it off by applying 3.3V to the cathode. No voltage drop across the LED -> no light output.
>
> Once the code is complete, it is time to build the project and create an output file for the JTAG device. There is a button on the toolbar for "Build Solution". If everything is correct, there will be no errors.
>
> Then click the ! button to start without debugging and, with luck, the LED will blink. This is a HUGE step up the learning curve. The rest is just details. Seriously!
>
> I'm not going to go through the details of Rowley CrossStudio because they do a better job:
> http://www.rowleydownload.co.uk/documentation/arm_2_1/index.htm
>
> Yes, there's a lot of reading to do. As I said a long time back on this thread, the learning curve for the ARM is high and steep. But it is worth it.
>
> Richard
>

that was a long jump ahead. thank you.

i am just waiting for my arm board and jtag to arrive.
:)

I agree that the learning curve for NXP devices may be steep, but this is
NOT the learning curve for ARM.

All of these issues are related to the device and its peripherals, not ARM,
and how much simpler is it with an 8 bit micro?.

The good thing is that once you get used to the configuration of peripherals
they are used across the entire family.

But if you want an easier life try using the CMSIS code to configure the
ports and peripherals.

Regards

Phil.

From: l... [mailto:l...] On Behalf Of
essam
Sent: 07 November 2011 02:44
To: l...
Subject: [lpc2000] Re: Where is the I/O ports in this LPC2148 Prototype
Board

--- In l... ,
"rtstofer" wrote:
>
> --- In l... ,
"essam" wrote:
> >
> > thank you
> > this book is not for beginner :)
> > As pointed out, the assumption is that the reader has some experience with
programming other microcontrollers. Implicit in the title is that the book
is intended for engineers. Folks who have taken classes in programming and
hardware.
>
> I had seen it early in my use of the LPC2106 but never bothered to read
it. If I were to read it today, I would read it from 10,000 feet. That is,
not bother about the details, just try to get the broad brush outline of the
device.
>
> All that assembly language stuff in the first chapter is interesting, the
pipeline is interesting, the fact that the PC is 8 byes ahead is CRITICAL
(to the assembly language programmer) but, in the end, C programmers just
don't get involved with such things very often.
>
> Skim over the book and put it aside for reference. It is probably as good
as anything out there other that the ARM manuals and they are really tough
to read. Again, the difference between a tutorial and a reference book.
>
> What you really need to do is get an LED to blink. This seems like a very
simple goal, and it is, but it takes quite a bit of knowledge to get it to
work.
>
> First, you need to understand how to create a new project and target the
LPC2148. This will bring in the startup code that is common to every
project. Written in assembly language, it is something you don't need to
understand right away.
>
> Next you need to know how to create a file for main.c (this will almost
ALWAYS be the name of the top level C file) and what header files you need
to include. The IDE main add the include statement or you may need to do it
yourself:
> #include You will also find that capitalization is important.
>
> OK, you're ready to write (or copy) C code. From the schematic, you find
out that one of the LEDs is on P0.10.
>
> #define LED_BIT (10)
>
> int main (void) {
>
> int j;
>
> IO0DIR |= (1 << LED_BIT);
> IO0CLR = (1 << LED_BIT);
>
> while (1) {
> for (j = 0; j < 1500000; j++ )
> ;
> IO0SET = (1 << LED_BIT);
>
> for (j = 0; j < 1500000; j++ )
> ;
> IO0CLR = (1 << LED_BIT);
> }
> }
>
> From reading Table 65 of the User Manual, you will see that IO0DIR is used
to set pins to input or output. Every bit that you set to '1' will become an
output. IO0DIR retains previous setup information (initially all 0's) so we
OR in the bit we want to change to output with the |= C operator.
>
> Again, from Table 65, we see that IO0SET is used to set the output pin
high and that IO0CLR sets the pin low. These registers NEVER use |= or &=,
they always use just =. Setting a bit in one of the registers changes the
state of the pin but does nothing to HOLD the pin in any state. You can
directly control the state of the pin with IO0PIN but this is not commonly
used.
>
> You have to go back a ways with microcontrollers to find out with IO0CLR
and IO0SET are so handy. In the old days we would have to read the port,
mask in the new desired state and then write the state. This was called
read-modify-write and was fraught with error. The value you read was not
necessarily the value of the output flip-flop (due to electrical issues) and
sometimes just reading a port would change things like interrupt signals. It
was often necessary to create a mirror copy of the register in RAM, modify
the RAM image and then just send the output. A lot of work that just isn't
required on the ARMs.
>
> From the schematic you will note that the LED is connected to 3.3V and
applying a logic '0' to the output pin will turn the LED on. So, IO0CLR = (1
<< LED_BIT) turns the LED on while IO0SET = (1<< LED_BIT) turns it off by
applying 3.3V to the cathode. No voltage drop across the LED -> no light
output.
>
> Once the code is complete, it is time to build the project and create an
output file for the JTAG device. There is a button on the toolbar for "Build
Solution". If everything is correct, there will be no errors.
>
> Then click the ! button to start without debugging and, with luck, the LED
will blink. This is a HUGE step up the learning curve. The rest is just
details. Seriously!
>
> I'm not going to go through the details of Rowley CrossStudio because they
do a better job:
> http://www.rowleydownload.co.uk/documentation/arm_2_1/index.htm
>
> Yes, there's a lot of reading to do. As I said a long time back on this
thread, the learning curve for the ARM is high and steep. But it is worth
it.
>
> Richard
>

that was a long jump ahead. thank you.

i am just waiting for my arm board and jtag to arrive.
:)



--- In l..., "Phil Young" wrote:
>
> I agree that the learning curve for NXP devices may be steep, but this is
> NOT the learning curve for ARM.
>
>
>
> All of these issues are related to the device and its peripherals, not ARM,
> and how much simpler is it with an 8 bit micro?.
>
>
>
> The good thing is that once you get used to the configuration of peripherals
> they are used across the entire family.
>
>
>
> But if you want an easier life try using the CMSIS code to configure the
> ports and peripherals.
>
>
>
> Regards
>
>
>
> Phil.
>
>
i am not looking for easier life otherwise i would ditch the ARM and use the arduino :D
i am looking for fun ,accomplishment , self satisfaction.
thank you for your kind response

--- In l..., "Phil Young" wrote:

> But if you want an easier life try using the CMSIS code to configure the
> ports and peripherals.
>
> Regards
> Phil.
CMSIS works on the LPC2148?

Richard

--- In l..., "rtstofer" wrote:
>
> --- In l..., "Phil Young" wrote:
>
> > But if you want an easier life try using the CMSIS code to configure the
> > ports and peripherals.
> >
> > Regards
> > Phil.
> CMSIS works on the LPC2148?
>
> Richard
>
Last time I checked the LPC2148 was based on an ARM7. Afaik, CMSIS covers Cortex-M, so the answer is probably "No".
I'm always open to learn new things.

Bob