34 lines
1023 B
Plaintext
34 lines
1023 B
Plaintext
'-----------------------------------------------------------------------
|
|
'Receive a char from Software-UART and send it back using Hardware-UART.
|
|
'-----------------------------------------------------------------------
|
|
|
|
'Set chip model
|
|
#chip 16f1786, 4
|
|
'Set internal oscillator to 4 MHz
|
|
Set IRCF = b'1101'
|
|
|
|
'Config Hardware-UART to send with
|
|
#define USART_BAUD_RATE 2400
|
|
#define USART_BLOCKING
|
|
'Invert UART Tx polarity to connect without max232
|
|
Set SCKP ON
|
|
'Set UART transmit pin to output (Tx)
|
|
Dir PORTC.6 Out 'Pin 17
|
|
|
|
'Config Software-UART to receive with
|
|
#define RecAHigh PORTB.7 ON
|
|
#define RecALow PORTB.7 OFF
|
|
InitSer 1, r2400, 1+WaitForStart, 8, 1, None, Invert
|
|
'Set the pin direction
|
|
Dir PORTB.7 In 'receive on Pin 40 (RB7/PGD)
|
|
Wait 100 Ms
|
|
|
|
'Message after reset
|
|
HSerPrint " PIC 16f1786"
|
|
HSerSend 13 ' "Carriage Return"
|
|
HSerSend 10 ' "Line Feed"
|
|
|
|
Start:
|
|
SerReceive 1, InChar 'wait for char from Software-UART
|
|
HSerSend InChar 'send back char to Hardware-UART
|
|
Goto Start |