SECTION V-7: Using EQU for Special Function Register Address Assignment

EQU is widely used to assign special function register (SRF) addresses. Examine the following code.

COUNTER EQU 0x00 ;counter value 00
PORT EQU 0xFF6 ;Special function register Port B address
MOVLW COUNTER ;WREG = 00H
MOVWF PORTB ;Port B now has 00 too
INCF PORTB, F ;Port B has 01
INCF PORTB, F ;increment Port B, Port B = 02
INCF PORTB, F ;increment Poer B, Port B = 03

 

 

 

 

 

 

 

The above is for the PIC18 family. If you use a different PIC controller such as PIC16F, where Port B is a different address, then change the EQU address for Port B and reassemble the program and run it.

 

COUNTER EQU 0x00 ;counter value 00
PORT EQU 0x07 ;Port B address in PIC16F
MOVLW COUNTER ;WREG = 00H
MOVWF PORTB ;Port B now has 00 too
INCF PORTB, F ;Port B has 01
INCF PORTB, F ;increment Port B, Port B = 02
INCF PORTB, F ;increment Poer B, Port B = 03 and so on...

 

 

 

 

 

 

More From Iamtechnical.com

Advertisement:

SiteLock