• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

16F887 Sync'd RS232 probs

Status
Not open for further replies.

Mosaic

Well-Known Member
Would anyone have any sample asm code to link 2 887 type chips via sync'd RS232 rather than Async mode?
I can get the ISIS simulator to run ok...but the real thing won't work AT all.
Also I can get the Async RS232 to work fine on both the simulator and the breadboard so....it's not the circuit.
 

Jon Wilder

Active Member
You stated above that async mode works so that it's not the circuit. In async mode, the UARTs must be cross connected. However, you don't cross connect with sync serial. Have you verified that your UARTs are not cross connected?

In any event, try this for your init code for both master and slave modes -

Code:
initUartMasterMode:
   banksel     BAUDCTL        ; bank 4
   bcf         BAUDCTL,SCKP   ; data changes on rising edge of clock
   banksel     TRISC          ; bank 1
   movlw       b'11000000'    ; RC6-RC7 tristate (controlled by UART hardware)
   iorwf       TRISC,F        ;
   movlw       d'34'          ; 115.2kbps bit rate w/16MHz xtal (2% error)
   movwf       SPBRG          ;
   movlw       b'10110000'    ; synchronous serial, master mode
   movwf       TXSTA          ;
   banksel     RCSTA          ; bank 0
   movlw       b'10000000'    ; enable serial port, continuous receive disabled
   return                     ; done

initUartSlaveMode:

   banksel     BAUDCTL        ; bank 4
   bcf         BAUDCTL,SCKP   ; data changes on rising edge of clock
   banksel     TRISC          ; bank 1
   movlw       b'11000000'    ; RC6-RC7 tristate (controlled by UART hardware)
   iorwf       TRISC,F        ;
   movlw       d'34'          ; 115.2kbps bit rate w/16MHz xtal (2% error)
   movwf       SPBRG          ;
   movlw       b'10110000'    ; synchronous serial, slave mode
   movwf       TXSTA          ;
   banksel     RCSTA          ; bank 0
   movlw       b'10000000'    ; enable serial port, continuous receive disabled
   return                     ; done
 
Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top