[SOLVED !] Macro documentation?


Closed Thread
Results 1 to 13 of 13

Thread: Macro documentation?5275 days old

  1. #1
    mulveyr
    Guest mulveyr's Avatar

    0 Not allowed!

    Default Macro documentation?

    Hi All:

    I just received my copy of PDS - very nice.

    I have a question about documentation for the Macro facility though - I've looked high and low, and can't find any reference to it in the help files or the manual - just comments on the forums. Is it not officially documented, or am I merely blind? ;-)

    Thanks,
    - Rich

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,168
    Thumbs Up
    Received: 96
    Given: 1
    Total Downloaded
    2.90 GB

    0 Not allowed!

    Default

    You are not blind - there is no documentation as yet.

    If you want to discover more there are a number of sample macros on the user site. I have also produced a wizard to help in writting basic macros. THe wizard will generate all the macro code you need to allow you to pass between a macro and your program. The help file has a brief description of macros and a couple of examples.

    I have recently re-implemented the wizard, written originally in VB, but now re-written in Delphi. It makes distribution much easier as well as being crisper in operation.

    Unzip the attached file and execute it. It will install the Macro Generator wizard as a plug in - You will find it will appear in the plugin menu under JGBTools.

    JohnB

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,689
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default

    Macro's while not officially documented are very usable. I can really recommend Johns macro wizard it makes the whole process very easy when you get into the more complex elements.

    For simple usage just write the name you want to call your macro and follow it with MACRO at the end of the code write ENDM

    An example

    FLASH MACRO
    High PORTB.0
    delayms 500
    Low PORTB.0
    ENDM

    Now when ever you use FLASH the code you inserted into the program

    High PORTB.0
    delayms 500
    Low PORTB.0

    There is a lot more to that in macros but it's a start.
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    cgriffin
    Guest cgriffin's Avatar

    0 Not allowed!

    Default

    Tim, I'm digging up this old thread because I thought I knew how to use macros... I verified my syntax with the search that brought me to this thread, but still, no success. Here's my code...

    Code:
    ChargerON MACRO
        pChg_En = cChgON     'portb.0 = 0
    ENDM
    
    ChargerOFF MACRO
        pChg_En = cChgOFF    'portb.0 = 1
    ENDM
    
    TestLabel:
        While 1 = 1
            ChargerOFF               'this fails
    '        pChg_En = cChgOFF   'this works
            DelayMS 200 
            wBatIn = ADIn cVBat
        	ChargerON 
    '        pChg_En = cChgOn
        	GoSub Beeper     'verify looping with 60ms audible indicator
        	DelayMS 200
        Wend
    GoTo TestLabel
    If I try to use the macro, the pin does not change state. If I un-comment the hard-coding, it works. What did I miss?

    Thanks!

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,689
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default

    Looks fine to me, I tried it and once I had set the tris it worked fine
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    cgriffin
    Guest cgriffin's Avatar

    0 Not allowed!

    Default

    The TRIS set between the definitions and use, along with all of the other register settings.

    I comment out the manual pin setting to use the Macro, and it won't work... swap the comments, and it begins to work.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #7
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,689
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default

    I take it your using an 18 series?
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #8
    cgriffin
    Guest cgriffin's Avatar

    0 Not allowed!

    Default

    16f88...

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #9
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,689
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default

    It always helps if you give us the full info....

    You want read this I copied from another post I did

    The compiler will compile all the code it see's

    It's up to the assembler if the code get's included.

    Say you wrote

    blink macro
    high portb.0
    delayms 500
    low portb.0
    endm

    then placed blink around your code

    What happens is the section of code inside the macro define is compiled as Proton see's it. Then the assembler takes that section of asm and places it were it see's the macro in the rest of your code.

    This can though lead to problems as the compiler does bank handling on the code as it see's it. In context with code around it. If you now paste that code with all it's bank handling some were else then it screws up.

    This is why you should use macros only for small sections of code that do no bank switching or you just pass variables and call a sub.

    They are very very handy if you are aware of their down side. Library manger routines do it properly.
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #10
    cgriffin
    Guest cgriffin's Avatar

    0 Not allowed!

    Default

    Ok, so I moved the macro definition below the Tris statement, and it works. Obviously, in PDS, using a Macro is not identical to inserting the code. I guess I'll just avoid macros, since they are unpredictable to me.

    Now here is an oddity. With the testcode loop still there in an infinite loop (with or without the Macro), if the infinite loop (both a While 1=1 and the goto) is followed by a HSEROUT command of 5 or more characters, it does not enter the loop--I have no idea what it does. Check this out...

    This works properly, and beeps continually:
    Code:
    TestLabel:
        While 1 = 1
            pChg_En = cChgOFF
            DelayMS 200 
            wBatIn = ADIn cVBat
            pChg_En = cChgON
        	GoSub Beeper
        	DelayMS 200
        Wend
    GoTo TestLabel 
            HSerOut ["1234"]
    This never beeps at all...
    Code:
    TestLabel:
        While 1 = 1
            pChg_En = cChgOFF
            DelayMS 200 
            wBatIn = ADIn cVBat
            pChg_En = cChgON
        	GoSub Beeper
        	DelayMS 200
        Wend
    GoTo TestLabel 
            HSerOut ["12345"]
    The ONLY difference is adding an extra character to the Hserout output. I even eliminated the macro all together, to make sure that wasn't it. Now, if I delete either the While or the Goto, then it works.

    Sometimes I think it'd just be easier to go 100% to assembler so I'd know 100% what's going on. How code following an infinite loop can effect the loop is beyond me. It's just not supposed to be this difficult. My sloppy basic coding should provide sloppy asm code, not malfunctioning asm code.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #11
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,689
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default

    Sometimes I think it'd just be easier to go 100% to assembler so I'd know 100% .....
    You need to press F2 now and again, If you did you will see that the only difference between the 2 loads of code are an extra

    Movlw 52
    [email protected] HRsout

    at the bottom, there is nothing wrong with that code.

    As for macro's this is why Les has not made them official.

    The solution if you want to carry on using them is to add a bank reset command to the macro to force the banks to 0

    cChgOFF MACRO
    RESET_BANK
    pChg_En = 0
    ENDM

    But this has an over head, at least it will work 100% on the 16 series
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #12
    cgriffin
    Guest cgriffin's Avatar

    0 Not allowed!

    Default

    Thanks for the tip on Reset_Bank. I might give it a try.... but can that mess up the code following the Macro? If the compiler assumes it is in a specific bank when it compiles the macro, then continues the assumption for each insertion... will the compiler not also assume that the macro does not change the bank, and cause a failure in commands following the insertion? It would seem to me that if you have to reset it for the commands internal to the macro to work, then you'd have to reset it for the commands following the macro as well.

    I do use F2, but I use it to read the LST file--which I find more helpful than the asm file. (This is how I found the ADIN bug with the 16f883, which cannot be seen in F2's asm file.)

    And because of this, I know that adding the single character to a HSerout command should only add two words to a file. The fact of the matter is that I have an infinite loop--which is an infinite While, backed up by an unconditional Goto--and adding that one character to the command following the infinite loop (so it should never be executed) prevents the loop from executing. I found, oddly, that removing either the While or the Goto allowed the loop to execute, regardless of the Hserout command...so perhaps PDS is missing some page checking. (But this seems unlikely, since it' is near the beginning of the code.)

    Either way, it's in a test loop for debugging , and I simply do not have the time to compare the output line by line to debug code intended for temporary debugging use.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #13
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,689
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default

    Basically when you issue the reset_bank macro (another one!) it forces the compiler to set the banks to bank 0.

    On the 16 series page bank switching can be an issue, as can with variables in the 18 series unless there in access ram which can be forced by adding system to the end of the dim. System vars are not an issue as they are all in access ram.

    Here are my tips for a trouble free life using macros

    12&16 series

    1 never inset chunks of code as 1 its a was of space and 2 you could get bank switching problems
    2 If you have to insert a section of code then use reset_bank at the start of the code,

    PrintResult macro
    reset_bank
    print dec vara; etc
    endm

    3 Put your macros in a section and end with reset_bank out side of the last macro

    4 If you want a neat way of calling a sub use a macro that calls the sub

    find_result macro
    gosub find_result_sub
    endm

    5 If you want to make a macro that passes parameters use Johnb's wizards they work a treat and ensure the vars are handles properly

    18 Series

    As above except you do not have to worry about Special Function Regs as they are in bank 0.

    Lastly you can use reset_bank var where var is the name of a variable
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. pickat documentation
      By davutnacikaya in forum PICKAT
      Replies: 0
      Last Post: 29th September 2019, 18:27
    2. PDS Documentation
      By jom in forum Proton Plus Compiler v3
      Replies: 19
      Last Post: 12th July 2012, 20:30
    3. [SOLVED !] Macro calling another macro inside a library
      By pdgnr in forum Library Manager
      Replies: 2
      Last Post: 27th March 2008, 08:20
    4. New command documentation
      By Alan R. in forum Proton Plus Compiler v3
      Replies: 0
      Last Post: 21st April 2005, 01:47
    5. [SOLVED !] General documentation
      By DaveM in forum Wish List / Product Feedback
      Replies: 4
      Last Post: 24th January 2004, 17:55

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts