Discussion in "Project Help" started by    hiast    Jun 16, 2016.
Thu Jun 16 2016, 08:28 pm
#1
help please
how do i initiate port 3 as an input port in assembly?
acutely there is push switch connecting to p3.2
push switch connecting to p3. 3
push switch connecting to p3.4
push switch connecting to p3.5
and i need to call function when the user pressed the push switch for the previous pins (not used as counter and not as timer… just call a function ( do special thing) when any push switch is pressed ???????
Fri Jun 17 2016, 05:49 pm
#2
I don't your applications . But below should help you .

      org 0000h
      SETB  p3. 3             ;   Configure as Input
      SETB  p3. 4             ;   Configure as Input
      SETB  p3. 5             ;  Configure as Input
HERE:
       JNB P3.3,STEP1       ; If SW1 Goes Low to STEP1
       JNB P3.4,STEP2       ; If SW2 Goes Low to STEP2
       JNB P3.5,STEP3       ; If SW3 Goes Low to STEP3
      SJMP HERE
STEP1 :
      ACALL FUN1
      SJMP HERE
STEP2:
      ACALL FUN2
      SJMP HERE
STEP3:
      ACALL FUN3
      SJMP HERE
;  
FUN1:
     RET
;
FUN2:
     RET
;
FUN3:
     RET
     END



--
Karan


[ Edited Fri Jun 17 2016, 05:50 pm ]
 hiast like this.
Fri Jun 17 2016, 08:55 pm
#3
thanks for help,
i wanted to write this code as you did, but i was doubt about it , so i did't and i writen this code
the project is to interface with 4*3 keypad connected to port 1 and there are 4 push switch connected to count0, count1 EXT0 and EXT1 ,to select the operation DIV , MUL , SUB and ADD respectively
so counter 0 is / operation
counter 1 is * operation
EXT0 is - operation
EXT1 is + operation


what i need is just to cal function 1 if and if the user pressed the * operation and
cal function 2 if and if the user pressed the / operation ........ and extra
and return to the main function after this function is finish ( i think the return should be by RETI ? )


i write this first code

ORG 0H
JMP START
ORG 03H ; External 0 vector address
LJMP FLAG_SUB
ORG 0BH ; Timer 0 vector adress
LJMP FLAG_DIV
Org 13H ; External 1 vector adress
LJMP FLAG_ADD
ORG 1BH ; Timer 1 vector adress
LJMP FLAG_MUL
START: LCALL MAIN
ORG 37
MAIN:
;
; do something
; in any line of the main code if user pressed the push switch ( counter 0 or counter 1 or EXT0 , EXT1 ) the assembler
; should go to function and return again to here after finish
LJMP MAIN


FLAG_SUB:
; do somthing
RETI

FLAG_DIV :
; do somthing
RETI
FLAG_ADD:
; do somthing
RETI
FLAG_MUL:
; do somthing
RETI

END


i think what i write is wrong and i have to replace it with your code .. your code is right !!!!

thanks for your help
i will replace my code and put yours ... thanks again
Tue Jun 21 2016, 10:10 am
#4
I am not Getting you . the project is to interface with 4*3 keypad connected to port

Do you know how to interface 4*3 Keypad in Assembly . ?
4 Push Switch ??
Where you see output ??
--
Wed Jun 22 2016, 06:28 am
#5
You could use T0 and T1 to trigger interrupts but it would stop you using Timers 0 and 1
which would be a waste.
Just connect * / + and - to port pins.. say P1,2,3,4 and poll them as you do the keyboard.

Normally, on a calculator, you do the calculation when you press the '=' key.



Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am
Anthonyvab
Wed Apr 17 2024, 08:48 am
RobertCix
Wed Apr 17 2024, 06:46 am