Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
brodin said:I wounder how it works with the STATUS register on a PIC 16F877.
I am using adress 03h. And that works even if I am in Bank1, where i probably should use 83h instead.
Should i use the correct adress for each bank I am in or is it ok to allways use 03h?
brodin said:I wounder how it works with the STATUS register on a PIC 16F877.
I am using adress 03h. And that works even if I am in Bank1, where i probably should use 83h instead.
Should i use the correct adress for each bank I am in or is it ok to allways use 03h?
eblc1388 said:brodin said:The full address only matters when one uses indirect addressing where all 8 bits address is being used. So using indirect addressing, one can use 05H to access PORT A and 85H to access TRISA.
How would that work when 85h is in GPR memory space?.
Nigel Goodwin said:How would that work when 85h is in GPR memory space?.
eblc1388 said:Nigel Goodwin said:How would that work when 85h is in GPR memory space?.
No. For 16F877, address 85H is TRISA and it is not inside the GPR ranges.
Nigel Goodwin said:Have you actually tried it though?, and does it work?,
Nigel Goodwin said:and (probably more importantly?) why would you want to?.
eblc1388 said:Nigel Goodwin said:Have you actually tried it though?, and does it work?,
It has to work. It just indirect addressing via FSR.
Nigel Goodwin said:You're assuming they are actually at that physical address?, but (from what you've said) you don't actually know it, and have never tried it?.
eblc1388 said:Nigel Goodwin said:You're assuming they are actually at that physical address?, but (from what you've said) you don't actually know it, and have never tried it?.
The Microchip datasheet tells me that they are there at that physical addresses.
You consider the datasheet wrong in this respect?
Nigel Goodwin said:Who knows?, the assembler doesn't consider them at that address 8)
;==========================================================================
;
; Verify Processor
;
;==========================================================================
IFNDEF __16F877
MESSG "Processor-header file mismatch. Verify selected processor."
ENDIF
;==========================================================================
;
; Register Definitions
;
;==========================================================================
W EQU H'0000'
F EQU H'0001'
;----- Register Files------------------------------------------------------
INDF EQU H'0000'
TMR0 EQU H'0001'
PCL EQU H'0002'
STATUS EQU H'0003'
FSR EQU H'0004'
PORTA EQU H'0005'
PORTB EQU H'0006'
PORTC EQU H'0007'
PORTD EQU H'0008'
PORTE EQU H'0009'
PCLATH EQU H'000A'
INTCON EQU H'000B'
PIR1 EQU H'000C'
PIR2 EQU H'000D'
TMR1L EQU H'000E'
TMR1H EQU H'000F'
T1CON EQU H'0010'
TMR2 EQU H'0011'
T2CON EQU H'0012'
SSPBUF EQU H'0013'
SSPCON EQU H'0014'
CCPR1L EQU H'0015'
CCPR1H EQU H'0016'
CCP1CON EQU H'0017'
RCSTA EQU H'0018'
TXREG EQU H'0019'
RCREG EQU H'001A'
CCPR2L EQU H'001B'
CCPR2H EQU H'001C'
CCP2CON EQU H'001D'
ADRESH EQU H'001E'
ADCON0 EQU H'001F'
OPTION_REG EQU H'0081'
TRISA EQU H'0085'
TRISB EQU H'0086'
TRISC EQU H'0087'
TRISD EQU H'0088'
TRISE EQU H'0089'
PIE1 EQU H'008C'
PIE2 EQU H'008D'
PCON EQU H'008E'
SSPCON2 EQU H'0091'
PR2 EQU H'0092'
SSPADD EQU H'0093'
SSPSTAT EQU H'0094'
TXSTA EQU H'0098'
SPBRG EQU H'0099'
ADRESL EQU H'009E'
ADCON1 EQU H'009F'
eblc1388 said:Nigel Goodwin said:Who knows?, the assembler doesn't consider them at that address 8)
You should really update your assembler to the current version.
The following is part of the 16F877.inc file from Microchip. Can you tell what address is TRISA or TRISB?
Nigel Goodwin said:But that's NOT what it produces!, it produces 05 and 06 for TrisA and TrisB.
movlw TRISA ;W will contains 85H, not 05H
movwf FSR ;FSR now contains 85H
movlw H'FF' ;W now contains 'FF'
movwf INDF ;all port A pins are now set as inputs
Yep, sometimes a picture is worth a million words :lol:Nigel Goodwin said:Looks like Jay has found the definitive graphic?.
Jay.slovak said:Yep, sometimes a picture is worth a million words :lol:Nigel Goodwin said:Looks like Jay has found the definitive graphic?.