Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Single Bit

Status
Not open for further replies.

chandu13

New Member
Hay

In 8051 pins are bit addressable using sbit (Keil-C51) so I can declare input switch & out put LED as
Ex:
#include <REG51.H>
sbit SWITCH P1^1
sbit LED P1^4

How to declare the input switch & out put LED in LPC2114 using Keil-ARM

Regards
chandu
 
i know nothing really but i can give you a tip on how to find the answer. Since it seems to be a simple question meaning its the basis of most of the operations. Try looking at some application (app) notes. And you will usually find the answer quick.
 
Last edited:
Hay

In 8051 pins are bit addressable using sbit (Keil-C51) so I can declare input switch & out put LED as
Ex:
#include <REG51.H>
sbit SWITCH P1^1
sbit LED P1^4

How to declare the input switch & out put LED in LPC2114 using Keil-ARM

Regards
chandu

Atom is correct, and you should be able to find all you need here:
NXP (founded by Philips) LPC2114

I don't know why you couldn't find this yourself? :confused: :D
 
Bit

Hay
I am switching LED on & off using following code

#include"LPC210x.H"
#define LED1 0x00000800 //LED connected to the P0.11
#define LED2 0x00000400 //LED connected to the P0.10

void main()
{
IODIR=0xFFFFFFFF;
while(1)
{
delay();
IOSET=LED1;
delay();
IOCLR=LED1;
delay();
IOSET=LED2;
delay();
IOCLR=LED2;
}
}

I have seen some different code in the INTERNET

IOSET_bit.P0_11 = 1; //set P0.11t to 1
IOSET_bit.P0_10 = 1; // set P0.10t to 1
IO0CLR_bit.P0_11 = 1; //set P0.11t to 0
IO0CLR_bit.P0_10 = 1; //set P0.10t to 0

How this code will work

In the #include"LPC210x.H” file all the registers are the 32 bit register addressable

Regards
chandu
 
Hay
I am switching LED on & off using following code

#include"LPC210x.H"
#define LED1 0x00000800 //LED connected to the P0.11
#define LED2 0x00000400 //LED connected to the P0.10

void main()
{
IODIR=0xFFFFFFFF;
while(1)
{
delay();
IOSET=LED1;
delay();
IOCLR=LED1;
delay();
IOSET=LED2;
delay();
IOCLR=LED2;
}
}

I have seen some different code in the INTERNET

IOSET_bit.P0_11 = 1; //set P0.11t to 1
IOSET_bit.P0_10 = 1; // set P0.10t to 1
IO0CLR_bit.P0_11 = 1; //set P0.11t to 0
IO0CLR_bit.P0_10 = 1; //set P0.10t to 0

How this code will work

In the #include"LPC210x.H” file all the registers are the 32 bit register addressable

Regards
chandu

That's great Chandu! Glad you got an LED flashing, now you should be able to do what you want with that part. :) Your source is MUCH more readable than the other example you give. :D

The other code works by making the statement ( could be a macro, I'd have to spend time..) true. It is somewhat obscure, and quite anoying.
I could say some very negative things about the person who wrote the other example, but then that would make me as bad as him or her. :p
 
Last edited:
The code you found on the web is pretty much a direct representation of the hardware.

The ports on the chip are accessed through registers: SET, CLR, DATA, READ, and HIZ. I do not remember the exact names given.

DATA is merely an output data latch and READ picks up the voltage on the pin so if you SET a pin that is pulled to GND externally the READ returns a ZERO. This is a deviation from most processors in that you can flash your LED with out effecting the rest of the port with out doing a read/modify/write cycle. This can save a lot of time randomly toggling ports, espescially since you can set or reset as many as you want in a single write. The ARM CORTEX goes all the way to direct hardware pin addressing.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top