- Transmition Line (Tx)
- Receiving Line (Rx)
- Common Ground (GND)
First consider the µController side.
Sample code given in MikroC will be a good start. But remember these things:
Usart_Write('I');
Usart_Write('C');
// this will send a word 'PIC' through USART
There are some string functions in C, which you can use to send words easily. These functions will ultimately call Usart_Write(char c) repeatedly to transmit the string data.
For Numbers:
Usart_Write(255);
Usart_Write(2);
// this will send the number in binary format.
Max. limit is 255 or 0xFF
unsigned char arr_data[5];
unsigned short i;
i = 0;
do {
if (Usart_Data_Ready()) {
arr_data(i) = Usart_Read();
i += 1; // increase i for the next step
}
} while (i<5);
Now let's have a quick look at PC side.
- MikroC include a USART terminal (short cut ctrl+T). First use this tool to visualize the data sent by PIC.
- If this is success only, move to the next step.
- See my blog on USART communication with Visual Basic 6.0 to create your custom user interface.