Menu

PORTX.Y as function parameter ?

Help
2015-03-01
2015-03-01
  • Jacques Nilo

    Jacques Nilo - 2015-03-01

    Hello all !
    I am trying to check the status of several push buttons with basically the same treatment. I initially tought I could do something along the following line:

    ;Chip Settings
    #chip 16F690, 8
    #config FOSC_INTOSC, WDTE_OFF
    
    #define Red_button      porta.0         ;Set red pushbutton
    #define White_button    porta.1         ;Set white pushbutton
    ;#define other buttons
    
    Dir Red_button   In
    Dir White_button In
    
    Sub Test_button(Button)
      If Button On Then
    ;   Some treatment here
      End if
    end sub
    
    do
     Test_button(Red_button)
     Test_button(White_button)
    ; test other buttons
    loop
    

    But this does not work (compiles ok but get "Symbol does not exist" msg when assembling).
    Any idea for a work around ?

     
  • Anobium

    Anobium - 2015-03-01

    Very easy to overlook. An equals sign in your if-then statement. You need to ensure you have a complete conditional test.

    Sub Test_button(Button)
    If Button = On Then
    ; Some treatment here
    End if
    end sub

    Anobium

     
  • Jacques Nilo

    Jacques Nilo - 2015-03-01

    My bad :-)
    Thanks Anobium

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.