Okada
Banned
I want to know whether the information provided here is correct.
https://www.microcontrollerboard.com/pic_serial_communication.html
I am using this code but I don't see any data on UART. UART is not working at all.
I am using PIC16F877A with 4 MHz Crystal
_XTAL_FREQ is defined as 4000000
Connections are correct because I am using EasyPIC v7 development board.
If I use mikroC PRO PICs UART library functions then it is working but using the above code it is not working. Crystal frequency is XT 4 MHz.
https://www.microcontrollerboard.com/pic_serial_communication.html
I am using this code but I don't see any data on UART. UART is not working at all.
I am using PIC16F877A with 4 MHz Crystal
_XTAL_FREQ is defined as 4000000
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 void UART1_Init(unsigned int baudrate) { //SPBRG value for high baudrate SPBRG = ((_XTAL_FREQ) / (baudrate * 16)) - 1; BRGH_bit = 1; //setting high baudrate SYNC_bit = 0; //setting Asynchronous mode for UART SPEN_bit = 1; //enable Serial Port CREN_bit = 1; //enable Continuous Reception TXEN_bit = 1; //enable Transmission } void UART1_Write(char data_) { TXREG = data_; while(!TRMT_bit)asm clrwdt; } void UART1_Write_Text(char *text) { while(*text) { UART1_Write(*text++); asm clrwdt } } char UART1_Read() { while(!RCIF_bit)asm clrwdt; return RCREG; } UART1_Init(9600); Delay_ms(200); UART_Write_Text("Hello!");
Connections are correct because I am using EasyPIC v7 development board.
If I use mikroC PRO PICs UART library functions then it is working but using the above code it is not working. Crystal frequency is XT 4 MHz.
Last edited: