[SOLVED] ARM 7 startup program

Status
Not open for further replies.

manvindar

Member level 1
Joined
Jun 10, 2012
Messages
41
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Banglore
Visit site
Activity points
1,529
i am new to ARM processors and want to write a simple code like monitoring pin P0.8 and if its high then LED should glow at Pin P0.22

how about to do that?
 

oh yea sry.....i am using LPC2129...and uvision 4

- - - Updated - - -

here is rough code

Code:
#include <LPC21xx.h>
#define led (1<<22)
#define sw (1<<8)
int main (void)
{ PINSEL0=sw;
IODIR0=0xFFFFFFF; if (sw == 1)

IOSET0 = (1<<22); 
else 
IOCLR0 = (1<<22);
}

- - - Updated - - -

whats wrong with this code???

Code:
#include <LPC21xx.h>
#define led (1<<22) // Led is bit 22
#define sw (1<<8)  // Switch is bit 8

int main (void)
{
  IODIR0 &= ~sw; // Set as inputs
  IODIR0 |= led; // Set as outputs

  while(1)
  {
    if (IOPIN0 & sw) // Check switch state, reflect to led
      IOSET0 = led;
    else
      IOCLR0 = led;
  }
}

[
 


I don't see a problem, what is the result of the code when you run it?
 

Can you post a schematic?
How is the led connected (Anode/Cathode) and to what voltage?
Did you use a resistor?
 

sry the code is correct..actually the led is embedded in dev board and its connected to the other way......
 

sry the code is correct..actually the led is embedded in dev board and its connected to the other way......

And I'm not sure what you meant by that, does it mean that you reversed the logic states in the code and you solved your problem?
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…