ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Вторник
26 ноября
66547 Топик полностью
0men (24.08.2006 19:38, просмотров: 1) ответил igor_m на помогите поднять прерывания от uart для lpc2138 - пишу на иаре 4.31. где взять готовый рабочий проект ? (с iar.se уже всё испробовал)
Чего там поднимать? 
#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 )
{
    // 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_UART0);                // IRQ on UART0 line.
    VICVectAddr1 = (unsigned long)Uart0Interrupt;   // Channel 1 of VIC - UARTO interrupt
    VICVectCntl1 = 0x20 | VIC_UART0;                // Enable vector interrupt for UART0 on channel 1 and set his type.
    VICIntEnable |= (1<<VIC_UART0);                 // Enable UART0 interrupt.

}

void Uart0Interrupt( void )
{
    unsigned char t;
    TransmitByte( ReceiveByte() );
    t = U0IIR;
}

void UART_init( void )
{
// 115200
    U0LCR = 0x83;
    U0DLL = 40;
    U0DLM = 0;
    U0LCR &= ~0x80;
    PINSEL0 |= 0x5; // &Acirc;&ecirc;&euml;. RxD TxD &ocirc;&oacute;&iacute;&ecirc;&ouml;&egrave;&egrave; &iuml;&egrave;&iacute;&icirc;&acirc;
    U0FCR = 0x01;

    U0IER = 0x01;
}


и усе