Tool/software: Code Composer Studio
void init_uart0(void)
{
volatile unsigned char rx_byte;
Uart0Regs.UARTCTRL3.bit.SW_RESET = 0; //software reset while initializing UART
Uart0Regs.UARTCTRL0.bit.DATA_SIZE = 7; //8 bits
Uart0Regs.UARTCTRL0.bit.STOP = 1; //2 stop bits
Uart0Regs.UARTCTRL0.bit.SYNC_MODE = 1; //asynchronous mode
Uart0Regs.UARTHBAUD.bit.BAUD_DIV_H = 0;
Uart0Regs.UARTMBAUD.bit.BAUD_DIV_M = 0;
Uart0Regs.UARTLBAUD.bit.BAUD_DIV_L = 49; //for 38400 //47 for control board, 44 for open loop
Uart0Regs.UARTRXST.bit.RX_ENA = 1 ;//enable RX
Uart0Regs.UARTTXST.bit.TX_ENA = 1;//enable TX
Uart0Regs.UARTINTST.all = 0xff; //these two statements are supposed to clear the status bits
Uart0Regs.UARTINTST.all = 0;
rx_byte = Uart1Regs.UARTRXBUF.bit.RXDAT; //clear RXRDY flag
Uart0Regs.UARTIOCTRLTX.bit.IO_FUNC = 1; //enable transmit pin
Uart0Regs.UARTIOCTRLRX.bit.IO_FUNC = 1; //enable receive pin
Uart0Regs.UARTCTRL3.bit.CLOCK = 1; //internal clock select;
Uart0Regs.UARTCTRL3.bit.SW_RESET = 1; //software reset released UART init done?
Uart0Regs.UARTIOCTRLSCLK.bit.IO_FUNC = 0; //disable external clock for UART.
Uart0Regs.UARTTXBUF.all = ' '; //put out a byte to get things started.
}
void char_out_0(char data)
{
volatile char rx_byte;
while(Uart0Regs.UARTTXST.bit.TX_RDY == 0)
{
if(Uart0Regs.UARTRXST.bit.RX_RDY == 1)
{
rx_byte = Uart0Regs.UARTRXBUF.bit.RXDAT; //clear RXRDY flag
}
pmbus_handler();
}
Uart0Regs.UARTTXBUF.all = data; //put out a byte
}
**************************************************************************************************
sir above code for uart0, Sir i want a code for uart1 so that i want to send my char "At command"to my wifi please can you send me the initialisation or code please. above code creating problem error after certain changes had been done.