ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Воскресенье
24 ноября
69442 Топик полностью
0men (19.09.2006 17:29, просмотров: 1) ответил smartleds на Народ помогите разобраться с внешним прерыванием у LPC2138
Короче, должно быть так 
#pragma vector=IRQV
__irq __arm void irq_handler(void)
{
    void (*interrupt_function)();
    unsigned int vector;

    vector = VICVectAddr;   // Get interrupt vector.
    interrupt_function = (void(*)())vector;
    (*interrupt_function)();  // Call vectored interrupt function.

    VICVectAddr = 0;    // Clear interrupt in VIC.
}


void LPC21xxInitInterrupt( void )
{
    EXTMODE |= 0x01; // EINT0 по перепаду
    EXTINT |= 0x01;
    PINSEL1 |= 0x01; // вкл. EINT0 функции пина P0.16

    // Assign all interrupt chanels to IRQ
    VICIntSelect  =  0;
    // Diasable all interrupts
    VICIntEnClear = 0xFFFFFFFF;
    // Clear all software interrutps
    VICSoftIntClear = 0xFFFFFFFF;
    // VIC registers can be accessed in User or privileged mode
    VICProtection = 0;
    // Clear interrupt
    VICVectAddr = 0;
    // Clear address of the Interrupt Service routine (ISR) for non-vectored IRQs.
    VICDefVectAddr = 0;

    // Clear address of the Interrupt Service routine (ISR) for vectored IRQs.
    VICVectAddr0  = \
    VICVectAddr1  = \
    VICVectAddr2  = \
    VICVectAddr3  = \
    VICVectAddr4  = \
    VICVectAddr5  = \
    VICVectAddr6  = \
    VICVectAddr7  = \
    VICVectAddr8  = \
    VICVectAddr9  = \
    VICVectAddr10 = \
    VICVectAddr11 = \
    VICVectAddr12 = \
    VICVectAddr13 = \
    VICVectAddr14 = \
    VICVectAddr15 = 0;

    // Disable all vectored IRQ slots
    VICVectCntl0  = \
    VICVectCntl1  = \
    VICVectCntl2  = \
    VICVectCntl3  = \
    VICVectCntl4  = \
    VICVectCntl5  = \
    VICVectCntl6  = \
    VICVectCntl7  = \
    VICVectCntl8  = \
    VICVectCntl9  = \
    VICVectCntl10 = \
    VICVectCntl11 = \
    VICVectCntl12 = \
    VICVectCntl13 = \
    VICVectCntl14 = \
    VICVectCntl15 = 0;


    VICIntSelect &= ~(1<<VIC_EINT0);                // IRQ on EINT0 line.
    VICVectAddr2 = (unsigned long)IntegrationComplete;	// Channel 2 of VIC - EINT0 interrupt
    VICVectCntl2 = 0x20 | VIC_EINT0;                // Enable vector interrupt for EINT0 on channel 2 and set his type.
    VICIntEnable |= (1<<VIC_EINT0);                 // Enable EINT0 interrupt.
}

void IntegrationComplete( void )
{
// бла бла
}