Is the PIC capable of sending RAW binary data??
I think if you just send the value without any formatting, it's in raw format.
I.E. X = 10 : HSEROUT [X].
You can send whatever value's in X directly to the USART TXREG like this,
and I'm fairly sure the PIC doesn't automatically convert bytes placed in
TXREG to ASCII;
Code:
SPBRG = 64 ' 19200 bps @20MHz
RCSTA = $90 ' Serial port enable
TXSTA = $24 ' Transmit enable, BRGH = 1 for high-speed
X VAR BYTE
TRISC.6=0
MAIN:
FOR X = 0 to 255
GOSUB ENCODE
PAUSE 50
NEXT X
X = $0D ' Carriage return
GOSUB ENCODE
X = $0A ' Line feed
GOSUB ENCODE
PAUSE 100
GOTO Main
ENCODE:
ASM
movf _X, W ; Load X into W reg
btfss PIR1,4 ; Wait for TXREG to be empty after last byte
goto $-1 ; Not empty, wait
movwf TXREG ; Empty, so send next byte
ENDASM
RETURN
I don't have MATLAB to test this, but I can't see why it wouldn't work. I get
the same results from either method with a standard terminal program.
Bookmarks