First test - LED2 is always on

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

First test - LED2 is always on

810件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lucretia on Sat Mar 19 10:50:20 MST 2011
Hi,

I'm managing to get somewhere, slowly. I have the following code:

#define LED (1L << 22)
//0x00400000

#define DELAY 10

int main(void) {
    
    // TODO: insert code here

    LPC_PINCON->PINSEL0 &= (!0x00003000);
    LPC_GPIO0->FIODIR = LED;

    volatile static int i = 0 ;

    while (1)
    {
        LPC_GPIO0->FIOCLR = LED;

        for (i = 0; i < DELAY; i++) ;

        LPC_GPIO0->FIOSET = LED;

        for (i = 0; i < DELAY; i++) ;
    }

    return 0 ;
}
Which, when I step through turns LED2 off and then back on again. But if I let it run, LED2 is always on.

Is there something I'm missing here?

From putting the USB plug into the board the first time, this LED has always been on, is this to show that the power is on?

Thanks,
Luke.
0 件の賞賛
返信
2 返答(返信)

802件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ajay on Sat Mar 19 11:14:41 MST 2011
Try increasing the delay (say 0x04000000).  Decimal 10 is awful short and you will not see the led turn off in that short of a duty cycle.
0 件の賞賛
返信

802件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lucretia on Sat Mar 19 11:13:20 MST 2011
Ah, changed my delay to 500000 and now have the LED on the board and an LED on pin 24 flashing!

I did actually mess around with the delay to start with, I just obviously, didn't go high enough as when stepping over the loop, the loop seemed to take ages!

Yay,
Luke.
0 件の賞賛
返信