I don't have my databook here at home, and I'm more familiar with the 16c74a, but the two chips probably have a similar I/O map. So here goes... On Wed, 23 Dec 1998 11:13:35 +0530 Greg Cormier writes: >I'm still stumped on STATUS registers and PAGE0 and PAGE1 and stuff, >can >someone explain? (I'm working on an 16C84).. I was going through some >code, >and found this which is fairly straight forward, but I'd like to >*understand* what it's doing... > >First there's some declarations... > >#DEFINE PAGE0 BCF $03,5 >#DEFINE PAGE1 BSF $03,5 > I prefer to call these BANK 0 and BANK 1, which I believe Microchip does. They refer to paging for program memory as opposed to "register file space", but the overall result is the same. There are 256 addresses available in the "register file map", (0x00 to 0xff) requiring 8 bits of address. HOWEVER, the instructions that refer to the registers only have 7 bits for the register address. Therefore, bit 5 of the status register is used to hold the most significant bit of the register file address used in these instructions. You have to set or clear that bit as appropriate. PAGE0 (or I use bank0) clears this bit so instructions such as movwf somewhere will land somewhere between 0x00 and 0x7f. If the instruction is preceeded by PAGE1 (or bank1), the data lands somewhere between 0x80 and oxff. >OPTION: .EQU $01 >STATUS: .EQU $03 >PORTA: .EQU $05 >TRISA: .EQU $05 ; This is REALLY at 0x85, but instructions using it (unless ; you use INDF) don't use the msb of the operand, instea d ; the above mentioned bit of the status register is used . >PORTB: .EQU $06 >TRISB: .EQU $06 ; Actually 0x86 > >Then the code... > >clrf PORTA ; Cleared register at 0x05 >clrf PORTB ; Cleared register at 0x06 >PAGE1 >clrf TRISA ;Port A0-A4 as output (cleared TRISA at 0x85) >clrf TRISB ;Port B0-B7 as output (cleared TRISB at 0x86) >movlw %00000110 ;set timer ratio 1:128 >movwf OPTION ; Stored in option register at 0x81 >PAGE0 >---- > > OK? Harold ___________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com/getjuno.html or call Juno at (800) 654-JUNO [654-5866]