33 lines
895 B
Plaintext
33 lines
895 B
Plaintext
'---------------------------------------------------
|
|
'Receive a char from Software-UART and send it back.
|
|
'---------------------------------------------------
|
|
|
|
'Chip model
|
|
#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
|
|
|
|
'Set the pin directions
|
|
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
|
|
|
|
'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
|