Need help about embedded C programming

Hi all,
I need some info about below program for embedded C,

void main (void ){
unsigned char mybyte;
P1=0xFF; // make port input enabled
while (1){
P2=mybyte; // buzzer signal

In above program, 0xFF signal is sent to port 1 for enabling it for input.
Now if, i am passing 0xFF as an input signal to port 1 then the same data will get assigned to mybyte and after that it will be sent to P2.
Now my question is, will P2 become input enabled or it will just send that data to output device?
How does the port differentiate between output signal and latch signal?

Mahesh Kedari


  • Typically, microcontrollers have at least 2 registers per port: one for data direction (input/output) and one for the actual data.

    How your particular microcontroller works, I have no idea. Might be wise posting which one it is if you expect better replies...
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion