button pullup/down resistor?


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Simplified, and still not working.

    Code:
    DEFINE OSC 4
    
    ' Define LCD registers and bits
    DEFINE  LCD_DREG        PORTC            'LCD addressing
    DEFINE  LCD_DBIT        4                'L1 = $80         
    DEFINE  LCD_RSREG       PORTD            'L2 = $C0 
    DEFINE  LCD_RSBIT       2                'L3 = $94
    DEFINE  LCD_EREG        PORTD            'L4 = $D4
    DEFINE  LCD_EBIT        3
    
    TRISD = %10000000
    but	var portd.0
    
    lcdout $fe,1
    Start:
    
    if but = 0 then
      lcdout $fe,$8A,"On "
    else
      lcdout $fe,$8A,"Off"
    endif
    
    goto start
    Shows "off" on the screen until I press the button - then says "on" and stays that way, even after button released

    I went back to a 4Mhz clock, and have measured voltages and resistances to ground and +5v on d.0 (pin 19)

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by davewanna View Post
    Code:
    TRISD = %10000000
    Take a good hard look at that line.

  3. #3
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Hmmmm

    I'm a dickhead...

    I'm trying to make RF work, and I don't even know how to set a TRIS.....

    So after reading the datasheet again, and doing some tests... It seems I've been setting the TRIS as LSB first, when it should be MSB first... Correct?

    Must just be pure luck that my previous projects have worked.

    Thanks Skimask.. You've been a big help on most all of my queries so far.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by davewanna View Post
    I'm a dickhead...
    I wouldn't go that far!

    So after reading the datasheet again, and doing some tests... It seems I've been setting the TRIS as LSB first, when it should be MSB first... Correct?
    It was either that or you had your ins and outs mixed up.
    1 = input = because it looks like the letter I for input
    0 = output = because it looks like the letter O for output
    MSB is on the left, just like in a regular written number (unless it's in Arabic...or are those read left to right also? Not sure...)....LSB on the right...

  5. #5
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    I would go that far... you see, that also means, that my nIRQ interrupt pin that would not go high, no matter what, was also assigned as an output... And that is a problem that i have spent a lot of time on.

    I'm sure there's a saying somewhere about the worst problems are ones that you cause yourself.


    You will be pleased to know also that I have stopped re-inventing the wheel. And am now using shiftin/shiftout for my RFM12. I am currently receiving something, it's not what I am transmitting yet, but it's a start. I had actually missed your earlier post in my other thread recommending to use shiftin/shiftout. If I had have seen that, it would also have saved me a lot of time.

    I can now go and try to work out how much of this received info is status bits, and how much is actual received data.

    Anyway skimask, you are my new hero... Mister_e is back to number 2... haha

  6. #6
    Join Date
    Apr 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    I'd rather code the button to debounce something like below:
    CHECK_PB:
    IF PB = 0 THEN DEBOUNCE_PB
    RETURN

    DEBOUNCE_PB:
    PAUSEUS 200
    IF PB = 0 THEN CHECK_PB

    MENU_CNT = MENU_CNT + 1

    RETURN
    and before that I would prefer to make the pin connected to button as output..

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by abidr View Post
    I'd rather code the button to debounce something like below:
    True...but the thing has to be working halfway in the first place...then all the options can be added...
    No sense in having spanky shiny rims on a car without an engine?

Similar Threads

  1. Sony SIRC IR Issue
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th August 2015, 08:10
  2. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43
  3. Code check -- button not working
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 2nd March 2006, 22:43
  4. Button Push within 3 second Window
    By Tissy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd December 2005, 10:06
  5. Button subfunction 16F628
    By Jųan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th August 2005, 16:44

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