2008-06-07 02:22 AM
2011-05-17 12:53 AM
Hi,
Now I am using the sample code as listed bellow to test the UART port on the MCB-STR9 Eval board V2.0. It doesn't work at all. Do anyone know why? Thanks eyang ////////// #include void com_baudrate (unsigned int baudrate) { unsigned long BRDi = 0, BRDf = 0; unsigned long long UARTClk = 48000000; if ((SCU->CLKCNTR & SCU_BRCLK_Div2) != SCU_BRCLK_Div2) { UARTClk /= 2; /* set UART Clock acc. BRSEL */ } /* baudrate calculation */ BRDi = ((100 * UARTClk) / (16 * baudrate)); /* calculate the integer part */ BRDf = BRDi - (100 * (BRDi / 100)); /* calculate the fractal part */ UART0->CR &= 0xFFFE; /* disable UART */ UART0->IBRD = BRDi / 100; /* set the integer part */ UART0->FBRD = ((((BRDf * 64) + 50) / 100)); /* set the fractal part */ UART0->LCR &= 0xFFFF; /* to accept baudrate */ UART0->CR |= 0x0001; /* enable UART */ } void init_serial (void) { /* Initialize Serial Interface */ /* UART0 Setup.....................................................*/ SCU->GPIOOUT[3] = 0x0008; /* P3.1 output UART0 TX */ SCU->GPIOIN[3] = 0x01; /* P3.0 input UART0 RX */ UART0->LCR = UART_WordLength_8D /* 8 bits */ | UART_Parity_No /* no Parity */ | UART_HardwareFlowControl_None /* no flow control */ & UART_StopBits_1 /* 1 Stop bit */ & UART_FIFO_Disable; /* FIFO disabled */ UART0->CR = UART_Mode_Rx /* Receive Enable */ | UART_Mode_Tx /* Transmit Enable */ | 0x0001; /* UART Enable */ com_baudrate (115200); /* 115200 Baud */ } /* implementation of putchar (also used by printf function to output data) */ int sendchar (int ch) { /* Write character to Serial Port */ if (ch == '\n') { while ((UART0->FR & 0x0020)); /* TX Fifo Full */ UART0->DR = 0x0D; /* output CR */ } while ((UART0->FR & 0x0020)); return (UART0->DR = ch); }2011-05-17 12:53 AM
There is hardware bug in MCB-STR9 V2.0. – UART0 / COM1 could not be used.
Take a look here: