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);
Hi the problem is i'm not able to configure P0_10 and P0_11 on LPC1114 as GPIO pins. pls help me to configure them as GPIO's. Using IAR i'v compiled the code.
Normally, GPIO is the default role for most pins of LPC chips. All you need to do is set the direction, find out if there are any compatibility/legacy issues (see SCS register of LPC24xx processors applying to GPIO port 0) and figure out how to clear and set the pins (again, referring to the legacy issue). The user manual will tell you all you need to know, as well as example programs available in your tool-chain folder.
I too thought the same.. but those to pins P0_10 and P0_11 on LPC1114 are not GPIO's on reset. using the following code i configured them as GPIO's.. but still it's not working..
/* last 3 bits of the following registers are used to select the function So i'v set it to 1 here. */
IOCON_SWCLK_PIO0_10 |= 0x1; IOCON_R_PIO0_11 |= 0x1;
What does your LED_DIR macro do? What does your BIT macro do?
they are jus macros...
this is how they are defined
LED_DIR GPIO0DIR /* PORT0 direction control register */ BIT(n) (1<<n)
where is your code?
9th and 10th pins of PORT0 on LPC1114 are not GPIO's On reset. I used the following code to set them set them as GPIO's. But still its not working.
#define LED_DIR GPIO0DIR #define BIT(n) (1<<n)
IOCON_SWCLK_PIO0_10 |= 0x01;
IOCON_R_PIO0_11 |= 0x01;
delay( );
You write about 9th and 10th pin.
But: bit 0 is 1st pin. bit 1 is 2nd. ... bit 8 is 9th bit 9 is 10th bit 10 is 11th.
How is this 9th and 10th pin? BIT(10) controls the 11th (not 9th) pin for the port. BIT(11) controls the 12th (not 11th) pin for the port.
But we assume that you do mean PIO0_10 and PIO0_11.
You are setting the least significant bit, without thinking about previous content. Should be ok since the reset value is 0 (unless there is another assign somewhere).
Mode 2 (pull-up enabled) should be ok.
Assign should be ok since reset value is zero (unless you have another assign somewhere). Mode 2 should also be ok.
Without having worked with your specific chip, it looks like PIO0_10 and PIO0_11 are set as GPIO output.
Maybe IOCON_SCK_LOC is involved, but to me it looks like this register is only relevant when having selected the SWCLK option.
What debugging have you done?
I'm using flash magic to burn the code.. i don't have any debugging options... Please guide me to configure P0_10 and P0_11 pins as GPIO's.
Thanks in advance Sanjeev
They all want "guidance". Go get yourself a guru for god's sake! Per gave you the answer. Did you even read it?!
If you have _zero_ options for debugging (no JTAG, and not being able to use a serial port, oscilloscope, LEDs, ...) then maybe you should consider doing something else. Everything about embedded development is a continuous sequence of feedback loops. Read specifications/datasheets/... then do something then verify what happens then analyze the outcome and figure out if there is needs for corrections and new verifications. Because of this need for feedback during the work, you should never attempt a task without having figured out if you have reasonable ways to collect the evidence you need.
An extra interesting thing here is that the boot-default for PIO0:10 is as SWCLK - serial wire clock for debug logic when in the Serial Wire Debug mode. On one hand, it might have been good if you had had the required equipment to use this Serial Wire Debug mode when writing your programs. On the other hand - maybe the two pins defaulting to debugging shouldn't be used for other tasks until you either know the chip well enough that you know that you can get away with developing without a hardware debugger.
By the way - how do you know that your pins aren't actually correctly configured but your LEDs not correctly connected?
i'v tested the continuity between LED and the pins.. On reset there state is on..
"On" as in high?
High as in strongly driven high or driven high by weak internal pull-up?
High as in managing to light the LED?
High as in managing to light the LED to full intensity?
The next thing is of course that your very short post only mentions what you saw "on reset" - but what happens later?
We haven't even seen your code that is expected to flash the LEDs.
Or what your delay() function actually does.
On reset all the LED's are ON. I'v writtern a test code to toggle there states. After flashing the code all LED states should be toggled. But only LED's on P0_8 and p0_9 pins are getting toggled. Other two LED's connected on P0_10 and P0_11 are always ON.
I'm sending the code. Pls review.
void delay( ) { unsigned int i = 0x40000; while ( i-- ); } main ( ) {
/* 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 */
while ( 1 ) { GPIO0DATA &= ~(BIT(8)); GPIO0DATA &= ~(BIT(9)); GPIO0DATA &= ~(BIT(10)); GPIO0DATA &= ~(BIT(11)); delay( ); delay( ); GPIO0DATA |= BIT(8); GPIO0DATA |= BIT(9); GPIO0DATA |= BIT(10); GPIO0DATA |= BIT(11); delay( ); delay( ); } }
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.
I'm sending the code. Pls review. please review the instructions Place source code source code .... in the yellow field of the reply (Enter Message Details Below) window
why do you think anyone can do anything with what you saw in the preview?
Erik