Files
SyncHome/trunk/workspace/gcb/Software Serial Setup Example - 16F886.gcb
2023-03-09 12:51:54 +00:00

65 lines
1.7 KiB
Plaintext

' ########### start ###########
' pic:PIC16F886
' ########### end ###########
; FILE: Software Serial Setup Example - 16F886.gcb
; DATE: 31.01.2015
; VERSION: 1.0a
; AUTHOR: Evan R. Venn
;
; Description.
' A serial terminal solution that turns an LED off or on.
' The LED will be turned ON a '1' is received.
' The LED will be turned OFF a '0' is received.
' The LED should be connected to PORTB.5 via appropiate resistors.
;
;
; This file is part of the Great Cow Basic compiler.
;
; This demonstration code is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; ----- Configuration
'PIC 16F886 running at 16 MHz
#chip 16F886, 16
; ----- Define Hardware settings
'Set pin directions
Dir SerOutPort Out
Dir SerInPort In
DIR portb.5 Out
; ----- Constants
'Setup Serial Port
#define SerInPort PORTB.6
#define SerOutPort PORTB.7
#define SendAHigh Set SerOutPort off
#define SendALow Set SerOutPort on
#define RecAHigh SerInPort off
#define RecALow SerInPort on
; ----- Main body of program commences here.
InitSer 1, r4800, 1+WaitForStart, 8, 1, none, invert
wait 500 ms
SerPrint 1, "GCBASIC Serial RS232 Test"
SerSend 1, 13
SerSend 1, 10
Wait 1 s
Do
SerReceive 1, Temp
SerSend 1, Temp
SerSend 1, 13
SerSend 1, 10
If Temp = "1" Then Set portb.5 on
If Temp = "0" Then Set portb.5 Off
Loop