Simple PIC to PIC UART problem mikroC

Discussion in 'Embedded Systems and Microcontrollers' started by lloydi12345, Dec 8, 2010.

  1. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    Hi, My circuit is not working properly on Proteus. Can you help me with my code? I think I have alot of mistake because I'm not yet familiar with mikroC.

    Here's my code.

    Transmitter:

    Code ( (Unknown Language)):
    1. void main() {
    2.           ADCON1 = 6;
    3.  
    4.           UART1_Init(9600);           // initialize USART module
    5.           while(1){                               //  (8 bit, 9600 baud rate, no parity bit...)
    6.           UART1_Write(0x0F);    //make RB0-RB3 light
    7.           Delay_ms(100);
    8.          
    9.           UART1_Write(0xF0);     //make RB4-RB7 light
    10.           Delay_ms(100);
    11.           }
    12. }
    Receiver:

    Code ( (Unknown Language)):
    1. unsigned char i;
    2.  
    3. void main(){
    4.       adcon1 = 6;
    5.       trisd = 0;
    6.  
    7.             while(1){
    8.                      if (UART1_Data_Ready()) {
    9.                      i = UART1_Read();                  // read the received data
    10.                      PORTD = i;
    11.                      Delay_ms(100);      //light the appropriate LEDs
    12.  
    13.                      }
    14.             }
    15. }
    I am new also to UART. I hope someone can help me. Thank you.
    Schematic is attached below.
     
Loading...