kahjoo
Junior Member level 2
- Joined
- Jul 23, 2012
- Messages
- 21
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,456
Hi,
Currently I'm porting the current coding using in 16F685 to new MCU 16F1824 which we need 32MHz for internal clock. However, I’ve problem of porting the “Indirect Addressing” function.
Below is the original code and the register address for reference:-
The register address are in Bank2. As the 16F1824 having the 16bits of FSR(FSRh,FSRl), how does the correct coding to be used for indirect addressing?
Can someone show me the corret way?
Currently I'm porting the current coding using in 16F685 to new MCU 16F1824 which we need 32MHz for internal clock. However, I’ve problem of porting the “Indirect Addressing” function.
Below is the original code and the register address for reference:-
The register address are in Bank2. As the 16F1824 having the 16bits of FSR(FSRh,FSRl), how does the correct coding to be used for indirect addressing?
Can someone show me the corret way?
Code:
;data storage on tx
tx_byte0 equ 0x123
tx_byte1 equ 0x124
tx_byte2 equ 0x125
tx_byte3 equ 0x126
tx_byte4 equ 0x127
tx_byte5 equ 0x128
tx_byte6 equ 0x129
tx_byte7 equ 0x12A
tx_byte8 equ 0x12B
tx_byte9 equ 0x12C
tx_byte10 equ 0x12D
tx_byte11 equ 0x12E
tx_byte12 equ 0x12F
;data tx/rx on ic2ic
ic_byte0 equ 0x143
ic_byte1 equ 0x144
ic_byte2 equ 0x145
ic_byte3 equ 0x146
ic_byte4 equ 0x147
ic_byte5 equ 0x148
ic_byte6 equ 0x149
ic_byte7 equ 0x14A
ic_byte8 equ 0x14B
ic_byte9 equ 0x14C
ic_byte10 equ 0x14D
ic_byte11 equ 0x14E
ic_byte12 equ 0x14F
;command register
reg0 equ 0x71
reg1 equ 0x72
reg2 equ 0x73
transfer_tx_byte_ic
bsf STATUS,IRP
movlw tx_byte0 ;from
movwf reg1
movlw ic_byte0 ;to
movwf reg2
;--- priority setting
bcf ic_byte0,0
btfsc priority_f
bsf ic_byte0,0
;---
;---transfer_byte
movlw .13 ;13bytes count
movwf reg0
transfer_byte_01
movf reg1,w
movwf FSR
movf INDF,w
movwf temp
movf reg2,w
movwf FSR
movf temp,w
movwf INDF
incf reg2,f
incf reg1,f
decfsz reg0,f
goto transfer_byte_01
transfer_byte_end
bcf STATUS,IRP
return
Last edited: