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.

defining the input of a microcontroller

Status
Not open for further replies.

Ogu Reginald

Full Member level 6
Joined
Oct 7, 2011
Messages
369
Helped
47
Reputation
94
Reaction score
46
Trophy points
1,308
Location
Nigeria
Activity points
3,391
Hi everyone, below is a portion of my code on how I defined the input of AT89S52 microcontroller. Also attached is the circuit diagram. My questions are:
1. Is it necessary add a resistor between the input of the microcontroller and the ground in other to make the input of the microcontroller be well defined at all times.
2. Must I always write a logic one in the code in other to configure the pins as input.
3. The way I defined the pins in the main program, is it alright.

Please if there needs to be adjustment anywhere let me know, thank you Code.jpg


Here is the code:

#include<reg51.h>
sbit low=P1^0;
sbit high=P1^1;
sbit danger=P1^2;
sbit emergency=P1^3;

void delay(int delay_time) // Time delay function
{
int j,k;
for(j=0;j<=delay_time;j++)
for(k=0;k<=1000;k++);
}

void main(void)
{
low=high=danger=emergency=1;
}
 

Debasis Swain

Member level 2
Joined
Feb 2, 2013
Messages
52
Helped
10
Reputation
20
Reaction score
10
Trophy points
1,288
Activity points
1,606
No requirement of resistor between input pin and ground.
 

welove8051

Full Member level 6
Joined
Jul 16, 2009
Messages
357
Helped
51
Reputation
102
Reaction score
41
Trophy points
1,308
Location
india
Activity points
3,277
1. Is it necessary add a resistor between the input of the microcontroller and the ground in other to make the input of the microcontroller be well defined at all times.
2. Must I always write a logic one in the code in other to configure the pins as input.
3. The way I defined the pins in the main program, is it alright.

1, no need. the i/o pin by default will be in logic 1 for i/p.
2, no need for 8051. but its good practice to follow
3, ok
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top