PDA

View Full Version : argh .. can anyone help a newbie here?


dan
12-17-01, 10:22 AM
i've been trying to program the keypad which is part of my security system project but can't seem to get it right. I've made my own keypad it seems to work fine.. the logic of my program seems correct and can compile with no problem .. but when i try to download it to the HC11 board .. NMIT0020 .. it doesn't wanna accept it ..is there a kind soul out there that could help me :)

heres the program in assembly ..

PORTA EQU $1000
PORTD EQU $1008
PORTDDR EQU $1009
PORTE EQU $100A

BIT0 EQU $01
BIT1 EQU $02
BIT2 EQU $04
BIT3 EQU $08
BIT4 EQU $10

*Bits representing respective values on keypad
* 1=B0 2=B0&B1 3=B1 4=B2 5=B2&B3
* 6=B3 7=B4 8=B4&B5 9=B5 0=B6

COMB1 EQU %00000001 ;1
COMB2 EQU %00000010 ;3
COMB3 EQU %00110000 ;8
COMB4 EQU %00001000 ;6

ORG $01F0
COUNTER RMB 1

*Main Program
ORG $0000

LDAA #%00011100
STAA PORTDDR

BEGIN LDS #$014A
LDAA #$0
STAA PORTD
STAA PORTA

COUNTIMES LDAB #$03
STAB COUNTER


DETECTIN_1 JSR KEYPADIN
CMPA #$0
BEQ DETECTIN_1
CMPA COMB1
BEQ DETECTIN_2

MISTAKE JSR WRONG
DEC COUNTER
BEQ SIREN
JMP DETECTIN_1


DETECTIN_2 JSR DEBOUNCE
JSR KEYPADIN
CMPA #$0
BEQ DETECTIN_2
CMPA COMB2
BNE MISTAKE
JMP BEGIN


*Wrong input subroutine
WRONG LDX #$1000
BSET $08,X BIT2
PSHX

LDX #$000B
XREG LDY #$FFFF
YREG DEY
BNE YREG
DEX
BNE XREG

PULX
BCLR $08,X BIT2
RTS


*Siren
SIREN BSET $00,X BIT4
JMP COUNTIMES


*Keypadin
KEYPADIN LDAA PORTE
RTS


*Debounce
DEBOUNCE LDX #$000B
XREG1 LDY #$FFFF
YREG1 DEY
BNE YREG1
DEX
BNE XREG1
RTS

sigh .. seems pretty hard to read from the preview eventhough i got the margin nicely aligned .. anyway heres the attached .txt file which is much easier to read

:)

dan
12-17-01, 10:29 AM
the text file

nmitech
12-17-01, 11:20 AM
Due to the conflict of your program address with the on board operating system storage area of the Buffalo monitor. This caused the download problem. Simply change your code address to where your free ram is availble then it should work.

If your sytem has 32Kbyte ram on the lower memory, you may put the ORG $2000.

If you only have 8Kbyte ram then just moves the ram to U3 socket put the ORG $C000.

Follow the manual to setup the jumpers properly for different memory device sizes.

http://www.newmicros.com/images/nmi-logo-small.gifTech

dan
12-18-01, 12:00 PM
thanks for the help.. :)

but now i discovered that the program runs fine when theres no looping ..(i've tried simple programs that doesn't loop) .. but when it runs in a loop it doesn't seem to accept it .. it hangs on the command 'done' in the maxterm download program

any suggestions on solving it?

thanks again

nmitech
12-18-01, 01:15 PM
Did you move the ORG of your program address to the free ram area? I guess not! It may run on the unlooping program because your program is small enough to fit in $0000-$002D (buffalo V3.4) or luckier to fit in $0000-$0036(buffalo V2.3) where the free internal ram area that unused by buffallo monitor. Your program probably write over the buffalo storage area (stack, variables, etc...) that caused the system crashes.

http://www.newmicros.com/images/nmi-logo-small.gifTech

dan
12-20-01, 06:33 PM
got it :) .. everythings a-ok now

dan
12-28-01, 02:49 AM
why is it that sometimes my program executes fine sometimes but other time doesn't?

i've checked n rechecked the jumper settings and U3 slot for the 8kb RAM and they all seem to be correct .. so i don't think thats the problem. When i run portions of the program it executes fine. But when i run the whole program it only executes fine sometimes... like out of 30 times i download it, it works for 3-4 times. the start address i use is C000 for the 8kb RAM and my program size is about 200 lines.

any solution to this problem?

nmitech
12-28-01, 09:26 AM
I suggest to put your stack at #$DFFF instead of #$014A and move the variable COUNTER to the free ram area just for the safe side. Also make sure PE0 is pull low.

dan
12-29-01, 10:08 AM
thanks again :) .. all running smoothly now