movf PORTA,0 ; not working, why?

Hi, I'm writing a simple programme using pic16f876 with PICDEM plus 2 board. the 'movf' command not working for POARTA, POARTC. only working with POARTA. does anyone know the reason. Hear is my coding.

---------------------------------------------------------------

list p=16f876 ; list directive to define processor #include ; processor specific variable definitions

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_ON & _LVP_OFF & _DEBUG_OFF & _CPD_OFF

;***** VARIABLE DEFINITIONS HALL EQU 0x72 mask EQU 0x73 PHASE6 EQU 0X74

;********************************************************************** org 0x0005 ; processor reset vector clrf PCLATH ; ensure page bits are cleared goto main ; go to beginning of program

main BCF STATUS, RP0 ; BCF STATUS, RP1 ; Bank0 CLRF PORTA ; Initialize PORTA by ; clearing output ; data latches BSF STATUS, RP0 ; Select Bank 1 MOVLW 0x06 ; Configure all pins MOVWF ADCON1 ; as digital inputs MOVLW 0xCF MOVWF TRISA

CLRF STATUS ; Bank0 CLRF PORTB ; Initialize PORTB by clearing output ; data latches BSF STATUS, RP0 ; Select Bank1 MOVLW 0x00 MOVWF TRISB

CLRF STATUS ; Bank0 CLRF PORTC ; Initialize PORTB by clearing output ; data latches BSF STATUS, RP0 ; Select Bank1 MOVLW 0x00 MOVWF TRISC

bcf STATUS,5 bsf STATUS,6

movlw 0x0E movwf mask

LOOP movf PORTA,0 ; MOVF NOT WORKING !!!! andwf mask,0 movwf HALL

call TABLE movwf PORTB goto LOOP

TABLE movf HALL,0 sublw 0x02 btfsc STATUS,2 retlw 0x38 ;56

movf HALL,0 sublw 0x04 btfsc STATUS,2 retlw 0x23 ;35

movf HALL,0 sublw 0x06 btfsc STATUS,2 retlw 0x32 ;50

movf HALL,0 sublw 0x08 btfsc STATUS,2 retlw 0x0E ;14

movf HALL,0 sublw 0x0A btfsc STATUS,Z retlw 0x2C ;44

movf HALL,0 sublw 0x0C btfsc STATUS,2 retlw 0x0B ;11

retlw 0x2A ;42

END ; directive 'end of program'

------------------------------------------------------------

Cheers, Bala

Reply to
bala_thanushan
Loading thread data ...

I think you may need to select bank 0 before entering the loop and writing to PORTA

Bank selects are usually the culprit when my PIC code acts strangely.

Paul E. Schoen

Reply to
Paul E. Schoen

Hello Paul, It's working. Thanks for your help. Cheers, Bala

Reply to
bala_thanushan

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.