Sonsivri

Electronics => Pic Basic Languages => Topic started by: rod27cn on May 11, 2008, 05:59:24 17:59



Title: Question: PICBasic Pro how to receive more than 2 byte of data from PC
Post by: rod27cn on May 11, 2008, 05:59:24 17:59
Hello, Can somebody help me on how to received more than 2 bytes of data from PC using PICBasic Pro. I am using PIC16F876A.

Please advise some idea or examples.

Thanks! :)

Posted on: May 11, 2008, 06:57:52 18:57 - Automerged

I am using RS232 communication by the way, I forgot to mention it.


Title: Re: Question: PICBasic Pro how to receive more than 2 byte of data from PC
Post by: strat on May 11, 2008, 08:19:09 20:19
You can use arrays. But the program worked on the PC must send data to Pic by byte variable.


Title: Re: Question: PICBasic Pro how to receive more than 2 byte of data from PC
Post by: maddoc on May 12, 2008, 08:47:22 08:47
I use a loop in the main program to receive nonstop data.

It usually can process around 19200bps of info with those CASE statements full of code.
I use to receive data also in the CASE statements, because some commands need 1 to 50 bytes of data.
Code:

MAIN:
C = HRSIN    
IF C <> $FF THEN

;do something if it is not a start command character ( $FF )

ELSE

CMND = HRSIN
SELECT CMND

CASE X
             do something
CASE X+1
             do something
CASE X+2
             do something
CASE X+3
             do something
CASE X+100
             for z = 1 to 50
             i[z] = HRSIN
             next
             do something with that array.

ENDSELECT
ENDIF
GOTO MAIN