microcontroller - UART in LPC1778 not working -
i trying send byte using uart1
in lpc1778
(i'm using keil simulator).
however i'm not able send byte; after detailed debugging, came conclusion data not getting written in uart1->thr
register.
this code snipped transmission:
void uart1_tra(uint8_t x) { lpc_uart1->thr=x; //after line ,irrespective of value of x, uart1->thr remains @ value equal 0 while(1) { if(lpc_uart1->lsr&(1<<5)) { break; } } }
initialization code:
void uar1_init(void) { lpc_sc->pconp|=1u<<4; lpc_sc->pclksel|=1u; lpc_uart1->lcr|=1u<<7; lpc_uart1->dll|=0x05; //set baud rate lpc_uart1->fdr|= 0x21; //end of baud rate calculations lpc_uart1->lcr&=~(1u<<7);//disable dlab lpc_uart1->lcr|=3u;//8-bitcharacter length lpc_uart1->fcr|=1u; //enable fifo reg lpc_uart1->fcr|=(0x03<<1);//reset rxbuffers //lpc_uart1->ier|=3u;//to enable interrupts lpc_iocon->p0_15|=1u; lpc_iocon->p0_16|=1; }
Comments
Post a Comment