Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

making UART Intterupts work

making UART Intterupts work

2004-05-28 by Owen Mooney

I have found the problem with the Uart interupts - there is a 
shortcomming in the phiilps documentation as follows:

Note that Interrupts must be disabled while setting up the UART. That 
is, set the Interupt enable bit in IER  AFTER DLAB is disabled.

Hope this stops someone wasting a day like I just have.

Typical uart setup code would be as follows:


void UART0Initialize(unsigned int baud) {
  unsigned int divisor = PERIPHERAL_CLOCK_FREQUENCY / (16 * baud);
  // setup interrupt vectors
  VICIntSelect &= ~0x40; 
  VICIntEnable = 0x40;
  VICVectCntl2 = 0x26;
  VICVectAddr2 = (unsigned int)UART0ISR;

  U0IER = 0;            // Disable Interrupts
  PINSEL0 = PINSEL0 | 0x5;
  U0FCR = 7;           // enable and reset buffers
  U0LCR = 0x83;        // 8 bit, 1 stop bit, no parity, enable DLAB */
  U0DLL = divisor & 0xFF;
  U0DLM = (divisor >> 8) & 0xFF;
  U0LCR &= ~0x80;      // Disable DLAB
  U0IER = 1;           // Interrupt on rx data available
}

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.