I/O - From Define to code ... must be easy


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default I/O - From Define to code ... must be easy

    Oki, so here's the question assuming the following way to define Aliases to I/O
    Code:
    DEFINE LowBeerLevel  PORTB,1
    OR
    Code:
    #DEFINE LowBeerLevel  PORTB,1
    On ASM level.

    It's still easy to use them later with MOVE?CT macro, or BSF/BCF whatever floats your boat.

    What if I wanted to use it with say I2CREAD, HIGH or whatever else PBP command?

    Tried few variants of EXT modifier thing.. but LOL...



    Seems I'm too idiot to make it work.

    I could still work on asm level... but if there's any other way, I would really like to hear them.

    Thanks!


    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: I/O - From Define to code ... must be easy

    I think the preferred way is this:
    Code:
    LowBeerLevel var portb.1
    GoToBeerStore var portb.2
     
    while !LowBeerLevel
       :):)
    while end
     
    ASM
    BSF _GoToBeerStore
    ENDASM
     
    If GoToBeerStore = 1 then
      :(
    Ok, silly example, but the point is create your var's or alias as usual, then to use in ASM block stick an underscore before the name.

    HTH
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: I/O - From Define to code ... must be easy

    You missed the DEFINE thing, however I came up with the following
    Code:
            DEFINE  SData   PORTB,1
            DEFINE  SClock  PORTB,2
    And then in the compilation time section you use
    Code:
    CreateVar   MACRO    PortIn,BitIn, PortOut, BitOut
    PortOut = PortIn
    BitOut = #V(BitIn)
            ENDM
            ;
            ;
            ;     somewhere later
            ;
    @       CreateVar SData, SerData, DataBit
    @       CreateVar SClock, SerClock, ClockBit
            
            SerData   VAR BYTE EXT
            DataBit   CON      EXT
            SerClock  VAR BYTE EXT
            ClockBit  CON      EXT
    just need to use 'em like
    Code:
    HIGH SerClock.0[ClockBit]
    It has some success, ugly... and we also know this method is not going to work all the time... good example? Shiftout

    Keep thinking...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: I/O - From Define to code ... must be easy

    I think of some other ways, but it's damn too much coding for a so simple thing The asm side's still good enough though. It would have been soo easy if we could do
    DEFINE LCD_EN_LINE PORTC,1
    and then
    LCD_EN_LINE VAR BIT EXT... BUT NOPE
    OR
    even easier.. have them ready to use, nothing to hack...

    Why I do prefer the DEFINE way... hahaha, I have no idea Probably to fit with PBP LCDOUT, HSEROUT, DEBUG etc etc etc
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    This will blink an LED on any pin, as specified in the BLINK_TEST define.
    If the define is commented out, it will bypass the blinky and start at the main program.
    Code:
    DEFINE BLINK_TEST PORTB,0
    '
    ' Variables, Constants etc.
    '
    ;----[Blinky test]------USE( DEFINE BLINK_TEST PORTB,0 )-----------------
    BLINK_LED VAR BIT EXT
    @ #undefine BLINK_LED
    @ #define BLINK_LED BLINK_TEST
    @ ifdef BLINK_TEST
        INCLUDE "AllDigital.pbp"
        Blink:
            TOGGLE BLINK_LED
            PAUSE 500
        GOTO Blink
    @ endif
    DT

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: I/O - From Define to code ... must be easy

    hhhhhhhhhhhhhhhhhhhhhaaaaaa! I knew it was something "easy", just never though of the #undefine twist...mmm... something else to chew on


    Thanks Mr Tech Support
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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