I'm new to this mikroc software and programming. Could you please provide me a sample code to transmit a character using UART in PIC18F65K40.
Is there any difference between pic18f65k40 and pic18f65k22 in terms of initiating uart transmission? Whether there is any need to initiate or disable any special registers in pic18f65k40? In mikroc software there present a library for uart so i just copied the code from your website and add my transmitter and receiver pins in program but my circuit doesnot working.
Code: Select all
char i ;
void main()
{
TRISC = 0x00; // making port as output
RX4PPS = 0x11;
TX4PPS = 0x10;
UART4_Init(9600); // Initialize USART module
// (8 bit, 9600 baud rate, no parity bit...)
delay_ms(2000);
UART4_Write_Text("Hello world!");
UART4_Write(13); // Start a new line
UART4_Write(10);
UART4_Write_Text("PIC18F65K40 UART example");
UART4_Write(13); // Start a new line
UART4_Write(10);
while (1) {
if (UART4_Data_Ready()) { // If data has been received
i = UART4_Read(); // read it
UART4_Write(i); // and send it back
}
}
}