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.

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;
}
 

No requirement of resistor between input pin and ground.
 

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top