Hi All, I'm running ARTX kernel and I want to use UART0 to send some data. When I call putchar() it sends the first char and system hangs. U0IIR says interrupt pending (bit0=0) and this is THRE interrupt (U0IIR=0xC2). Program does not executes after calling putchar(). Please help, Here is the init, putchar and interrupt vector from serial.c (It was originally for UART1 and I modified it to use UART0.) /* INIT SERIAL*/
void serial_init (void) { // PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */ PINSEL0 |= 0x00000005; /// UART0 U0FCR=0x01; ///Enable FIFOS and reset U0LCR = 0x83; /// DLAB =1 U0DLL = 0x20; /// 115200 baud U0DLM = 0x00; U0LCR = 0x03; /// 8 bits, no Parity, 1 Stop bit ve DLAB=0 yapılıyor */ U0IER = 0x03; /// Enable RDA and THRE interrupts */ VICVectAddr14 = (U32)int_serial; /// 14th vector is serial interrupt VICVectCntl14 = 0x27; /// enable vect14 and assign IRQ number 7 VICIntEnable |= 0x80; /// IRQ 7 enable sendstop = 0; /* CtrlQ not received */ ridx = widx = 0; /* clear buffer indexes */ }
/*---------------*/ /*-------Interrupt Vector--------*/
/*------ I have commented receive side but I read U0IIR to clear reset
---------*/ void int_serial (void) __irq { U8 c; c=U0IIR; ///for test only. will be deleted later /* if ((U0IIR & 0x0E) == 0x04) { /// Receive interrupt . Clears flags c = (char) U0RBR; /// read character
switch (c) { /// process character
case CTRL_S: sendstop = 1; /// if Control+S stop transmission goto ack;
case CTRL_Q: if (sendstop) { /// if Control+Q start transmission sendstop = 0; } break;
default: /// send character to a mailbox
recbuf[widx++] = c; isr_evt_set (0x0100, rd_task);/// set event character received
goto ack; }
} */ /// Transmit interrupt
isr_evt_set (0x0100, wr_task); /// Go on, set event transmit ready
//ack: VICVectAddr = 0; /// Acknowledge Interrupt
}
/*-------PUTCHAR--------*/
int putchar (int c) { wr_task = os_tsk_self (); /* identify task for serial interrupt */ os_evt_clr (0x0100, wr_task); /* if (c == '\n') { /// expand new line character: U0THR = (char)'\r'; os_evt_wait_or (0x0100, 0xfffe); /// wait till character transmited } */ U0THR = (char)c; /// transmit a character U0THR = (char)c; /// transmit a character
os_evt_wait_or (0x0100, 0xfffe); /// wait till character transmited return (c); /// return character: ANSI requirement }
Device is never get into the interrupt vector. I think THRE interrupt is not working.