lpcware

LPC1114 Olimex

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
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);
}
}

Outcomes