I am stumped!!!


Closed Thread
Results 1 to 20 of 20

Thread: I am stumped!!!

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Thank you for clarifying that, I've spent all of Saturday trying to figure this out. Have you time for another question? If so, with the above setup why upon startup does my led blink?

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    with the above setup why upon startup does my led blink?
    Cannot answer without the schematic. Post how you wired your system, and I will try to give you an answer.

    Al.
    All progress began with an idea

  3. #3


    Did you find this post helpful? Yes | No

    Default

    I have a keypad, 3 rows, 4 columns, my rows are connected to PortB bits 1-3, the columns are connected to PortB bits 4-7. I set PortB.0 to 1 (high) feeding four 1n4148 diodes anode to PortB.0 cathodes to bit 4-7. When a button is pressed on the keypad it pulls whichever pin 4-7 low. I have OPTION_REG.6 = 0 to trigger on the falling edge.


    Thanks

  4. #4


    Did you find this post helpful? Yes | No

    Default

    keypad ohms out good, brand new actually, but as I mentioned before PortB.1-3 are my rows and 4-7 are my columns with the above code, pressing a button on the keypad does not pull any pin low.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    I changed TRISB = %11111110 to TRISB = %11110000 now pressing keypad the selected PORTB 4-7 pulls low to 2.2VDC, by the way PORTB.0 is connect first in series with a 330 ohm resistor, then to the four 1N4148's. I thought limiting the current to 15mA would be easier on the internal pull-ups.

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Thanks for the drawing, that is how this is connected, yes I am aware of "scanning the keypads" Bruce has been a great help, but I am just narrowing it down to pressing on button, pins 1-3 low, and pin 0 high just to see how interrupt's work. I am looking to use the interrupt to sleep all the time, detect when key is pressed, wake up, set PORTB.0, and 4-7 as inputs, bits 1-3 as out, pause about 50, then began scanning keypad something like this:

    recycle:
    @ Sleep
    @ NOP
    @ NOP
    goto recycle

    ' my Interrupt handler
    search:
    PORTB = 0
    TRISB = $f1
    PAUSEUS 10
    keypadscan:
    FOR row = 1 TO 3
    PORTB = 0
    TRISB = (DCD row) ^ $fe
    col = PORTB >> 4
    IF col != $f THEN keypressed
    NEXT row
    GOTO recycle

    Haven't got all this worked out yet, but thats another day

  7. #7


    Did you find this post helpful? Yes | No

    Default

    I'm just stumped with the original code above why am I already in the interrupt when I power up, just to confirm that I changed the INT handler to:
    '---[INT - interrupt handler]---------------------------------------------------
    ToggleLED1:
    TOGGLE LED
    pause 50
    @ INT_RETURN

    and sure enough the led is flashing...

    By the way, what program are you using to upload your schematic?

  8. #8
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    I don't know how you want to connect your 3x4 keypad but the way you did explain is not going to work.

    See the attached schematic. You have to put portB.1 to portB.3 (one at the time) to be an output and set it to low.
    If you push one key of your keypad then the interrupt will detect the change (portB.4/7 going low) and will jump in the interrupt subroutine where you will decode the key, knowing which portB.1/3 was active low and which portB.4/7 was activated.

    Al.
    Attached Images Attached Images  
    All progress began with an idea

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