UART communication between two AVR micro in mikroc

General discussion on mikroC PRO for AVR.
Post Reply
Author
Message
elasa_group
Posts: 2
Joined: 19 Jun 2017 17:03

UART communication between two AVR micro in mikroc

#1 Post by elasa_group » 04 Mar 2018 16:21

we need to read data from one MLX90615 serial module ( IR thermometer sensor), SO it works with usart system the datasheet of the module is in this link:

https://www.circuitointegrato.com/en/um ... 42969.html

Since there is not mlx90615 library in Proteus we simulate the sensor with one another micro which sends the code's similar to the sensor in Proteus.

but the problem is here which we could not communicate between two mikros in mikroc software and in Proteus.

we working on a simple communication between two mikros, one is sending "Z" Character and receiver send the received character after reading on in RX line.

the Transmitter is here:

Code: Select all


// main function: entry point of program
int main (void)
{

    UART1_Init(9600);               // Initialize UART module at 9600 bps
  Delay_ms(100);                  // Wait for UART module to stabilize

while (1)
      {

                     // If the previous data has been shifted out, send next data:
if (UART_Tx_Idle() == 1) {
  UART_Write(0x5A);
 }
      }

    return 0;
}
and the receiver is here:

Code: Select all

char uart_rd ;

// main function: entry point of program
int main (void)
{
 UART1_Init(9600);               // Initialize UART module at 9600 bps
  Delay_ms(100);                  // Wait for UART module to stabilize
 UART1_Write_Text("Init");
  UART1_Write(13);UART1_Write(10);

while (1)
      {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
    }
  }

    return 0;
}
So at Proteus, the receiver Mikro must send the "Z" Character on the tx line but the virtual terminal in proteus dont show anything.

the simulation files is here:

https://www.4shared.com/zip/RLFINQ7Zca/New_folder.html
Image
thanks a lot.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: UART communication between two AVR micro in mikroc

#2 Post by filip » 12 Mar 2018 09:43

Hi,

The best way is to implement UART interrupt for the receiver side, you can find examples in the compiler's installation folder.

First of all, you should test it the receiver is running correctly - turn on some LEDs when a data is received.

Regards,
Filip.

Post Reply

Return to “mikroC PRO for AVR General”