try this
Code:
'
' PIC Configuration
' =================
@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
' Internal Oscillator
' Enable watch dog timer
' Enable power up timer
' Disable MCLR pin
' Enable brown out detect
DEFINE OSCCAL_1K 1 ' load internal osc calibration
'
' Hardware configuration
' ======================
TRISIO = %00101010 ' set GP3, GP4, GP5 input
' others to output
ANSEL = 0 ' disable adc
CMCON = 7 ' disable comparators
'
' Hardware assignment
' ===================
S_In1 var GPIO.1 ' Serial input #1
S_In2 VAR GPIO.5 ' Serial input #2
S_Out VAR GPIO.4 ' Serial output
'
' Variables definition
' ===================
Command VAR BYTE[10]
Baud var word
'
' Constants definition
' ====================
T2400 CON 396
T4800 CON 188
T9600 CON 84
N2400 CON 16780
N4800 CON 16572
N9600 CON 16468
'
' Software/Hardware initialisation
' ================================
'
' select baudrate
' ---------------
baud = t9600
'
' Set serial output pin idle level
' --------------------------------
if baud<400 then
high s_out
else
low s_out
endif
pause 50 ' settle time
serout2 s_out,baud,["Hello, this is a test!!!",13,10]
'
' Program Start
' ============
Start:
serout2 s_out,baud,["i'm waiting for incoming data on GPIO.1",13,10]
serin2 s_in1,baud,[str command\10\13]
Serout2 s_out,baud,["i got...", str command,13,10,13,10,_
"waiting for some data on GPIO.5",13,10]
serin2 s_in1,baud,[str command\10\13]
Serout2 s_out,baud,["i got...", str command,13,10,13,10]
goto start
Bookmarks