Hi friends.I am new to ARM programming.I am working on NXP LPC1768 processor. There are 8 LED's interfaced to the processor as follows. LED0-P2.0 LED1-P2.1 LED2-P2.2 LED3-P2.3 LED4-P2.4 LED5-P2.5 LED6-P1.25 LED7-P1.26 i want to display the equivalent values of 0 to 255 on these LED's. When we use the FIOSET and set any particular pin only that pin gets set and provious pins remain unchanged. I have used following code.
#include "lpc17xx.h" #include "type.h" #include "delay.h" int main (void) { unsigned int i; unsigned long value=0; SystemInit(); LPC_GPIO2->FIODIR = 0x0000003F; while(1) { LPC_GPIO2->FIOCLR=0x0000003F; for(i=1;i<64;i++) { value=value+1; LPC_GPIO2->FIOSET=(value); delay_ms(100); } i=0; } }
The output is worng.Please suggest me. Thank you
When we use the FIOSET and set any particular pin only that pin gets set and provious pins remain unchanged.
And how did you you plan on clearing any of those pins you set?
to be precise when i want to display 0x00000001 the LED0 pin will be ON.and when i want to display 0x00000002 LED 0,1 are getting on when only LED 1 has to be ON. I am struck with the algorithm as to how to clear the pin value(using FIOCLR).
LPC_GPIO2->FIOSET=(value); LPC_GPIO2->FIOCLR=(~value &0x3F); // Invert to clear the bits you want to ZERO