Burglar Alarm LCD and Keypad ASM

Discussion in 'Programmer's Corner' started by skusku, Mar 1, 2013.

  1. skusku

    Thread Starter Well-Known Member

    Aug 9, 2009
    Hi guys

    I am having a problem. This is a burglar alarm with keypad and lcd in ASM for a PIC16F628a.
    I included a zip file with the code and I am using PIC Simulator IDE with a screenshot for the LCD settings.

    I got the base code from Nigels tutorial and adapted it quite a lot.
    Ok lets start with how it works etc...
    Once the program runs, it shows "ALARM DEACTIVATED" and waits for the code to be entered. The correct code is "AAA0" at this stage. Enable RB0, RB1 and RB2 (now the programs reads that no keys are pressed).
    Disable RB0, Enable RB0 - This gives us the "A" key (Do this 3x)
    Disable RB1, Enable RB1 - This gives us the "0" key

    Now the LCD shows "ACTIVATED"
    The beam is set to be on RB3, so once you enable RB3 and then disable RB3 (To simulate a beam has been triggered) the LCD should show "ALARM" and then activate RA6 which is the siren.

    Ok now for the problem, When you leave RB3 enabled it keeps on going in a loop and I get a Hardware stack overflow error.

    Otherwise the rest of the program is looking alright(ish) there is also an error where the RA6 deactivates momentarily while you press a key. But lets skip that for now.

    The loop with the problem occurs between BEAM and ALARM in the code.

    Anybody to please help me get rid of the Hardware stack overflow error please. I don't know how to get passed the Level stack limit, I'm assuming a call instruction is being called over and over with no return, but Im clueless.

    This is a long(ish) code, for me anyways. Im still learning. Would appreciate any help.

    Thanks guys.

    Edited. OK seems I solved the problem I was having.
    Last edited: Mar 2, 2013
  2. Markd77

    Senior Member

    Sep 7, 2009
    Look for a return where there was no call. I think I found one where you goto keys, which then has a goto keyfound and in keyfound there is a return.
    Return without call = stack overflow if you do it repeatedly.
  3. skusku

    Thread Starter Well-Known Member

    Aug 9, 2009
    Thanks for your help Markd