Continue to Site

Initializing Ports on MicroController

Status
Not open for further replies.

theone_in_themoon

Junior Member level 3
Junior Member level 3
Joined
Oct 20, 2003
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Lahore Pakistan
Activity points
323
Hi

Im using ATMEL 89C2051 uC. I have used it before but i have come up with a unique problem.

i.e. When i need to communicate serially with PC through RS-232... it requires that i do NOT initialize the ports with 0x00. [Initializing with 0xFF works somtimes].

However if i do not initialize the ports (so that i can do serial comm.) then the uC does not read the value at the pins [By sbit ].

Its either the serial communication OR Reading Pin values ........... but i need to have both these tasks performed.

Can anyone suggest or guide me with wat might i be doing wrong ???

Thankyou

P.S. Please Do reply ... i really need help
 

Some instructions read the port latch and some read the port pin.

Study section 4 of this datasheet carefully to understand the difference:
**broken link removed**

/Rambo
 

Im using a C51 compiler. So that means im NOT using assembly language instruction set. Im using normal C language.
 

Initializing ports with 0x00 means you are making them as an output port, therefore you will not be able to receive data from your UART.

I am quite confused in your question on reading the UART and reading the ports, if you declare the two pins as the for the UART and I believe they are built to have that function as a substitute for being an I/O pin.

The UART function is done automatically by your microcontroller but of course you must initialize the ports properly before making the I/O pins do a certain job.

At initialization, all pins of microcontrollers are expected to act as an input port, initializing the UARTs could have internally controlled the RX pin of the micro to act as an output.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top