4x4 Matrix Keypad Controller PIC with LED Confirmation of Data Received


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262

    Default 4x4 Matrix Keypad Controller PIC with LED Confirmation of Data Received

    I started out with a 74c922 but that didnt work many problems, so I designed this. it requires the PIC its hooked up to to receive the data after a pulse has been sent to its IRQ pin, then after the data has been received the PIC must send a pulse back to the Controller PIC's IRQ (RB0) to clear the data (which will let the user know data was sent and received by the LED)

    Looking for some of you more knoledgeable programmers to tell me if you see a problem, or a better way, etc.... I am using the "On Interrupt's" right now till I get that down then I will learn that other package for IRQ's

    Basic layout of code on the External PIC
    Code:
    ON Interrupt goto handler
    handler
    read data in on 4 pins your choice and store in a variable
    send a high to RB0 on the Controller PIC with a pin of your choice
    pause 10
    exit handler
    resume
    now for the Controller PIC's Code
    Code:
    TRISA = %11110000
    TRISB = %00000001
    OUT VAR Byte
     
    on Interrupt Goto MYINT ' Define interrupt handler
    INTCON = $90 ' Enable INT0 interrupt
    OPTION_REG = $7f 'PORTB Pull Up
    LOOP:
    '************Clear All data**************************
    PORTA = 0
    out = 16
    PORTB.1 = 0
    PORTB.2 = 0
    '************Data Cleared, Start Data Collection*****
    PORTB.4 = 1
    if PORTA.4 = 1 then out = 0
    if PORTA.5 = 1 then out = 1
    if PORTA.6 = 1 then out = 2
    if PORTA.7 = 1 then out = 3
    PORTB.4 = 0
    PORTB.5 = 1
    if PORTA.4 = 1 then out = 4
    if PORTA.5 = 1 then out = 5
    if PORTA.6 = 1 then out = 6
    if PORTA.7 = 1 then out = 7
    PORTB.5 = 0
    PORTB.6 = 1
    if PORTA.4 = 1 then out = 8
    if PORTA.5 = 1 then out = 9
    if PORTA.6 = 1 then out = 10
    if PORTA.7 = 1 then out = 11
    PORTB.6 = 0
    PORTB.7 = 1
    if PORTA.4 = 1 then out = 12
    if PORTA.5 = 1 then out = 13
    if PORTA.6 = 1 then out = 14
    if PORTA.7 = 1 then out = 15
    PORTB.7 = 0
    if out < 16 then goto send
    Goto loop 'No Buttons Pressed, Check Again
    'Loop will continue to send pulse for data ready till OUT = 16 (see MYINT)
    SEND: 
    PORTA = out 'Will output to PORTA 0 - 3
    if out > 15 then goto loop 'Failsafe for Bad Data
    PORTB.1 = 1 'Send Data Ready Pulse for External Microprocessor's INT0 (RB0)
    pause 5
    PORTB.1 = 0 'Clear Pulse & External Microprocessor will run its Interrupt
    goto send
    ' ****** Interrupt handler *******
    Disable ' No interrupts past this point
    MYINT: 'Should only be triggered during the SEND loop
    out = 16 'Sets OUT to default, when returned to SEND loop, returns to LOOP
    PORTB.2 = 1 'Signal Received LED ON
    pause 1000 ' will be changed to 25 after program tests good.
    PORTB.2 = 0 'Signal LED OFF
    INTCON.1 = 0 ' Clear interrupt flag
    Resume ' Return to main program
    Enable
    Tell me what you think, ideas, options, etc...

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 4x4 Matrix Keypad Controller PIC with LED Confirmation of Data Received

    You will want to get out of the habit of using LOOP as a label, in PBP3 LOOP in an instruction.

    Is is best to get out of an ISR as fast as possible, set a flag for the main routine if a long (time wise) instruction needs carried out. Using ON INTERRUPT gets around this problem and you can get around it when using ASM interrupts but you will find it troublesome. So I would get rid of the PAUSE in the ISR all together.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: 4x4 Matrix Keypad Controller PIC with LED Confirmation of Data Received

    ok i got that, moveing that out of the ISR is no problem.

Similar Threads

  1. 8x8 keypad matrix...
    By mbox in forum General
    Replies: 5
    Last Post: - 9th October 2014, 18:43
  2. display received data
    By NURULHAIZA in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th May 2010, 06:03
  3. Replies: 5
    Last Post: - 24th June 2009, 03:01
  4. 3x4 matrix keypad
    By tazntex in forum Serial
    Replies: 3
    Last Post: - 14th October 2008, 20:13
  5. Need help in matrix keypad coding
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 24th May 2008, 13:16

Members who have read this thread : 1

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