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 = 0x55; // 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 = 0x55; // 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 = 0x00000000; // 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.

3 Comments:

  1. hai,
    Do u have abstract of INTERFACING OF GRAPHICAL LCD(128X64) TO LPC2148 (ARM7) BASED 32 BIT MICROCONTROLLER.

  2. Hi i’m totally new to programming. Are the codes written above is in C language? Or is it assembly? I’m really confuse between these two.

  3. Pingback: How to define port in LPC2148???

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.