Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

interfacing the MC serial port

Status
Not open for further replies.
Julia said:
The thing is Nigel and I don't know ATMELs at all. Nigel was just trying to tell you what he would do with PIC If he had such problem. Rolling Eyes
SO ? noone can help me in this forum ?! no one how to deal with AT89C51 ?
:cry: :cry: :cry: :cry: :cry: :cry: :cry:
i will fill this forum with my tears
:cry: :cry: :cry: :cry: :cry: :cry: :cry:
:wink:

I see no reason why an Atmel processor should behave differently, if a pin is set as an input, you should be able to feed it from a 3V logic chip. As I said before, if it reads 5V - THEN FIND OUT WHY!, IT'S PROBABLY NOT NORMAL!.
 
I see no reason why an Atmel processor should behave differently, if a pin is set as an input, you should be able to feed it from a 3V logic chip. As I said before, if it reads 5V - THEN FIND OUT WHY!, IT'S PROBABLY NOT NORMAL!.
dear Nigel you say
if a pin is set as an input
and i told you there's nothing in ATMEL data sheet tells me how to set the RX pin as as input, because it's already input ,
and you say
As I said before, if it reads 5V - THEN FIND OUT WHY!, IT'S PROBABLY NOT NORMAL!
i tested that on 4 a ATMEL MC, they all gave me the same result, the RX pin is high... :roll:
 
Julia said:
I see no reason why an Atmel processor should behave differently, if a pin is set as an input, you should be able to feed it from a 3V logic chip. As I said before, if it reads 5V - THEN FIND OUT WHY!, IT'S PROBABLY NOT NORMAL!.
dear Nigel you say
if a pin is set as an input
and i told you there's nothing in ATMEL data sheet tells me how to set the RX pin as as input, because it's already input ,
and you say
As I said before, if it reads 5V - THEN FIND OUT WHY!, IT'S PROBABLY NOT NORMAL!
i tested that on 4 a ATMEL MC, they all gave me the same result, the RX pin is high... :roll:

So, do you mean the I/O pins can't be set as either input or output?, that sounds a very limited design! - particularly as Atmel were trying to jump on the PIC bandwagon!.

Assuming this is so?, check what the datasheet has to say about the inputs (PIC datasheets usually give a small diagram showing how the I/O pins are wired), this should help you find out what the problem is.
 
So, do you mean the I/O pins can't be set as either input or output?
no i didn't mean that, the i\o pins can be set as input and output, but i was talkin' about the TX & RX pins, the Tx is an output by default, and the RX is an input by default, i can't change anyone of them. :x
and i am pretty sure of that,
but the thing that i am not sure about is the logic high on the RX pin :roll:
 
Julia said:
So, do you mean the I/O pins can't be set as either input or output?
no i didn't mean that, the i\o pins can be set as input and output, but i was talkin' about the TX & RX pins, the Tx is an output by default, and the RX is an input by default, i can't change anyone of them. :x
and i am pretty sure of that,

As I've already said, I don't use Atmel devices, but on a PIC the TX and RX are just normal I/O pins, and can be set as inputs or outputs, but if you wish, set to be connected to the internal hardware USART. So on a PIC you would have to set RX as an input, TX as an output, and then turn on the USART.

but the thing that i am not sure about is the logic high on the RX pin :roll:

I can only suggest reading the datasheet, it 'should' explain what you need to know.
 
Hey Julia,
the atmel MC serial ports is a part of the port number 3, so you can make the tx & rx pins an output and input,
but i really don't know how to make the input port low,
because if you want to make the pin as input port you have to send setb p3.0 and that mean you will set it to high !!!!!!
that's all i know
 
If you post the full part number for your controller We can look it up and give you better info.

the i\o pins can be set as input and output, but i was talkin' about the TX & RX pins, the Tx is an output by default, and the RX is an input by default, i can't change anyone of them.
It's common on 8051s for the RX and TX pin to be shared with standard port pins. Since the I/O on the pin is set up for both you have to set up the I/O on the pin even if you are using the UART on those pins.

but the thing that i am not sure about is the logic high on the RX pin
Add a 10K resistor from the pin to ground and measure the voltage to ground it should read close to 0V. If it doesn't then You probably have something set up wrong - the port drive most likely.

The 8051's that I've used have 2 possible port pin setups: Push-Pull and open-drain. To set the pin to an input you have to set it to be open drain and load a 1 into the port output register. This also might help you fix you level shifting problem. If you set TX to be an open drain and use a pullup resistor to your 3V supply you will get a 3V output.
 
If you post the full part number for your controller We can look it up and give you better info.
I'm using AT89C51 , it's compatible with Compatible with MCS-51, 4K Bytes of In-System Reprogrammable Flash Memory, 128 x 8-bit Internal RAM

Since the I/O on the pin is set up for both you have to set up the I/O on the pin even if you are using the UART on those pins
what do you mean by set it up ? do you mean the initialization ?
like this
ORG 0H ; Start at location 0 in the ROM
Mov TMOD, #20H ; Timer 1 Mode 2
Mov TH1, #-3 ; 9600 Baud rate
Mov SCON, # 50 H ; 8-bit, 1 stop bit, REN enabled
SETB TR1 ; Start timer
or you mean set it as o/p or i/p pin ? setb p3.0 as Peter said ?
 
news news news....

hey bmcculla , you told me to put a 10k resistor between the RX and the ground,
i did that , and the voltage of the RX pin became 2.4 V !!!
it has been reduced , but it didn't reach zero !

i tried another thing,
i made that program and teseted
org 0h
setb p3.0 ; rx pin
end
then i measured the rx pin ,
i found it low :lol: :lol: :lol:
i guess this is the missing point right ?
 
