View Full Version : How to upon receiving data via RS232, MCU immediately sends it back to the sender?
SKOLS1
- 21st February 2011, 20:15
I want to make something like this,when I receiv data from RS232 immediatelu send back to the sender,i write code but It can't compile it.Why?
define OSC 8
INCLUDE "Modedefs.bas"
TRISA = %00000100
TRISB = %00000000
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 5
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
Primi var BYTE
Prati var Byte
Isprati var BYTE
Main:
PORTA = $00
SERIN PORTA.3,N2400,Primi
pause 3000
IF Primi <> 0 Then Prati
ENDIF
Goto Main
Prati:
Primi = Isprati
Serout PORTA.2,N2400,Isprati
Goto Main
END
aratti
- 21st February 2011, 21:00
Remove the ENDIF and add the square parentesis it will compile.
Main:
PORTA = $00
SERIN PORTA.3,N2400,Primi
pause 3000
IF Primi <> 0 Then Prati
Goto Main
Prati:
Primi = Isprati
Serout PORTA.2,N2400,[Isprati]
Goto Main
Cheers
Al.
SKOLS1
- 21st February 2011, 21:20
no,it's not working
aratti
- 21st February 2011, 21:33
Did you turn portA digital ? Remember that by default portA is set as analog, so you cannot use the serin/serout command.
Which pic are using?
Al.
SKOLS1
- 21st February 2011, 22:03
No I forget to turn into digital,I have to use ADCON = 7?
I am using PIC16F877,but IF it's working I will make a small network,so I should send a messages from one PC to onether with RS232 protocol.
FinchPJ
- 22nd February 2011, 01:49
Another error: you define Prati as a byte then use it as a label - remove the byte definition. Also you assign the output value to Isprati which is undefined
Peter
SKOLS1
- 22nd February 2011, 20:01
No it's not working,I changed everything,but stil nothing.
I think the problem is in the MCS.When I compile code for PIC18F2550
there is an error.
And I want to make the code from DT,code for the Baragraphs it can't
compile it.
Ceetee
- 22nd February 2011, 20:20
I see from your code that you do not assign a value to Isparti.
Prati:
Primi = Isprati
Serout PORTA.2,N2400,[Isprati]
Goto Main
You assign Primi with the value IspartI, would it be better to reverse it ?.
Isparti = Primi
Powered by vBulletin® Version 4.1.7 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.