We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
pls help...
i'm working on LPC1114-FBD/301 series
On my board 4 LED's are connected to P0_8, P0_9, P0_10, P0_11.
I'v written a sample code toggle them. Only on 8 and 9 port pin LED's are blinking but on 10 and 11 there state is always on. here is the sample code
/* by default P0_8 and P0_9 pins are GPIO's */ LED_DIR |= BIT(8); LED_DIR |= BIT(9);
/* 9th and 10th pins are not GPIO's on reset */ // i think here some changes required to make them as GPIO's IOCON_SWCLK_PIO0_10 |= 0x1; IOCON_R_PIO0_11 |= 0x1;
LED_DIR |= BIT(10); LED_DIR |= BIT(11);
if you don't have hardware debugging capabilities, you may want to simulate your code.
i have no idea if your is right or not but the following may be more readable:
#define LED_PORT GPIO0DATA //output data register where the leds are on #define LED_DIR GPIO0DIR #define BIT(n) (1<<n) #define LEDs (BIT(8) | BIT(9) | BIT(10) | BIT(11)) //leds on pin8/9/10/11 #define LED_ON(leds) {LED_PORT |= (leds);} //leds active on #define LED_OFF(leds) {LED_PORT &=~(leds);} //leds active off #define LED_TOGGLE(leds) {LED_PORT ^= (leds);} //toggle leds void delay(unsigned long dly ) { while ( dly-- ); } void main (void ) { /* by default P0_8 and P0_9 pins are GPIO's */ LED_DIR |= BIT(8); LED_DIR |= BIT(9); /* 10th and 11th pins are not GPIO's on reset */ IOCON_SWCLK_PIO0_10 |= 0x01; /* Set P0_10 pin as GPIO */ IOCON_R_PIO0_11 |= 0x01; /* Set P0_11 pin as GPIO */ LED_DIR |= BIT(10); LED_DIR |= BIT(11); while ( 1 ) { LED_TOGGLE(LEDs); //toggle leds delay(0x40000 ); //waste some time } }
this will be easier to read.
Thanks... I'v to improve my coding style...