hi....i am just starting with ARM microcontrollers........ i want to make a program so that i can monitor a pin like P0.8 and if its high then LED should glow on P0.22
here is pseudocode for it
#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); }
well....i think that code is fundamentally wrong...i tried what he said on my dev board but it didnt worked
Do your teachers not provide you with guidance, or notes?
I have no idea what board you have, and I'm not much into NXP, but this would seem to be a more sensible solution. Note the use of PRE tags for source code, per the "Tips for Posting Messages"
#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; } }
well i am learning by myself..... i am using LPC2129 board...
this code is not working
That's a chip, what board is it on, who makes it? Provide a cite for schematics, documentation, etc.
i think that code is fundamentally wrong
If that's what you think, what possessed you to write fundamentally wrong code?
Or more to the point: why didn't you just steal better code from somewhere else?