Getting started with Blinky

Hi, there,

I am new to ARM and just downloaded MDK3.70 demo to try to get Blinky to run on lpc2106.

I set up uvision3, and wired up the schematic in Proteus (7.1), since I already downloaded an almost identical program there - with a .hex file. the program is to flash LEDs linked to P0.0-P0.7. The Proteus simulation, with the pre-made .hex file, worked well.

so I decided to produce my own .hex file in uvision3, see below.

=========code===========
#include <LPC210x.H> /* LPC210x definitions */

void wait (void) { /* wait function */ ; /* only to delay for LED flashes */
}

int main (void) {
// unsigned int i; /* Delay var */
// unsigned int j; /* LED var */

PINSEL0=0x00; IODIR = 0xFF; // P0.0..7 defined as Outputs */

while (1) { IOSET=0xff; //?? IOCLR=0xff; }
}

========end of code==============

I didn't put the wait() function there for simplicity.

well, uvision did produce a .hex file. I loaded the file to the proteus simulation, and replaced the pre-made .hex. no go. all ports are in high impedance mode and nothing happened.

I would appreciate very much if you can point me in the right direction. I am thinking the problem is likely caused by my uvision not producing the right .hex file (wrong settings somewhere?) but I am not sure where to start.

your help is greatly appreciated. Thanks.

Parents
  • Ashely,
    I guess your LEDs are blinking so fast that you just don't see them fluctuate. Write your 'wait' function in assembly or use a hardware timer to poll to generate the desired delay.
    here is an example:

    // time measurement in microseconds for an LPC2478 running at 72[MHz]. use for short delays only that depend
    // only on the speed of the processor.
    #define MICROSECONDS(x)                         (x*15)
    
    // for an LPC2478 running at 72[MHz]
    // delays execution by at least the specified number of microseconds
    // use the macro 'MICROSECONDS' to specify the desired delay
    // this is a blocking call; it returns only after the delay has elapsed
    // if you need to do something during the delay period, do not use this function but
    // use the following construct:
    
    // l_time_ref = T2TC ;
    //
    // do
    // {
    // }
    // while ( (int32u)(T2TC - l_time_ref) < (int32u)T2_50_MICROSECONDS) ;
    //
    // or 'g_timers', but then you are limited to the resolution of TIM2
    __asm void delay(int32u a_microseconds)
    {
            STMDB   R13!, {R0 - R1}
    
    loop
            MOVS    R1, R0
            SUB     R0, R0, #1
            BNE     loop
    
            LDMIA   R13!, {R0 - R1}
    
            BX      LR
    }
    

Reply
  • Ashely,
    I guess your LEDs are blinking so fast that you just don't see them fluctuate. Write your 'wait' function in assembly or use a hardware timer to poll to generate the desired delay.
    here is an example:

    // time measurement in microseconds for an LPC2478 running at 72[MHz]. use for short delays only that depend
    // only on the speed of the processor.
    #define MICROSECONDS(x)                         (x*15)
    
    // for an LPC2478 running at 72[MHz]
    // delays execution by at least the specified number of microseconds
    // use the macro 'MICROSECONDS' to specify the desired delay
    // this is a blocking call; it returns only after the delay has elapsed
    // if you need to do something during the delay period, do not use this function but
    // use the following construct:
    
    // l_time_ref = T2TC ;
    //
    // do
    // {
    // }
    // while ( (int32u)(T2TC - l_time_ref) < (int32u)T2_50_MICROSECONDS) ;
    //
    // or 'g_timers', but then you are limited to the resolution of TIM2
    __asm void delay(int32u a_microseconds)
    {
            STMDB   R13!, {R0 - R1}
    
    loop
            MOVS    R1, R0
            SUB     R0, R0, #1
            BNE     loop
    
            LDMIA   R13!, {R0 - R1}
    
            BX      LR
    }
    

Children
More questions in this forum