Continue to Site

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.
 

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
 

I've tried, but it's not working!!! Any other mothods????
 

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 ?
 

The P3.0 is used to give a switch ON signal to turn on the stepper motor which is connected to Port 1.
 

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
 

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

Back
Top