Comunication with PC and MCU over RS232.

pr2501
 
Avatar
 
Subject:

Comunication with PC and MCU over RS232.

 · 
Posted: 12.06.2008 - 17:53  ·  #1
My APP consist of two edit boxes:
Edit1Read for TX (transfer data from variable "outMCU") and
Edit2Write for RX (receive data into variable " inMCU").

Whats the way to approach to this problem?
What must i do with AVRco and what with Delphi?
miparo
Administrator
Avatar
Gender:
Location: Germany
Age: 59
Posts: 953
Registered: 09 / 2007
Subject:

Re: Comunication with PC and MCU over RS232.

 · 
Posted: 12.06.2008 - 18:40  ·  #2
Hello pr2501,
you need for Delphi Cport(TComport) then you can do:

Code
Procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer);
Var ch: char;
Begin
  // receive event from the UART component
  If SLIPactive1 Then Begin
    Try
      While Form1.ComPort1.Read(ch, 1) = 1 Do Begin
        EditBoxTx.Text:=ch;
      End;
    Except
    End;
  End;
End;


Code

procedure Sendbyte;
Begin
   Str := 'Hello';
  ComPort1.WriteStr(Str); // string type variable
  ComPort1.Write(Str[1], Length(Str)); // no defined type
 //  Comport1.Write(pB^, count); // Array ?
end;



In AVRco look at Page 64 3.11

When you transfer more than one byte the SLIP Function is the best way :D

miparo
pr2501
 
Avatar
 
Subject:

Re: Comunication with PC and MCU over RS232.

 · 
Posted: 14.06.2008 - 06:24  ·  #3
Thank you

And about hardware what do i need?

From (RXD) PD0 and (TXD) PD1
to which pins of com port1 of PC need to be connected?
pr2501
 
Avatar
 
Subject:

Re: Comunication with PC and MCU over RS232.

 · 
Posted: 14.06.2008 - 06:27  ·  #4
I have hardware for programing and i can switch leds on outputs.
fl
 
Avatar
 
Subject:

Re: Comunication with PC and MCU over RS232.

 · 
Posted: 15.06.2008 - 09:09  ·  #5
You must not connect any AVR I/O pin directly to the PC com port! PC com port uses voltages up to +/- 12 volts! You will need a RS232 transceiver like ST202, ST232 or similar devices.
pr2501
 
Avatar
 
Subject:

Re: Comunication with PC and MCU over RS232.

 · 
Posted: 15.06.2008 - 12:24  ·  #6
thank you
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 13   84   97 · Page-Gen-Time: 0.028792s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI