#include "LPC11xx.h" //PIO1_7 TXD pin void uart_init(void) { LPC_IOCON->PIO1_7 |= (1 << 0); //Select TXD function for GPIO1_7 LPC_IOCON->PIO1_7 &= ~(1 << 4);//Disable internal pull up resistor on GPIO1_7 LPC_UART->LCR |= (1 << 7);//Set DLAB, to configure u0dll u0dlm LPC_UART->DLL |= 4; LPC_UART->DLM |= 0; LPC_UART->LCR &= ~(1 << 7);//Clear DLAB for normal operation LPC_UART->FDR |= 0b0101;//Set DIVADDVAL = 5 LPC_UART->FDR |= 0b10000000;//Set MULVAL = 8 LPC_UART->FCR =1;//Enable uart FIFO LPC_UART->LCR |= 0x03;//Select 8-bit data LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 12);//Enable uart LPC_SYSCON->UARTCLKDIV = 26;//Enable peripheral clock, UARTCLKDIV for 115200 bit/s baud LPC_UART->TER |= (1 << 3);//Enable transmit } int main(void) { uart_init(); while( (LPC_UART->LSR & 0x00000020) == 0x00000000){}//While bit 5 THRE in U0LSR is 0 -> containts data -> wait LPC_UART->LCR &= ~(1 << 7);//Clear DLAB for normal operation LPC_UART->THR = 85; while (1) { } } |