hotrodhed120
Member
I've got a problem with this code not writing to porta if mplab sim. I'm having similer problems elsewhere in the code but this is my power on routine to see that everything is working but it is not. Am I using the #define correctly? I also tried to use the set directive in a previous version but it did not work correctly either. Please, help!
Code:
list p=16f870 ; list directive to define processor
#include <p16f870.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_OFF & _LVP_OFF & _CPD_OFF
; '__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 0x7E ; variable used for context saving
status_temp EQU 0x7F ; variable used for context saving
#define tps porta,0
#define tach porta,2
#define led porta,4
#define up portb,1
#define down portb,2
#define bypin portb,3
#define rangein portb,5
#define bypass portc,4,5,6,7
#define ledflg atemp,5
#define outputc portc
#define firstflg shftflg,0
#define secondflg shftflg,1
#define thirdflg shftflg,2
#define fourthflg shftflg,3
udata_shr
atemp res 1 ;porta temp
swtemp res 1 ;switch temp
output res 1 ;portc
count0 res 1 ;for delay
count1 res 1 ;for delay
count2 res 1 ;for delay
shftflg res 1 ;flag byte for gear position
first res 1
second res 1
third res 1
fourth res 1
;**********************************************************************
ORG 0x000 ; processor reset vector
main bsf status,5 ;bank 0
movlw d'5'
movwf trisa ;
movlw d'255'
movwf trisb
movlw d'0'
movwf trisc
movlw b'00001010'
movwf adcon1
bcf status,5
clrf porta
clrf portb
clrf portc
movlw b'01000000' ;setup for ch0 but not on
movwf adcon0 ;
clrf porta
clrf portb
clrf portc
clrf atemp
clrf shftflg
clrw
bsf ledflg
movfw atemp
movwf porta
call delay
clrf porta
call delay
movfw atemp
movwf porta
call delay
nop
call delay
clrf porta
movlw d'243'
movwf first
movlw d'241'
movwf second
movlw d'240'
movwf third
movlw d'242'
movwf fourth
end