Re: how to connect tow pic with usart by using mickroC compiler
If connect UART between PIC to PIC, just use TTL level, no need to convert to RS232.
TX first PIC connect to RX second PIC.
RX first PIC connect to TX second PIC.
Then, you learn how to code UART transmit and receive.
thank you for you help
i had seen the example and tried to do like it but with no luck
what is killing me is how can i transmit and receive my program (the code that i have written) by using this usart
---------- Post added at 11:57 ---------- Previous post was at 11:53 ----------
If connect UART between PIC to PIC, just use TTL level, no need to convert to RS232.
TX first PIC connect to RX second PIC.
RX first PIC connect to TX second PIC.
Then, you learn how to code UART transmit and receive.
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
UART1_Write_Text("Start");
while (1) { // Endless loop
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read(); // read the received data,
UART1_Write(uart_rd); // and send data via UART
}
}
}
?
If you have any problem with your code please post it
thank you for you help
i had seen the example and tried to do like it but with no luck
what is killing me is how can i transmit and receive my program (the code that i have written) by using this usart
bigdogguru , john blue i really appreciate your help and i really did fine your links very helpful
what am trying to build is a remote control circuit for my robot with two pic (transmitter & receiver) , so i used a RF circuit (for transmitting & receiving) wirelessly
and this RF circuit transmit & receive data via serial port USART
my code is so simple all what i want to know how can I use mikroC compiler library to send my code via usart port and the second pic will understand this data
i will write simple code which control the direction of my robot, and i want from you so kindly to add to it a USART library
//USART direction control
void main() {
trisa=15; //make porta as input a1...a3
trisb=0; //make portb as output
while(1){
if (porta.f0==1)portb.f0=1; //move forward
if (porta.f1==1)portb.f1=1; //move backwoard
if (porta.f2==1)portb.f2=1; //move left
if (porta.f3==1)portb.f3=1; //move right
}
}