uint8_t key; uint32_t clk, i; uint32_t baudRate = 115200; const uint32_t UARTCLKDIV = 1; /* Enable IOCON clock */ LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 18); /* Setup the clock and reset UART0 */ LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 14)|(1 << 15)|(1 << 16); LPC_SYSCON->PRESETCTRL &= ~(1 << 3); LPC_SYSCON->PRESETCTRL |= (1 << 3); LPC_SYSCON->PRESETCTRL &= ~(1 << 2); LPC_SYSCON->PRESETCTRL |= (1 << 2); NVIC_DisableIRQ(UART0_IRQn); /* Enable the clock to the Switch Matrix */ LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 7); ///* Pin Assign 8 bit Configuration */ ///* U0_TXD */ ///* U0_RXD */ //LPC_SWM->PINASSIGN0 = 0xffff0004UL; // ///* Pin Assign 1 bit Configuration */ ///* SWCLK */ ///* SWDIO */ ///* RESET */ //LPC_SWM->PINENABLE0 = 0xffffffb3UL; /* Pin Assign 8 bit Configuration */ /* U1_TXD */ LPC_SWM->PINASSIGN1 = 0xffff0fffUL; /* Pin Assign 1 bit Configuration */ /* SWCLK */ /* SWDIO */ /* RESET */ LPC_SWM->PINENABLE0 = 0xffffffb3UL; LPC_SYSCON->UARTCLKDIV = UARTCLKDIV; /* Configure UART0 */ clk = __MAIN_CLOCK / UARTCLKDIV; LPC_USART1->CFG |= (1<<2); LPC_USART1->BRG = clk / 16 / baudRate - 1; LPC_SYSCON->UARTFRGDIV = 0xFF; LPC_SYSCON->UARTFRGMULT = (((clk / 16) * (LPC_SYSCON->UARTFRGDIV + 1)) / (baudRate * (LPC_USART1->BRG + 1))) - (LPC_SYSCON->UARTFRGDIV + 1); /* Clear the status bits */ LPC_USART1->STAT = (1<<5) | (1<<11); /* Enable UART0 */ LPC_USART1->CFG |= (1<<0); while (1) { for (key = 0x30; key <= 0x40; key++) { /* Wait until we're ready to send */ while (~LPC_USART1->STAT & (1<<2)) ; LPC_USART1->TXDATA = key; while (~LPC_USART1->STAT & (1<<3)) ; } } |
while ((LPC_USART1->STAT & (1<<2)) == 0) |
/* Wait until we're ready to send */ while ( ~( LPC_USART1->STAT & (1<<2) ) ) ; LPC_USART1->TXDATA = key; while ( ~( LPC_USART1->STAT & (1<<3) ) ) ; |
/* Wait until we're ready to send */ while ( ~( LPC_USART1->STAT & (1<<2) ) ) ; LPC_USART1->TXDATA = key; while ( ~( LPC_USART1->STAT & (1<<3) ) ) ; |