Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Initialize AT89C2051 port!!!

Status
Not open for further replies.

c3cube

Newbie level 4
Joined
Feb 9, 2006
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,356
What should I write to initialize port 3 as input port in assembler language??? Actually, I only need P3.0 to turn on a stepper motor using a remote control.
 

kannan.k

Junior Member level 2
Joined
Jan 17, 2006
Messages
24
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Location
chennai, India
Activity points
1,541
Hi

To make a port as an input port you have to just write '1' to that pin/port and then read the status.

Code:
       setb P3.1   ;write 1 to the port
       jb p3.1 set   ;check if it is 1 or 0
       nop ;bit is not set ie input is 0
       sjmp con
set:   nop ;bit is set ie input is 1

con:
       ;rest of the code
 

c3cube

Newbie level 4
Joined
Feb 9, 2006
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,356
I've tried, but it's not working!!! Any other mothods????
 

silvio

Advanced Member level 3
Joined
Dec 31, 2001
Messages
715
Helped
105
Reputation
210
Reaction score
16
Trophy points
1,298
Location
Romania
Activity points
11,468
c3cube said:
I've tried, but it's not working!!! Any other mothods????

c3cube can you post your code / schematics ?

You only need P3.0 to turn on a stepper motor ???? How do you suppose to do that ? A stepper motor ?
However, if P3.0 is used as output why do you need to initialize port P3 as input ?
 

c3cube

Newbie level 4
Joined
Feb 9, 2006
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,356
The P3.0 is used to give a switch ON signal to turn on the stepper motor which is connected to Port 1.
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,929
Helped
2,311
Reputation
4,624
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,416
Assuming that a momentary switch is connected between P3.0 and GND ..

SETB P3.0

LOOP: JB P3.0, LOOP
..
cont ..

when you press the switch P3.0 becomes "0" for a while, microcontroller will leave the LOOP and continue with Stepper Motor control ..

Regards,
IanP
 

eehero

Full Member level 3
Joined
Nov 23, 2005
Messages
169
Helped
13
Reputation
26
Reaction score
5
Trophy points
1,298
Location
Libya
Activity points
2,620
Re: Initialize AT89C2051 port!!! by eehero

Try my standard code for AT89c

;#############written by Ali Mustafa Naas for help#######################
;########################################################################
$TITLE(LED flashing.asm)
$MOD51
$NOPRINT ; to see error on screen, if any errors found
$INCLUDE(MYPAULM2.EQU) ;address of PAULMON2 utility routines
$LIST ; overrided by $NOPRINT

;####################################################
;RESET ROUTINE
ORG 0000H ;locate routine at 00H
AJMP MAIN ;jump to START

;####################################################
;Interrupts (i will not use them here)

ORG 03H ;external interrupt 0
RETI
ORG 0BH ;timer 0 interrupt
RETI
ORG 13H ;external interrupt 1
RETI
ORG 1BH ;timer 1 interrupt
RETI
ORG 23H ;serial port interrupt
RETI
ORG 25H ;locate beginning of rest of program


;#####################################################

INITIALIZE: ;set up control registers & ports
MOV TCON,#00H
MOV TMOD,#00H
MOV PSW,#00H
MOV IE,#00H ;disable interrupts


RET


;######################################################

;**************************************************************************
;
DELAYMS: ;millisecond delay routine
; ;
MOV R7,#00H ;put value of 0 in register R7
LOOPA:
INC R7 ;increase R7 by one (R7 = R7 +1)
MOV A,R7 ;move value in R7 to Accumlator (also known as A)
CJNE A,#0FFH,LOOPA ;compare A to FF hex (256). If not equal go to LOOPA
RET ;return to the point that this routine was called from
;
;**************************************************************************

;#######################################################

loop:
ACALL INITIALIZE
SETB p1.0 ; here port p1.0 is initialized as input
SETB p1.2 ; here port p1.2 is initialized as input also
;note: the initialization of the ports may be done in the INITIALIZE sub-routine
; instead of the main loop,there is no difference,.
; At the normal case all ports are initailized output port.

#######write your code here#####################
END

good luck
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top