Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Changing Variables entering into a macro

Status
Not open for further replies.

jstar

New Member
My problem is that when I enter a macro, I have it using a variable that is changing within the program. Now for some reason the macro takes the address of the register (0x28) and works with that instead of the contents of the register (0xaf) How do I make the macro take the contents and not the address of the register?

Let me know if you have any other questions, I have been debugging for the last couple days and this is my last problem with this program and I do not know how to fix it.

Thanks.
 
My problem is that when I enter a macro, I have it using a variable that is changing within the program. Now for some reason the macro takes the address of the register (0x28) and works with that instead of the contents of the register (0xaf) How do I make the macro take the contents and not the address of the register?

Let me know if you have any other questions, I have been debugging for the last couple days and this is my last problem with this program and I do not know how to fix it.

Thanks.

hi,
It sounds like the Macro is written to load the address rather than the contents of the address.

Post the Macro.
 
Thats exactily what its doing.
edited because i had a old version of it with some things commented out. It is now how it stands.



Code:
REVinit    MACRO
       bcf         STATUS, RP0
       bcf         STATUS, RP1
       bcf         REVport
       bsf         STATUS, RP0
       bcf         STATUS, RP1
       bcf         REVtris
       movlw       b'00000111'     ; TMR0 prescaler rate 1:256
       movwf       OPTION_REG      ; OPTION <- W
       bcf         STATUS, RP0
       bcf         STATUS, RP1
       ENDM
REV   MACRO        ;freq , duration
       bcf         STATUS, RP0
       bcf         STATUS, RP1
       movlw       freq
       movwf       REV_TEMP1
       movlw       0x01				;time before frequency change
       movwf       REV_TEMP2
       call        REVsub
       ENDM
;**********************************************************************
; Subroutines

REVsub
       clrf        TMR0            ; Counter initialization
       bcf         INTCON, T0IF
       bcf         REVport
REVa
       bcf         INTCON, T0IF    ; Clears TMR0 Overflow Flag
REVb
       bsf         REVport
       call        B_Wait          ; Logic one "1" duration
       bcf         REVport
       call        B_Wait          ; Logic zero "0" duration
       btfss       INTCON, T0IF    ; Check TMR0 Overflow Flag,
       goto        REVb           ; skip next if set
       decfsz      REV_TEMP2, f   ; Is REV_TEMP2 = 0 ?
       goto REVa                  ; Go to REVa again
       return
B_Wait
       movf REV_TEMP1, w
       movwf REV_TEMP3
B_Waita
       decfsz REV_TEMP3, f
       goto B_Waita
       return
 
Last edited:
hi,
If its the REV Macro, the movlw freq, is loading W with the address

if you want the contents of freq in W, it should be
movf freq,W

Code:
 movlw       freq
 movwf       REV_TEMP1
 movlw       0x01				;time before frequency change
 movwf       REV_TEMP2
 
Last edited:
THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU !!!!! Ah something sooo simple I should have caught, the macro was orignally made to take a literal value that was injected into it, so it makes sense that I would have to make it accept the file and use that with movlw instead. You just saved the day!!! thanks!!!!!!!! Il reburn it tomorrow when I get back to the lab and see how it goes.
 
Possible confusion?

Is it any chance that he is confusing macro with subroutine?

I am not being picky but...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top