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.

macro setup

Status
Not open for further replies.

ibwev

Member
First time to attempt using a macro. So far I've been unsuccessful. I'm using MPLAB with MPASM assembler. The code compiles; however the MPLAB simulator produces the following error message when the simulator reaches the instruction line calling the MACRO:

CORE-W0014: Halted due to PC incrementing over the Maximum PC address and wrapping back to Zero

Please help.
 

Attachments

  • Lesson6.asm
    4.3 KB · Views: 122
hi,
There are many errors in the program listing.
Why are you using a mixture or relative/absolute statements, are you trying for relocatable code or a hex file for a PIC.????
 
hi,
There are many errors in the program listing.
Why are you using a mixture or relative/absolute statements, are you trying for relocatable code or a hex file for a PIC.????

I am trying for a hex file for the PIC16F690.

I do not know how to answer why I am using a mixture of relative/absolute statements. I am working through a tutorial on gooligum and the lesson I am on is trying to teach me how to insert a macro into the body of the main program.
 
I am trying for a hex file for the PIC16F690.

I do not know how to answer why I am using a mixture of relative/absolute statements. I am working through a tutorial on gooligum and the lesson I am on is trying to teach me how to insert a macro into the body of the main program.

hi,
Look at this very simple use of a Macro.

Code:
;
;dummy program

    list      p=16F690            ; list directive to define processor
    #include <p16F690.inc>        ; processor specific variable definitions
    errorlevel -302, -207    
    
;define registers
WAITL   equ 0x20
CNTR0    equ 0x21
CNTR1     equ 0x22

    
;Define the macro          
;delay loop 1 to 255 msec  
LOOPMS    macro    MSEC   
    movlw    MSEC 
    movwf    WAITL  
    call    LOOP_WAIT
    endm

    org 0x0000
    goto start
    org 0x0004


start:
    LOOPMS    .1 ; this loads the macro with 1mSec count

    nop
    goto start

;usage called from macro loopms .nnn 
LOOP_WAIT:
    call    DEL1MS
    decfsz    WAITL,F        
    goto    LOOP_WAIT
    return

DEL1MS:                ; 1ms delay loop 
    movlw    0X64        ;100*10US=1MS
    movwf    CNTR0
DL2:
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    decfsz    CNTR0, F
    goto    DL2        ;
    return

    end
 
Last edited:
hi ibwev.

I would suggest that you look at Nigels tutorials, the link is near my signature on this post.
 
I got it working thanks to your help.

hi,
Thats good.
You will find that Nigels tutorials, with the hardware circuits provided are a quick and easy way to get into assembler programming.
 
Status
Not open for further replies.

Latest threads

Back
Top