I am trying to use ARDUINO serial monitor for my PIC microcontroller for debugging purpose, by connecting TX and RX pins of PIC with ARDUINO, I wrote the code for PIC16f877A, which indeed has hardware USART module, using Mikroc compiler, the oscillator frequency is 4MHz, This is working fine when I try to simulate in Proteus, the output is visible both on Serial monitor (Inside Proteus) and also on another microcontroller that I used as receiver for UART but I am unable to get this thing working between PIC and Arduino Uno Physically. The screen (Arduino IDE serial monitor) remains blank.
This is the code of PIC transmitter using UART library of Mikroc :
char test[]="Test string Incoming \n";
char *p1;
void main()
{
UART1_init(9600); //initializing USART module with 9600 baud rate
delay_ms(100);
while(1){
p1=test;
while(*p1){UART1_Write(*p1); p1++ ; delay_ms(100);} // writing character one by one on serial transmitter pin
}
}
and This is the code for Arduino Uno which will be acting as a receiver, and then transmit the received character to Serial monitor:
char byt;
void setup() {
Serial.begin(9600);
Serial.println("This is uart test!");
}
void loop() {
if (Serial.available()){
byt= Serial.read();
if (byt==' ') Serial.println();
else Serial.print(byt);
}
}
This is the code for another PIC16F877A that I used as receiver in Proteus simulation.
sbit lcd_rs at rb2_bit;sbit lcd_en at rb3_bit;sbit lcd_d4 at rb4_bit; sbit lcd_d5 at rb5_bit; sbit lcd_d6 at rb6_bit; sbit lcd_d7 at rb7_bit;
sbit lcd_rs_direction at trisb2_bit; sbit lcd_en_direction at trisb3_bit; sbit lcd_d4_direction at trisb4_bit;
sbit lcd_d5_direction at trisb5_bit; sbit lcd_d6_direction at trisb6_bit; sbit lcd_d7_direction at trisb7_bit;
char ch;
void main()
{
lcd_init();
lcd_cmd(_lcd_clear);
lcd_cmd(_lcd_cursor_off);
lcd_out(1,1,"This is UART test!");
UART1_init(9600);
while(1)
{
if (UART1_Data_Ready)
{ ch=UART1_Read();
lcd_chr(2,1,ch);}
}
}
Does anyone have any idea regarding this?