while taking input to 8051,in C,i used to never send a '1' to the port latch.now i know the architecture and realized that i had to send a 1 to the latch.but even when i did'nt do this the inputs used to be proper external inputs.how is this possible?does the compiler put an extra instruction wherever the inputs are taken?
I don't believe compilers set it to a 1 before an input. More likely you are just forcing the I/O to a specific level. The input buffer is always active and will read the actual level of the pin regardless of the output buffer setting. Setting the output buffer high or tristate allows the input to override the output level and be read correctly. If the output is left set to 0 and a 1 is forced externally, the output buffer will be stressed and generate some heat but the input buffer will read the level correctly.
When a 8051 restarts (or Power up) it loads all ports with 0xff (like when you want to use it as input). if you don't use a Pin as a bi-directional Pin (for both Input and output) , you usually don't need to reload it every time with 1 to act as input.
When a 8051 restarts (or Power up) it loads all ports with 0xff (like when you want to use it as input). if you don't use a Pin as a bi-directional Pin (for both Input and output) , you usually don't need to reload it every time with 1 to act as input.
normally there will not be any problem,and it's a good practice to pull up the port pins as most of the us do.
when you are using the same pins as Input and output, without any IC's in between, there could be a problem.in such cases you have to write a 1 to the pin which you have to read.
normally there will not be any problem,and it's a good practice to pull up the port pins as most of the us do.
when you are using the same pins as Input and output, without any IC's in between, there could be a problem.in such cases you have to write a 1 to the pin which you have to read.
thank you for the reply.i never used any port pull ups except for P0.i realize now the reason for my MC burning(actually 4).as you said using pull ups is a good practice.i studied that in MC book by Mazidi.