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

56 lines
1.6 KiB
Plaintext

' ########### start ###########
' pic:PIC16C84
' ########### end ###########
'
' ******************************************************************
' Test for a Serial transmission with a PIC16C84
' 2014-02-04 (c) Paolo Iocco
' ******************************************************************
'
' Circuit diagram
' ---------------
' +--\/--+
' nc-----|1° 18|--------> TX
' nc-----|2 17|<-------- RX
' nc-----|3 16|<--------H
' +5V--|50K|-->|4 15|<--------H = 4 MHz chrystal+ capacitors
' GND-------->|5 14|<--------+5V
' nc-----|6 13|-----nc
' nc-----|7 12|-----nc
' nc-----|8 11|-----nc
' nc-----|9 10|-----nc
' +------+
'
' ******************************************************************
Config:
#Chip 16C84, 4
#Config OSC = XT, WDT = OFF, PWRTE = ON, CP = OFF
'Set the pin directions
Dir PORTA.1 Out 'send on Pin 18
Dir PORTA.0 In 'receive on Pin 17
'Config Software-UART
#define SendAHigh Set PORTA.1 ON
#define SendALow Set PORTA.1 OFF
#define RecAHigh PORTA.0 ON
#define RecALow PORTA.0 OFF
'-------------------------------------------------------------
Startup:
InitSer 1, r9600, 1+WaitForStart, 8, 1, None, Invert
' Message after reset
SerSend 1, 0x31 ' 1
SerSend 1, 0x36 ' 6
SerSend 1, 0x43 ' C
SerSend 1, 0x38 ' 8
SerSend 1, 0x34 ' 4
SerSend 1, 0x0D ' "Carriage Return"
SerSend 1, 0x0A ' "Line Feed"
'-------------------------------------------------------------
'Main routine
Loop:
SerReceive 1, InChar 'wait for char from UART
SerSend 1, InChar 'send back char to UART
Goto Loop