Myke's Home Page
|
"TrueRS" ExperimentPersonally, I feel that the most effective method of interfacing PICmicro® microcontrollers to other devices is via RS-232. For the next four experiments, I will be looking at different ways in which the PICmicro can be wired to RS-232 devices. In this first experiment, I will be looking at using a PICmicro with a built in USART port (the PIC16C73B) along with using a "true" RS-232 interface, the MAX232.
This experiment uses the circuit shown below:
The parts needed for this experiment are listed in the table:
Using a breadboard, the experiment is wired using the guide:
The source code listed below can be accessed from the CD-ROM by clicking Here.
title "TrueRS - Simple 3-Wire RS-232 Application"
;
; This Application Implements a simple "3 Wire" RS-232 Link
; to another Computer. The built in USART is used with a
; MAX232 Protocol translation chip.
;
;
; Hardware Notes:
; PIC16C73B Running at 4 MHz
; _MCLR is Pulled Up
; RC7 - Serial Receive Pin
; RC6 - Serial Transmit Pin
;
; Myke Predko
; 99.12.31
;
LIST P=16C73B, R=DEC
INCLUDE "p16c73b.inc"
PAGE
__CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF ^ _BODEN_ON
; Mainline of TrueRS
org 0
bsf STATUS, RP0 ; Enable the Serial Port
movlw (1 << TXEN) ; Enable Serial Transmission
movwf TXSTA ^ 0x080
movlw 51 ; Make the Serial Port Run at 1200 bps
movwf SPBRG ^ 0x080
bcf STATUS, RP0
movlw (1 << SPEN) | (1 << CREN)
movwf RCSTA ; Enable Serial I/O
Loop
btfss PIR1, RCIF ; Wait for Received Character Set
goto Loop ; - Nothing There
movf RCREG, w ; Get the Received Character
bcf PIR1, RCIF ; Clear the Character Present Flag
addlw 255 - 'z' ; Get the High limit
addlw 'z' - 'a' + 1 ; Add Lower Limit to Set Carry
btfss STATUS, C ; If Carry Set, then Lower Case
addlw h'20' ; Carry NOT Set, Restore Character
addlw 'A' ; Add 'A' to restore the Character
movwf TXREG ; Send the Character
goto Loop
end
|