HCS12 ASM assembly language keypad to seven segment

Thread Starter

someone_else

Joined Jun 3, 2018
3
I will upload the assignment and how far I've gotten I need help working my keypad out I haven't been able to find any information to help me in ASM language.

Code:
#include C:\dragon12_plus2\DRAGON12_Plus2_B\LCDRoutines_SP17.asm
;*******************************************************************************************
;*******************************************************************************************
  ORG  $1000
TEMP:  RMB  1
CURRENT_KEY:  RMB  1
CURRENT_7SEG  RMB  1
DEC_NUM  FCB  00,  01,  02,  03,  04,  05,  06,  07,  08,  09,  10,  11,  12,  13,  14,  15  ; FOR 7 SEG
HEX_NUM  FCB  $3F, $06, $5B, $4F, $66, $6D, $7D, $07, $7F, $67, $77, $7C, $39, $5E, $79, $71  ; FOR 7 SEG
;*******************************************************************************************
;*******************************************************************************************
FIRST_LINE  FCC  "Enter 4 digit  "
SECOND_LINE  FCC  "Press PH2 RESET "
;*******************************************************************************************
;*******************************************************************************************
  ORG  $2000
  JMP  MAIN
;  ORG  $1100  ;Keypad Look-up Table
;KCODE0  FCB  $31,$32,$33,$41  ;"123A"
;KCODE1  FCB  $34,$35,$36,$42  ;"456B"
;KCODE2  FCB  $37,$38,$39,$43  ;"789C"
;KCODE3  FCB  $2A,$30,$23,$44  ;"*0#D"
;*******************************************************************************************
;*******************************************************************************************
SETUP
  LDAA  #$FF
  STAA  DDRB
  STAA  DDRJ
  STAA  DDRP
 
  LDAA  #$FF
  STAA  PORTB
  STAA  PORTJ
  STAA  PORTP
 
  LDAA  #$0F
  STAA  DDRA
  BSET  PUCR, 1
 
  RTS

;*******************************************************************************************
;*******************************************************************************************
DISP_7SEG
  LDAA  CURRENT_7SEG
  STAA  PORTB
  LDAA  #$0E
  STAA  PORTP
 
  JSR  DELAY_10ms
  LDAA  #$0D
  STAA  PORTP
 
  JSR  DELAY_10ms
 
  LDAA  #$0B
  STAA  PORTP
  JSR  DELAY_10ms
  LDAA  #$07
  STAA  PORTP
 

  JSR  DELAY_10ms
 
  RTS
;*******************************************************************************
;*******************************************************************************
DISPLAY_START
  LDX  #FIRST_LINE
  LDAB  #16
  JSR  LCD_LINE1
  LDX  #SECOND_LINE
  LDAB  #16
  JSR  LCD_LINE2
  RTS


;*******************************************************************************************
;******************************************************************************* 
 
SCAN_KEYPAD
SCAN_AGAIN  LDAB  #15
  LDAA  #$F7
  STAA  TEMP
 
NEXT_ROW  STAA  PORTA
  JSR  DELAY
  LDAA  PORTA
  ANDA  #$F0
 
  CMPA  #$F0
  BNE  KEYIN
 
  DECB
  CMPB  #11
  BEQ  NO_KEYIN
  ROR  TEMP
  LDAA  TEMP
  BRA  NEXT_ROW
 
NO_KEYIN  CLC
  BRA  SCAN_AGAIN
 
KEYIN  ROLA
  BCC  KEY_OK
  SUBB  #4
  BRA  KEYIN
 
KEY_OK  SEC
  STAB  CURRENT_KEY
  STAB  PORTB
 
  RTS
 
;*******************************************************************************************
;*******************************************************************************************
CONVERT_7SEG  ; CONVERT YOUR DAMN 7 SEG WITH THIS SUB ROUTINE
  LDX  #DEC_NUM  ; THIS WILL LOAD INTO Y WHICH WILL HELP US LATER
  LDY  #HEX_NUM  ; LOAD UP A TEMP NUMBER
  LDAA  CURRENT_KEY  ; CHECK NEXT WILL BRANCH HERE FROM BELOW IF NOT FOUND
CHECK_NEXT  CMPA  0,X  ; IF ITS NOT GOOD WILL BRANCH TO INX
  BNE  NEXT_PAIR
  BEQ  MATCH  ; IF WE HAVE A MATCH WE WILL LOAD 0,Y
NEXT_PAIR  INX
  INY
  BRA  CHECK_NEXT
MATCH  LDAA  0,Y
  STAA  CURRENT_7SEG
  RTS
;*******************************************************************************************
;*******************************************************************************************
MAIN
  JSR  SETUP
  JSR  DISPLAY_START
MORE_KEYS  JSR  SCAN_KEYPAD
  JSR  CONVERT_7SEG

AGAIN  JSR  DISP_7SEG
  BRA  AGAIN

  BRA  MORE_KEYS
  END

;*******************************************************************************************
;*******************************************************************************************
Moderator edit: added code tags
 

Attachments

Thread Starter

someone_else

Joined Jun 3, 2018
3
I wrote this program but I am not understanding how to get my keypad to write to my 7 segment I have to create a security system where you put in a 4 digit code in 7 segment and it either confirms or denies that the code is inputted correctly
 

MrChips

Joined Oct 2, 2009
34,765
Try to think modular. Break your project down into functional modules and work on one module at a time. Each module is independent from all other modules.

A keyboard is one module. The four-digit 7-segment display is another module. Forget the fact that you are designing a security system for the time being.

Show how your MCU is connected to the 7-segment display using a circuit diagram. Write the simplest code to output numbers such as 1234 on the display.
 

Thread Starter

someone_else

Joined Jun 3, 2018
3
okay I have it running now and set up so it accepts the number and you can press ph2 to reset but they want me to put ph3 to save which is on the same button not really sure how to do that and when writing i'm not sure weather to make ph3 its own subroutine so I can have its beq and bne to transfer to something around it but i'm still not sure how to store the numbers I have put into the code
 

JohnInTX

Joined Jun 26, 2012
4,787
Welcome to AAC!
The original poster has not been back so you probably will not get an answer. If you like, start a new thread and ask your question there.
Good luck!
 
Top