Files
SyncHome/trunk/workspace/gcb/Example_SoftUART_12f1501.gcb
2023-03-09 12:51:54 +00:00

55 lines
1.6 KiB
Plaintext

' ########### start ###########
' pic:PIC12F1501
' ########### end ###########
; FILE: Example_SoftUART_12f1501.gcb
; DATE: 31.01.2015
; VERSION: 1.0a
; AUTHOR: Evan R. Venn based on works of others
;
; Description.
' A demonstration program for GCGB and GCB.
' Receive a char from Software-UART and send it back.
; 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
#chip 12f1501, 4
'Set internal oscillator to 4 MHz
' (writing to IRCF only does not work !?)
' Set OSCCON = b'1101011' 'writing bit 0-6; bit 3-6 = IRCF
; ----- Define Hardware settings
Dir PORTA.2 Out 'send on Pin 5
Dir PORTA.0 In 'receive on Pin 7 (PCD
'Config Software-UART
#define SendAHigh Set PORTA.2 ON
#define SendALow Set PORTA.2 OFF
#define RecAHigh PORTA.0 ON
#define RecALow PORTA.0 OFF
InitSer 1, r2400, 1+WaitForStart, 8, 1, None, Invert
; ----- Variables
' No Variables specified in this example. All byte variables are defined upon use.
; ----- Main body of program commences here.
'Message after reset
SerPrint 1, " PIC 12f1501"
SerSend 1, 13 ' "Carriage Return"
SerSend 1, 10 ' "Line Feed"
'Main routine
Start:
SerReceive 1, InChar 'wait for char from UART
SerSend 1, InChar 'send back char to UART
Goto Start