본문 바로가기

[AnalogDevice]/ADuc7K

[Aduc7024 EVM]외부인터럽트 예제 테스트

 [Aduc7024 EVM]외부인터럽트 예제

  

외부 인터럽트발생(스위치)시  LED를 On/Off하는 예제를 테스트 했다.



예제소스

//=============================================================================

// [Aduc7024] Evm Test Program

//

// by http://cafe.naver.com/elab

//=============================================================================

/*

 - Adcu7024 EVM Basic Test

  - EX0 인터럽트 발생시 P3 -> LED에 연결된 LED를 On/Off하는 프로그램

*/

#include <ioaduc7024.h>

//-----------------------------------------------------------------------------

//LED Test Futicion

#define Led1On()                (GP3SET = 0xFFFFFFFF)

#define Led1Off()               (GP3CLR = 0xFFFFFFFF)

void InitLed(void)

{

    GP3CON = 0x0;

    GP3DAT = 0xFFFFFFFF;   

}

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

//Simple System Delay

void Delay(void)

{

   volatile int iDelay = 0x1FFFF;

   while (iDelay--);

}

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

int m_flag = 0;

__irq __arm void irq_handler(void);                    //      IRQ Function Prototype

//IRQ Handler

__irq __arm void irq_handler(void)           

{

        m_flag ^= 1;

       

        if(m_flag)Led1On();

        else Led1Off();

        return ;

}

//-----------------------------------------------------------------------------

int main (void) 

{

    //   Enable XIRQ0 in IRQEnable

        IRQEN = XIRQ0_BIT;                               

    InitLed();

        while(1)

        {

        }

}

반응형