Electrix
Member
This particular program is to send data from one PIC to another PIC. One of them is continously transmitting data (ASCII charc) and the other is polling the RCIF to receive the data. The problem is i'm keeping an LED to indicate that a byte has been successfully received. It's all working fine in the simulator, but when I see the actual test..the LED doesnt flash.
Code:
;**********************************************************************
; This file is a basic code template for assembly code generation *
; on the PICmicro PIC16F73. This file contains the basic code *
; building blocks to build upon. *
; *
; If interrupts are not used all code presented between the ORG *
; 0x004 directive and the label main can be removed. In addition *
; the variable assignments for 'w_temp' and 'status_temp' can *
; be removed. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler (Document DS33014). *
; *
; Refer to the respective PICmicro data sheet for additional *
; information on the instruction set. *
; *
;**********************************************************************
; *
; Filename: xxx.asm *
; Date: *
; File Version: *
; *
; Author: *
; Company: *
; *
; *
;**********************************************************************
; *
; Files required: *
; *
; *
; *
;**********************************************************************
; *
; Notes: *
; *
; *
; *
; *
;**********************************************************************
list p=16f73 ; list directive to define processor
#include <p16f73.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _RC_OSC
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;***** VARIABLE DEFINITIONS
w_temp EQU 0x20 ; variable used for context saving
w_temp1 EQU 0xA0 ; reserve bank1 equivalent of w_temp
status_temp EQU 0x21 ; variable used for context saving
pclath_temp EQU 0x22 ; variable used for context saving
cnt500u EQU 0x23
cnt1m EQU 0x24
cnt100m EQU 0x25
cnt500m EQU 0x26
cnt1s EQU 0x27
cnt15s EQU 0x28
;**********************************************************************
ORG 0x000 ; processor reset vector
clrf PCLATH ; ensure page bits are cleared
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
bcf STATUS,RP0 ; ensure file register bank set to 0
movwf status_temp ; save off contents of STATUS register
movf PCLATH,w ; move pclath register into w register
movwf pclath_temp ; save off contents of PCLATH register
; isr code can go here or be located as a call subroutine elsewhere
bcf STATUS,RP0 ; ensure file register bank set to 0
movf pclath_temp,w ; retrieve copy of PCLATH register
movwf PCLATH ; restore pre-isr PCLATH register contents
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
main
; remaining code goes here
BANKSEL TRISB
clrf TRISB
movlw b'01000000'
movwf INTCON
movlw b'00100000'
movwf PIE1
movlw 0x30
movwf FSR
Ag
BANKSEL SPBRG
movlw D'64'
movwf SPBRG
BANKSEL TXSTA
bsf TXSTA,BRGH
BANKSEL RCSTA
movlw b'10010000'
movwf RCSTA
BANKSEL PIR1
WaitRX btfss PIR1,RCIF
goto WaitRX
call RC
goto WaitRX
RC
bcf PIR1,RCIF
BANKSEL RCREG
movf RCREG,W
movwf INDF
BANKSEL PORTB
bsf PORTB,0
call t500m
bcf PORTB,0
incf FSR,f
return
delay
t1m
movlw d'2'
movwf cnt1m
tm1lp2 movlw d'249'
movwf cnt500u
tm1lp1 nop
nop
decfsz cnt500u,f
goto tm1lp1
decfsz cnt1m,f
goto tm1lp2
return
t100m
movlw d'100'
movwf cnt100m
tm2lp call t1m
decfsz cnt100m,f
goto tm2lp
return
t500m
movlw d'5'
movwf cnt500m
tm3lp call t100m
decfsz cnt500m,f
goto tm3lp
return
t1s
movlw d'2'
movwf cnt1s
tm4lp call t500m
decfsz cnt1s,f
goto tm4lp
return
t15s
movlw d'15'
movwf cnt15s
tm5lp call t1s
decfsz cnt15s,f
goto tm5lp
return
END ; directive 'end of program'