PDA

View Full Version : Conflict receiving RS485 stream



ngeronikolos
- 4th August 2005, 13:18
Hello Boys&Girls,

I hope you are well.It is time for holidays not for work but...money!!!

Let's talk about PicBasic Pro.
I have a problem with my code.I have a 16F628A which receives a rs485 stream.The device that transmit the stream is the master and it can <<talk>> with 128 slave devices.My pic is a slave device so it has a header(an address).
When I don't receive the stream my code loop MAIN it is working propertly.
When I receive my pic reads ok the stream but I can not go to MENU label while the conditions of porta.3 &porta.4 is 1.

Here is my code:

--------------------------------------------------------------------------
MAIN: IF PORTB.6 = 1 THEN STATIC
WHILE PORTA.3 = 1 AND PORTA.4 = 1 <--it does not work when I it receives
GOTO MENU
wend
DYNAMIC: IF RCIF = 1 THEN
HSERIN 300,MAIN,[WAIT(X),STR SERDATA\17] ;X = header - address
GOSUB OUT
gosub SERTALLY
ENDIF
GOTO MAIN
--------------------------------------------------------------------------

Thanks
Nikos Geronikolos

NavMicroSystems
- 4th August 2005, 15:27
-----------------------------------------------------------------MAIN: IF PORTB.6 = 1 THEN STATIC
WHILE PORTA.3 = 1 AND PORTA.4 = 1 <--it does not work when I it receives
GOTO MENU
wend
DYNAMIC: IF RCIF = 1 THEN
HSERIN 300,MAIN,[WAIT(X),STR SERDATA\17] ;X = header - address
GOSUB OUT
gosub SERTALLY
ENDIF
GOTO MAIN
-----------------------------------------------------------------



what do MENU, OUT and SERTALLY do?

and...
you are using a While...Wend loop that is jumped out of as soon as the condition in the While statement is met.

That doesn't make much sense, better would be something like:


IF PORTA.3 = 1 AND PORTA.4 = 1 THEN GOTO MENU