The 10K resistor was to test if there is an internal pullup resistor on the pin. If the pin was being driven high the voltage wouldn't drop at all. Since the voltage dropped by half it would seem that there is an internal 10K pullup resistor on the pin.

You need to set the drive mode on the RX pin to make it an input. The drive mode register on the 8051s I'm familiar with is called P3MDOUT for Port3. You need to set the pin to be in open drain mode. Look in the Port i/o section of your datasheet to see how to do this. Then turn off the open drain transistor.

After a quick look at an the datasheet to seems that this 8051 doesn't have push-pull outputs. You just need to set the port pin to 1 and have an external source drive the port.
 
damn it !
i am sorry, the above program gave me high not low
i am so depressed and disappointed :cry: :cry: :evil: :evil:
i asked a doctor in my college about the RX pin
he told me, you don't have to set it as input port !
as long as you are intializing the serial transfer mode, so it's okay
go on with it
:!: :?:
i'm in dilemma :roll:
 
Julia said:
i asked a doctor in my college about the RX pin
he told me, you don't have to set it as input port !

Initially port3 pins(which include RxD & TxD) are all HIGH after reset.

In this situation, they are available for use as input or for alternate function.

You must take care never to output directly a LOW on these two pins because it will stop them functioning. There is NO mechanism to pull high the pin, all is done using internal pull up resistors.

As long as you do not change these pins by sending a LOW to them, you are OK.

I have also checked your Timer mode/baud rate settings and they are good for 9,600bps. Are you copying them from somewhere else or you design it yourself?
 
eblc1388 said:
Julia said:
i asked a doctor in my college about the RX pin
he told me, you don't have to set it as input port !

Initially port3 pins(which include RxD & TxD) are all HIGH after reset.

In this situation, they are available for use as input or for alternate function.

You must take care never to output directly a LOW on these two pins because it will stop them functioning. There is NO mechanism to pull high the pin, all is done using internal pull up resistors.

As long as you do not change these pins by sending a LOW to them, you are OK.

I have also checked your Timer mode/baud rate settings and they are good for 9,600bps. Are you copying them from somewhere else or you design it yourself?
you are completely right EBLC , that's what i am going to do, i will use them as they are because they are already input and i won't care if the rx is high or low after the reset,
about your question EBLC
and to be a good girl :wink: , i got the codes from a book called, the 8051 microcontroller and embedded systems, "Janice Gillipie Mazidi" :D
 
Julia said:
i got the codes from a book called, the 8051 microcontroller and embedded systems, "Janice Gillipie Mazidi" :D

Thought so, we all do that.

You still need to find a way to solve your 5V RxD pin to GPS 3V TxD pin interfacing problem.
 
eblc1388 said:
Julia said:
i got the codes from a book called, the 8051 microcontroller and embedded systems, "Janice Gillipie Mazidi" :D

Thought so, we all do that.

You still need to find a way to solve your 5V RxD pin to GPS 3V TxD pin interfacing problem.
i think i will make a crazy idea
i will put the output of the MC on a variable resistor, then adjusting the 3v,
what do you think ? this could work
? :?:
 
Julia said:
i think i will make a crazy idea
i will put the output of the MC on a variable resistor, then adjusting the 3v,
what do you think ? this could work
? :?:

The trouble is you need to pull LOW the 89C51 RxD pin using the GPS TxD pin which is OK. But when TXD pin goes high then 5V of 89C51 would feedback to your GPS TxD pin. If you insert a resistor and adjust the voltage to 3V, then you may not be able to pull the 89C51 RxD pin low enough. That's why I post that two-transistor circuit earlier.

But your idea worth a try because the input protection diodes on the GPS would limit the input voltage via the series resistor. A resistor of a few Kohms would be a nice start.

Good luck & bedtime for me.
 
hey guys,
i purchased a kit for my gps module, you know why ?
because the kit has a RS232 port , so, i won't need to suffer more from the 3 <>5 conversion ,
now, i am going to purchase MAX232 to interface the kit to the micro controller,
the kit documentation says,
the main serial port normally hooked to a host computer using a standard 9 pins ( Male - Female )serial connection cable ( ref: digikey p/n AE1020 ). this cable should be wired one-to-one ( ie, not a null modem ) pin assignments:
pin 1 : 1pps to host, rs232 levels
pin2 TxD, serial data from m12+ to host, RS-232
pin3 RxD, serial commands from host to M12+, RS-232
pin5 Signal ground

now, i want to ask one more question about one to one meaning
i know the null modem connection, what about the one to one ?
how shall i connect the rs232 to the MC serial port ?


:roll:
 
The mention of one-to-one cable is referring to connection to a PC or MAC RS232 port.

But you are connecting it to a uC via a MAX232 chip. The only thing that matters is the RS232 TxD signal of one is connected to the RS232 RxD of the other using cable.

About the 1 pps output, you can use the left over MAX232 to convert it into TTL level and use one port pin of the 89C51 to read it and do something with it.
 
The only thing that matters is the RS232 TxD signal of one is connected to the RS232 RxD of the other using cable
that's so good, that mean i will connect the tx of the kit to the rx of the mc via the max, and the tx of the mc to the rx of the module via the max
that's great :lol:

but i have a question about the pps,
when i measure the pin1 ( 1pps output ) on the kit rs port, it should give me high and low, high and low,...etc right ?
 
Julia said:
but i have a question about the pps,
when i measure the pin1 ( 1pps output ) on the kit rs port, it should give me high and low, high and low,...etc right ?

The pulse can be a sharp pulse going LOW or a sharp pulse going high or a square wave. It does not matter. What's important is the frequency is 1 Hz.

If a meter does not give you good indication, you can use a scope to view it or try to find out about it from the datasheet of the kit.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top