Ref: Tutorial 45 in 'Assembly for PICMicro v4', v3 Development Board, 16F88 (19.6608Mhz)
I been working with this tutorial and used the two routines to get the letter 'i' to appear on pin 11, RB5. A loop and delay have been added to the 'i' appears every 500ms. When the MAX232 chip arrives I should be able to connect the PIC to the PC and see the character string appearing in the hyperterminal.
Q1. The tutorial says you should be able to data being output on PORTC, pins RC5 and RC6? I'm using the 16F88 so were these notes written for the 16F877 which I believe does have a PORTC? If this is obvious please note I am a newbie and still learining.
Q2. Is there any drawings for the PORTC and PORTD connectors on the v3 development board? I was trying to find out if they were connected to any of the ports on the PICs or whether I could pickup the RB5 signal from them?
Q3. Can you supply a simple example for receiving RS232 data using the 16F88 from the PC? At this stage I only want to send a number from the PC that will appear on PORTA etc.
Any help would be greatly appreciated
For reference here is the test code to transmit the letter 'i'
Code: Select all
;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; Configuration data
; PICmicro MCU type: 16F88
; Oscillator: HS mode
; LCD display: off
; 7-segment display: off
; Version 3 board settings: none
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
; The following lines embed configuration data into the PICmicro
LIST P=16F88
__CONFIG H'2007', H'3F6A' ; HS mode
__CONFIG H'2008', H'3FFC' ; Clock Fail-Safe disabled
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#DEFINE BANK0 BCF STATUS,5
#DEFINE BANK1 BSF STATUS,5
OPSHUN EQU H'81' ;
PCL EQU H'02' ;
STATUS EQU H'03' ;
PORTA EQU H'05' ;
TRISA EQU H'85' ;
PORTB EQU H'06' ;
TRISB EQU H'86' ;
INTCON EQU H'0B' ;
PCLATH EQU H'0A' ; Bank 0, 1, 2, 3
INTCON EQU H'0B' ; Bank 0, 1, 2, 3
PIR1 EQU H'0C' ; Bank 0
PIE1 EQU H'8C' ; Bank 1
EEDATA EQU H'10C' ; Bank 2
EECON1 EQU H'18C' ; Bank 3
PIR2 EQU H'0D' ; Bank 0
EEADR EQU H'10D' ; Bank 2
EECON2 EQU H'18D' ; Bank 3
TMR1L EQU H'0E' ; Bank 0
TMR1H EQU H'0F' ; Bank 0
T1CON EQU H'10' ; Bank 0
CCP1CON EQU H'17' ; Bank 0
RCSTA EQU H'18' ; Bank 0
TXSTA EQU H'98' ; Bank 1
TXREG EQU H'19' ; Bank 0
SPBRG EQU H'99' ; Bank 1
ANSEL EQU H'9B' ; Bank 1
ADRESH EQU H'1E' ; Bank 0
ADRESL EQU H'9E' ; Bank 1
ADCON0 EQU H'1F' ; Bank 0
ADCON1 EQU H'9F' ; Bank 1
TXIE EQU 4
TXEN EQU 5
TXIF EQU 4
cblock h'48'
d1
d2
d3
endc
W EQU 0 ;
F EQU 1 ;
C EQU 0 ;
DC EQU 1 ;
Z EQU 2 ;
;************* START OF PROGRAM ***********************
ORG 0 ; Reset vector
GOTO 5 ; Goto start of program
ORG 4 ; Interrupt vector
GOTO 5 ; Goto start of program
ORG 5 ; Start of program memory
;CLRF PORTA
;CLRF PORTB
;BANK1 ; BANK1
;CLRF TRISA
;CLRF TRISB ;Port B0-B7 as output
CALL SETBAUD
call DELAY500MS
MOVLW H'69' ;CHAR 'i'
NEXT CALL SERIALSEND
CALL DELAY1S
GOTO NEXT
;********** INITIALISATION ROUTINE ****************
SETBAUD BANK1
movlw 129 ; BRG for 9600baud from 20MHz, brgh=1
; movlw 103 ; BRG for 9600baud from 16MHz, brgh=1
; movlw 25 ; BRG for 9600baud from 4MHz, brgh=1
; movlw 23 ; BRG for 9600baud from 3.6864MHz, brgh=1
; movlw 20 ; BRG for 9600baud from 3.2768MHz, brgh=1
; movlw 22
movwf SPBRG
movlw B'00000100' ; set sync=0, brgh=1 + ninth bit not set
movwf TXSTA
bcf PIE1,TXIE ; clear interrupt bit (bit TXIE)
BANK0
movlw B'10000000' ; set SPEN Bit of RCSTA reg
movwf RCSTA
BANK1
bsf TXSTA,TXEN ; enable transmission (bit TXEN)
BANK0
return
;********** ROUTINE THAT CAUSES ACTUAL OUTPUT OF SERIAL DATA BYTE *******
SERIALSEND
btfss PIR1,TXIF ; wait for TXIF bit 4 to go high
goto SERIALSEND ; (showing TXREG empty)
movwf TXREG ; put val (held in W) in TXREG ready for transmission
return
;********** DELAY ROUTINES *******
DELAY500MS
; Delay = 0.5 seconds
; Clock frequency = 19.6608 MHz
; Actual delay = 0.5 seconds = 2457600 cycles
; Error = 0 %
;2457600 cycles
movlw 0x6D
movwf d1
movlw 0x5C
movwf d2
movlw 0x06
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
return
DELAY1S
; Delay = 1 seconds
; Clock frequency = 19.6608 MHz
; Actual delay = 1 seconds = 4915200 cycles
; Error = 0 %
;4915195 cycles
movlw 0xDA
movwf d1
movlw 0xB7
movwf d2
movlw 0x0B
movwf d3
Delay_1
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_1
;5 cycles
goto $+1
goto $+1
nop
return
END ;final line