LPC1114 Olimex

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1114 Olimex

317 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bahec06 on Tue Jul 29 12:44:16 MST 2014
Hello. I have a board LPC1114-Olimex, which contains lpc1114/302 microcontroller. I'd like to do something with LED, but nothing happens. This is my code from Keil v4. Downloading code to memory is succesfull. I'm using j-link segger. Where i'm wrong?

#include "LPC11xx.h"

const unsigned long led_mask[] = {1 << 0, 1 << 1, 1 << 2, 1 << 3, 
                                  1 << 4, 1 << 5, 1 << 6, 1 << 7 };
int i;

void LED_On (unsigned int num) {

  LPC_GPIO3->DATA |=  led_mask[num];
}

void LED_Off (unsigned int num) {

  LPC_GPIO3->DATA &= ~led_mask[num];
}

void delay(int time) {
for(i=1;i<=time;i++) {
}
}

void LED_init(void) {

  LPC_SYSCON->SYSAHBCLKCTRL |= (1 <<  6);     /* enable clock for GPIO      */
  /* configure GPIO as output */
  LPC_GPIO3->DIR  |=  (led_mask[0] | led_mask[1] | led_mask[2] | led_mask[3]);

  LPC_GPIO3->DATA &= ~(led_mask[0] | led_mask[1] | led_mask[2] | led_mask[3]);
}

int main() {
LED_init();
while(1) {
LED_On(1);
delay(10000);
LED_Off(1);
delay(10000);
}
}
Labels (1)
0 Kudos
1 Reply

294 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nerd herd on Thu Jul 31 12:45:00 MST 2014
Hello,

Judging from your code snippet, the first thing that comes to mind is to make sure you are initializing the pin correctly. As you can see in section 9.5 in the LPC11xx user's manual, the pins on the MCU are multiplexed and can have different functions. Make sure you are initializing the pin that the LED is connected to as a GPIO!

http://www.nxp.com/documents/user_manual/UM10398.pdf

It also wouldn't hurt to look at our software platform, LPC Open. We have several code examples, but the board you have is not officially supported. The examples will most likely not work out of the box, but you can still look at the examples as a reference. The "blinky" example in specific can be helpful for what you are trying to accomplish. ;)

http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc11xx-packages-0
0 Kudos