This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Code not working on LPC2148 board

I bought an ARM LPC2148 Development board and started uploading code in it.  I wrote the code to blink the on-board 4 LEDs.  It gets uploaded successfully in the board but the LEDs never blink (leave alone the blinking according to the code).  I have rechecked the code again and again.  I am getting 0 V on the pins(P1.16, P1.17, P1.18, P1.19) to which the LEDs are connected.  I cannot figure out why this is happening.  Help!!

The code is:-

#include  <lpc214x.h> //Includes LPC2148 register definitions
#define LED1_ON() IO1SET=(1<<16) //Macro Functions to turn ON LED

#define LED2_ON() IO1SET=(1<<17)

#define LED3_ON() IO1SET=(1<<18)

#define LED4_ON() IO1SET=(1<<19)

#define LED1_OFF() IO1CLR=(1<<16) //Macro Functions to turn OFF LED

#define LED2_OFF() IO1CLR=(1<<17)

#define LED3_OFF() IO1CLR=(1<<18)

#define LED4_OFF() IO1CLR=(1<<19)

void  Delay(unsigned char j)    //This Function is used to cause delay between LED ON and OFF events

{

unsigned int  i;

for(;j>0;j--)

{

  for(i=0; i<60000; i++);

}

}

int  main(void)

{

PINSEL0 = 0x00000000; // Enable GPIO on all pins

PINSEL1 = 0x00000000;

PINSEL2 = 0x00000000;

IO1DIR = (1<<19) | (1<<18) | (1<<17) | (1<<16); // Set P1.16, P1.17, P1.18, P1.19 as Output
while(1)

{

  LED1_ON();

  Delay(25);

  LED1_OFF();

  LED2_ON();

  Delay(25);

  LED2_OFF();

  LED3_ON();

  Delay(25);

  LED3_OFF();

  LED4_ON();

  Delay(25);

  LED4_OFF();

}

return(0);

}

Parents
  • Hi mayankv2,

    It's puzzling when you get 0 V on P1.16 to P1.19, either the drivers are stuck to logic low or the ports cannot be properly configured (we note that they have internal pull-up). Try to verify your measurements first, double check the pin numbers, better yet use a logic probe or an oscilloscope if you have that instrument. If you confirm your previous results, try running your code with:

    • the Debug/Trace/JTAG connectors disconnected
    • your development board disconnected from the host computer

    When trying to restart the LPC2148, press the reset button of your board instead of using a command from the IDE. If there is no change in the behavior of your board, try to disable the line that modifies PINSEL2

    PINSEL2 = 0x00000000;

    to

    //PINSEL2 = 0x00000000;

    Revisions of the LPC214x User manual have changes relating to PINSEL2 and you may want to avoid writing to the PINSEL2 register if possible.

    If you will provide update to your progress, indicate the state of the LEDs in more detail. Do they appear to be all off, on simultaneously, or on simultaneously but faint?

    Regards,

    Goodwin

Reply
  • Hi mayankv2,

    It's puzzling when you get 0 V on P1.16 to P1.19, either the drivers are stuck to logic low or the ports cannot be properly configured (we note that they have internal pull-up). Try to verify your measurements first, double check the pin numbers, better yet use a logic probe or an oscilloscope if you have that instrument. If you confirm your previous results, try running your code with:

    • the Debug/Trace/JTAG connectors disconnected
    • your development board disconnected from the host computer

    When trying to restart the LPC2148, press the reset button of your board instead of using a command from the IDE. If there is no change in the behavior of your board, try to disable the line that modifies PINSEL2

    PINSEL2 = 0x00000000;

    to

    //PINSEL2 = 0x00000000;

    Revisions of the LPC214x User manual have changes relating to PINSEL2 and you may want to avoid writing to the PINSEL2 register if possible.

    If you will provide update to your progress, indicate the state of the LEDs in more detail. Do they appear to be all off, on simultaneously, or on simultaneously but faint?

    Regards,

    Goodwin

Children
  • Thanks for replying back goodwin.

    I double-checked all the connections.  I run the above code in Debugging mode in Keil and it's working fine.   I also checked in Simulation in Proteus and it shows expected results. Also, I connected 4 LEDs on a separate breadboard and connected them with the pins of the LPC board using jumper wires.  They were all off for the whole time.  Not a single LED blinked or turned on for a moment.  Also, I noted a strange behavior.  The pin P1.23 and P1.22 are always high in my board.  I wrote a simply code to output LOW on P1.23 and P1.22 but again they gave high voltage.  I don't know what is happening here. 

  • Have you tried doing your exercises on PORT0?

    In this LED sequencer, you may want to replace IO1SET, IO1CLR, and IO1DIR with IO0SET, IO0CLR, and IO0DIR respectively in your code (save the modification in a different project) and connect the separate LEDs to P0.16, P0.17, P0.18, P0.19. Try if the code will work, this will tell whether the problem is confined only to PORT1 or will also manifest on PORT0.