Myke's Home Page

Book CD-ROM Home

File Copying/Harddrive Setup

Development Tools

Experiments

Projects

Useful Code Snippets and Macros

Introduction to Electronics

Introduction to Programming

Datasheets

PCBs

Links

McGraw-Hill Professional Publishing

"TrueRS" Experiment

Personally, 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:

Part Description
PICmicro® MCU PIC16C73B-JW
Vdd/Vss Decoupling Capacitor 0.1 uF (Any Type)
_MCLR Pull Up Resistor 10K, 1/4 Watt
4 MHz Ceramic Resonator Three Leaded Ceramic Resonator with Built in 27-33pF Capacitors
MAX232 Maxim MAX232 in sixteen pin "DIP" package
1.0 uF Capacitors 16 Volt Rating, Any Type
9-Pin Female "D-Shell" Connector Modified and wired to the PC as discussed in the Book
Breadboard Any Type
+5 Volt "Vcc" Power Supply Any Type

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
              

Click Here to look at the forty second experiment - BasicRS