First LPC2148 ARM7 microcontroller test–led blink

This is simple led blinking routine using my development board. The compiler I used was WINARM. I like this compiler because its free and adaptation is easy while the same functionality is in WINAVR. This simple test just blinks pin 16 of port 0. This I used when I first got to know ARM microcontroller.

Here is the main code:

/*************************************************

* WinARM Demo P0.16 blink

**************************************************/

#include “types.h”

#include “LPC214x.h”

#include “config.h”

#include “armVIC.h”

#define IOPINS016 16

static void lowInit(void)

{

// set PLL multiplier & divisor.

// values computed from config

PLLCFG = PLLCFG_MSEL | PLLCFG_PSEL;

// enable PLL

PLLCON = PLLCON_PLLE;

PLLFEED = 0xAA; // Make it happen. These two updates

PLLFEED = 0×55; // MUST occur in sequence.

// setup the parallel port pin

IO0CLR = (1<

IO0SET &= ~(1<

IO0DIR =(1<

// wait for PLL lock

while (!(PLLSTAT & PLLSTAT_LOCK))

continue;

// enable & connect PLL

PLLCON = PLLCON_PLLE | PLLCON_PLLC;

PLLFEED = 0xAA; // Make it happen. These two updates

PLLFEED = 0×55; // MUST occur in sequence.

// setup & enable the MAM

MAMTIM = MAMTIM_CYCLES;

MAMCR = MAMCR_FULL;

// set the peripheral bus speed

// value computed from config.h

VPBDIV = VPBDIV_VALUE; // set the peripheral bus clock speed

}

/**/

static void sysInit(void)

{

lowInit(); // setup clocks and processor port pins

// set the interrupt controller defaults

#if defined(RAM_RUN)

MEMMAP = MEMMAP_SRAM; // map interrupt vectors space into SRAM

#elif defined(ROM_RUN)

MEMMAP = MEMMAP_FLASH; // map interrupt vectors space into FLASH

#else

#error RUN_MODE not defined!

#endif

VICIntEnClear = 0xFFFFFFFF; // clear all interrupts

VICIntSelect = 0×00000000; // clear all FIQ selections

VICDefVectAddr = (uint32_t)reset; // point unvectored IRQs to reset()

}

static void _delay(uint32_t N)

{

for (uint32_t i=0; i

}

int main(void)

{

sysInit();

for (;;)

{

IO0CLR = (1<

_delay(900000);

IO0SET = (1<

_delay(900000);

}

return 0;

}

All project files and compiled hex file is in LPC2148.zip.

Blogsphere: TechnoratiFeedsterBloglines
Bookmark: Del.icio.usSpurlFurlSimpyBlinkDigg
RSS feed for comments on this post
 |  TrackBack URI for this post

New on WinAVR Tutorial
Running TX433 and RX433 RF modules with AVR microcontrollers,
Sometimes in embedded design you may want to go wireless. Might be you will want to log various readi …
Programming AVR ADC module with WinAVR,
Most of AVR microcontrollers have Analog to Digital Converter (ADC) integrated in to chip. Such solut …
New on WinARM Tutorial
What are differences between WinARM and WinAVR,
Everyone who is working with AVR microcontrollers knows this powerful tool – WinAVR (http://win …
LPC2000 watchdog timer,
As in all microcontrollers watchdog timers purpose isto reset microcontroller after reasonable amount …

Leave a Reply