I am stumped!!!


Closed Thread
Results 1 to 20 of 20

Thread: I am stumped!!!

Hybrid View

  1. #1

    Default I am stumped!!!

    I am using a PIC 16F628A processor, and am trying to learn how to use DT's Interrupts but here is my problem:
    If TRISB = %11111110 and PORTB %00000001 that should mean that bit 0 of PORTB is an ouput all others are input and with PORTB = %00000001 that means bit 1 is equal to one meaning high 5v and all others low, CORRECT???? Well, after check with my meter PORTB 0-7 are high or shall I say 5v, running the code below, I am experimenting with Interrupts on PORTB 4-7 wanting to detect when bits 4-7 go low and with keypad connected to PORTB 1-7, Bit 0 is an output set high going through forward through diode anode to pins 4-7 when button is pressed that particular bit is pulled low....
    DEFINE OSC 4
    CMCON = 7
    VRCON = 0
    pauseus 10
    TRISA = %00000110
    TRISB = %11111110
    PORTA = %00000000
    PORTB = %00000001
    OPTION_REG.7 = 0 'enable pullups
    OPTION_REG.6 = 0 'trigger on falling edge
    led var portA.3
    INCLUDE "DT_INTS-14.bas" ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts

    ASM
    INT_LIST macro ; IntSource, Label, Type, ResetFlag?
    INT_Handler RBC_INT, _ToggleLED1, PBP, yes
    endm
    INT_CREATE ; Creates the interrupt processor
    ENDASM

    @ INT_ENABLE RBC_INT ; enable external (INT) interrupts

    Main:
    PAUSE 1
    GOTO Main

    '---[INT - interrupt handler]---------------------------------------------------
    ToggleLED1:
    TOGGLE LED
    PAUSE 50
    @ INT_RETURN

    My explanation my seem confusing but it is early and I haven't had my COFFEE!!!!

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    If TRISB = %11111110 and PORTB %00000001 that should mean that bit 0 of PORTB is an ouput all others are input and with PORTB = %00000001 that means bit 1 is equal to one meaning high 5v and all others low, CORRECT???? Well, after check with my meter PORTB 0-7 are high or shall I say 5v,
    This is correct! You set portB.0 to be an output all remaining to be inputs, but you also have activated the internal pullup so, all inputs are high waiting your command (short to ground) while your instruction "PORTB %00000001" will have effect only on portB.0.

    Al.
    All progress began with an idea

  3. #3


    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?

  4. #4
    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

  5. #5


    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

  6. #6


    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.

  7. #7
    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