I have two example that were generated from my applicatopn
Flashing leds using the four timer interrupts , 100ms, 200ms, 400ms, 800ms
A simple example that uses the GPIO group and pin interrupts.
LED1 turns on when P21 and P22 are grounded (using group 0 interrupt)
LED1 turns of when P23 or P24 are grounded (using group 1 interrupt)
LED2 turns on when P19 is grounded (using GPIO interrupt 0)
LED2 turns off when P18 is grounded (using GPIO interrupt 1)
First of all you have to add the extern "C" in front of the interrupt handlers in your code like I din in my examples , I don't think there is a way to avoid that with the online compiler.
I had trouble making the code compile using the LPC11Uxx.h header because there were the startup and core/system files that needed to be added so I replaced the header with mbed.h and the code worked fine.
I'm sure it will work too with LPC11Uxx.h if some system libraries are added but I didn't bother much and used the mbed instead.
My application doen't have UART initialization yet but if you do it using regiters and not function from a library then you don't need to add anything.
Note that sooner or later you will need to add so me library , for example LCD driver or something but this shouldn't be a problem, just add the library to the project.
Alex
Greatings,
I want to programme my mbed without the mbed library just for the fun of it and to learn how it goes. My starting point is the code examples of keil for the 11Uxx that I found here : http://www.lpcware.com/content/nxpfile/sample-code-bundle-lpc11uxx-peripherals-using-keils-mdk-arm-0
I tried the following blinky code at first :
/**************************************************************************** * $Id:: blinky.c 9190 2012-02-16 20:59:45Z nxp41306 $ * Project: NXP LPC11xx Blinky example * * Description: * This file contains LED blink code example which include timer, * GPIO initialization, and clock monitoring. * **************************************************************************** * Software that is described herein is for illustrative purposes only * which provides customers with programming information regarding the * products. This software is supplied "AS IS" without any warranties. * NXP Semiconductors assumes no responsibility or liability for the * use of the software, conveys no license or title under any patent, * copyright, or mask work right to the product. NXP Semiconductors * reserves the right to make changes in the software without * notification. NXP Semiconductors also make no representation or * warranty that such application will be suitable for the specified * use without further testing or modification. ****************************************************************************/ #include "LPC11Uxx.h" /* LPC11Uxx definitions */ #include "timer16.h" #include "clkconfig.h" #include "gpio.h" #include "nmi.h" #define TEST_TIMER_NUM 0 /* 0 or 1 for 16-bit timers only */ extern volatile uint32_t timer16_0_counter[2]; extern volatile uint32_t timer16_1_counter[2]; /* Main Program */ int main (void) { uint32_t interval; SystemCoreClockUpdate(); /* Config CLKOUT, mostly used for debugging. */ CLKOUT_Setup( CLKOUTCLK_SRC_MAIN_CLK ); LPC_IOCON->PIO0_1 &= ~0x07; LPC_IOCON->PIO0_1 |= 0x01; /* CLK OUT */ /* Enable AHB clock to the GPIO domain. */ LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6); /* TEST_TIMER_NUM is either 0 or 1 for 16-bit timer 0 or 1. */ interval = SystemCoreClock/1000 - 1; if ( interval > 0xFFFF ) { interval = 0xFFFF; } init_timer16(TEST_TIMER_NUM, interval); enable_timer16(TEST_TIMER_NUM); /* Set port 0_7 to output */ GPIOSetDir( 0, 7, 1 ); while (1) /* Loop forever */ { #if TEST_TIMER_NUM /* I/O configuration and LED setting pending. */ if ( (timer16_1_counter[0] > 0) && (timer16_1_counter[0] <= 200) ) { GPIOSetBitValue( 0, 7, 0 ); } if ( (timer16_1_counter[0] > 200) && (timer16_1_counter[0] <= 400) ) { GPIOSetBitValue( 0, 7, 1 ); } else if ( timer16_1_counter[0] > 400 ) { timer16_1_counter[0] = 0; } #else /* I/O configuration and LED setting pending. */ if ( (timer16_0_counter[0] > 0) && (timer16_0_counter[0] <= 200) ) { GPIOSetBitValue( 0, 7, 0 ); } if ( (timer16_0_counter[0] > 200) && (timer16_0_counter[0] <= 400) ) { GPIOSetBitValue( 0, 7, 1 ); } else if ( timer16_0_counter[0] > 400 ) { timer16_0_counter[0] = 0; } #endif } }I compiled it but it does not seem to work. I tried to change the pin in the code and other things but it seems like it is not so easy.
Is it possible to compile this code with the online compiler of mbed and to upload it on my board? Or am I missing somthing?
Any hint?
thanks.