PDA

View Full Version : Serout -->>> serin



larzazral
- 27th February 2010, 03:13
I HAVE SOME PROBLEM....
I DONT KNOW WHY MY SEVEN SEGMENT COUNT 1,3,5,7,9

MY CODE:

SEROUT:

I VAR BYTE
TRISD = 0
PORTD = 0

LOOP1:
GOSUB SEND
I = I + 1
PAUSE 200
IF I > 9 THEN
I = 0
ENDIF
GOTO LOOP1
SEND :
SEROUT2 PORTD.1,16468,["A",DEC I]
RETURN
END


SERIN:

INCLUDE "modedefs.bas"

PATTERN VAR BYTE
I VAR BYTE
DIGIT VAR BYTE
TRISC = 255
PORTC = 0
TRISB = 0
PORTB = 0

MAIN:
DIGIT = I
GOSUB CONVERT
PORTB = PATTERN

SERIN2 PORTC.3,16468,[WAIT("A"),DEC I]

GOTO MAIN

CONVERT:

LOOKUP DIGIT, [$C0, $F9, $A4, $B0, $99, $92, $82, $F8, $80, $90], Pattern
RETURN

END

Darrel Taylor
- 27th February 2010, 03:46
Hi larzazral,

With SERIN2, the DEC modifier needs a non-numeric character to indicate the end of the number.
Or, it needs to know how many digits to expect.

As it is, the next non-numeric character is the "A" from the next packet, so that A (and it's data) are discarded, and it waits for the packet after that.
Which makes it only receive every other packet.

Either this on the transmit side ...
SEROUT2 PORTD.1,16468,["A",DEC I,";"]

OR, this on the receive side ...
SERIN2 PORTC.3,16468,[WAIT("A"),DEC1 I]
Should get you going.