IF - WHILE and variables


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    flotulopex, Some more code would be nice... I havent had any problem with the way you are using them.. Some more code however might solve the problem...

    Dave Purola,
    N8NTA

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


    Did you find this post helpful? Yes | No

    Default

    I know what you want to do, but unfortunately you can't do it.

    What you want it's something like
    MakePORTB CON PORTB & %00111110

    but this will not compile. What you may do is use a Macro, but there's no advantage in this case.

    btn_x = PORTB & %00111110
    Work, but only where it is called.

    You may use A timer interrupt to refresh btn_x, but still, there's no real advantages, and you also need another variable to confirm that btn_x have been refreshed.

    Assuming you want to poll some push buttons, then yes Timer interrupt could be interesting. That's how I deal with them most of the time.

    You can use the timer interrupt to read the push buttons, to confirm that it's not just a glitch and then, to do the debouncing. Now we talk
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Code:
    btn_x = PORTB & %00111110
    If btn_x=2 would mean that the other inputs are all low, but PORTB.1
    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