Comunication with PC and MCU over RS232.

pr2501
 
Avatar
 
Betreff:

Comunication with PC and MCU over RS232.

 · 
Gepostet: 12.06.2008 - 19:53 Uhr  ·  #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
Schreiberling
Avatar
Geschlecht:
Herkunft: Germany
Alter: 59
Beiträge: 987
Dabei seit: 09 / 2007
Betreff:

Re: Comunication with PC and MCU over RS232.

 · 
Gepostet: 12.06.2008 - 20:40 Uhr  ·  #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
 
Betreff:

Re: Comunication with PC and MCU over RS232.

 · 
Gepostet: 14.06.2008 - 08:24 Uhr  ·  #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
 
Betreff:

Re: Comunication with PC and MCU over RS232.

 · 
Gepostet: 14.06.2008 - 08:27 Uhr  ·  #4
I have hardware for programing and i can switch leds on outputs.
fl
 
Avatar
 
Betreff:

Re: Comunication with PC and MCU over RS232.

 · 
Gepostet: 15.06.2008 - 11:09 Uhr  ·  #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
 
Betreff:

Re: Comunication with PC and MCU over RS232.

 · 
Gepostet: 15.06.2008 - 14:24 Uhr  ·  #6
thank you
Gewählte Zitate für Mehrfachzitierung:   0

Registrierte in diesem Topic

Aktuell kein registrierter in diesem Bereich

Die Statistik zeigt, wer in den letzten 5 Minuten online war. Erneuerung alle 90 Sekunden.
MySQL Queries: 15 · Cache Hits: 14   84   98 · Page-Gen-Time: 0.060609s · Speichernutzung: 2 MB · GZIP: ein · Viewport: SMXL-HiDPI