Hello I am new to the 8051 compatible controller. I am used to PIC as well as Renesas and using C. The 8051 does not have a "Port Direction" to set. I have some questions regarding this: - How to set it as input? I read something of writing 1 to the latch. However, this is as using it as output and set it. I don't get its function. - How to set it as output correctly? - There is a difference between reading the "pin" and reading "latch". Can I somehow select which one I want to read? Thanks for your help Franz
8051 Controller
Started by ●August 2, 2006
Reply by ●August 2, 20062006-08-02
<@> wrote:> Hello > > I am new to the 8051 compatible controller. I am used to PIC as well as > Renesas and using C. > The 8051 does not have a "Port Direction" to set. I have some questions > regarding this: > > - How to set it as input? I read something of writing 1 to the latch. > However, this is as using it as output and set it. I don't get its function. > - How to set it as output correctly? > - There is a difference between reading the "pin" and reading "latch". Can I > somehow select which one I want to read?The 8051 port pins have weak pull-ups, which means if you set them to '1', you can use them as inputs. There is nothing else you can or must do to use a pin as an input. You can't read back the latch AFAIK. If you want to use it as a an output, you don't need to do anything either, unless you need more drive on the high side, in which case you add a pull-up resistor or a buffer. This is why doing open collector type routines like I2C, one-wire bus etc is so easy on the 8031.
Reply by ●August 2, 20062006-08-02
<vkesler@gmail.com> schrieb im Newsbeitrag news:1154532425.814367.195320@s13g2000cwa.googlegroups.com...> <@> wrote: >> Hello >> >> I am new to the 8051 compatible controller. I am used to PIC as well as >> Renesas and using C. >> The 8051 does not have a "Port Direction" to set. I have some questions >> regarding this: >> >> - How to set it as input? I read something of writing 1 to the latch. >> However, this is as using it as output and set it. I don't get its >> function. >> - How to set it as output correctly? >> - There is a difference between reading the "pin" and reading "latch". >> Can I >> somehow select which one I want to read? > > The 8051 port pins have weak pull-ups, which means if you set them to > '1', you can use them as inputs. There is nothing else you can or must > do to use a pin as an input. > You can't read back the latch AFAIK. > > If you want to use it as a an output, you don't need to do anything > either, unless you need more drive on the high side, in which case you > add a pull-up resistor or a buffer. > > This is why doing open collector type routines like I2C, one-wire bus > etc is so easy on the 8031. >Thanks a lot. Franz
Reply by ●August 2, 20062006-08-02
There's a good web site.... www.8052.com , that has a good forum, and tutorial web page. The wording for the "classic" 80c51 ports is called Quasi-Bidirectional. Check out these a.. '51 "Bible" Family Architecture (PDF): Chapter 1: '51 family of microcontrollers, architectural overview a.. '51 "Bible" Hardware Description (PDF): Chapter 3: '51 Hardware description- stuff that is not in data sheets any more a.. '51 "Bible" Programmers Guide (PDF): Chapter 2: '51 programmers guide and instruction set http://www.8052.com/links.phtml Regards Joseph <@> wrote in message news:44d0cb9d$1_1@news.tiscalinet.ch...> <vkesler@gmail.com> schrieb im Newsbeitrag > news:1154532425.814367.195320@s13g2000cwa.googlegroups.com... >> <@> wrote: >>> Hello >>> >>> I am new to the 8051 compatible controller. I am used to PIC as well as >>> Renesas and using C. >>> The 8051 does not have a "Port Direction" to set. I have some questions >>> regarding this: >>> >>> - How to set it as input? I read something of writing 1 to the latch. >>> However, this is as using it as output and set it. I don't get its >>> function. >>> - How to set it as output correctly? >>> - There is a difference between reading the "pin" and reading "latch". >>> Can I >>> somehow select which one I want to read? >> >> The 8051 port pins have weak pull-ups, which means if you set them to >> '1', you can use them as inputs. There is nothing else you can or must >> do to use a pin as an input. >> You can't read back the latch AFAIK. >> >> If you want to use it as a an output, you don't need to do anything >> either, unless you need more drive on the high side, in which case you >> add a pull-up resistor or a buffer. >> >> This is why doing open collector type routines like I2C, one-wire bus >> etc is so easy on the 8031. >> > > Thanks a lot. > Franz > >
Reply by ●August 2, 20062006-08-02
@ wrote:> Hello > > I am new to the 8051 compatible controller. I am used to PIC as well as > Renesas and using C. > The 8051 does not have a "Port Direction" to set. I have some questions > regarding this: > > - How to set it as input? I read something of writing 1 to the latch. > However, this is as using it as output and set it. I don't get its function. > - How to set it as output correctly? > - There is a difference between reading the "pin" and reading "latch". Can I > somehow select which one I want to read?This also depends somewhat on the variant. The orginal 80C51 used a quasi-bidirectional port : Strong N FET with dymamic P fet and lighter holding P FET. This makes Wire OR and two way links like i2c ans 2 wire, very easy. The data sheets explain which opcodes read the pins, and which read the latch; there is no port set-up as such. Newer variants have 4 mode port pins : (and these do need a port set-up) Std C51 CMOS Drive Open Drain Input Examples are Silabs devices, Philips LPC9xx, Atmel AT89LPxx, Winbond W79E8xx series, (etc) These allow almost any design to be implemented, on a per-pin granularity. Open drain without pullups, is good for very low power keypad idle appliations, Input only allows higher impedence drive sources ( mains zero crossing ) CMOS drive is good for LED or large FET drive. -jg
Reply by ●August 3, 20062006-08-03
Ah! Heres a good start http://www.8052.com/forum/read.phtml?id=121603 <@> wrote in message news:44d0bb33$1_1@news.tiscalinet.ch...> Hello > > I am new to the 8051 compatible controller. I am used to PIC as well as > Renesas and using C. > The 8051 does not have a "Port Direction" to set. I have some questions > regarding this: > > - How to set it as input? I read something of writing 1 to the latch. > However, this is as using it as output and set it. I don't get its > function. > - How to set it as output correctly? > - There is a difference between reading the "pin" and reading "latch". Can > I somehow select which one I want to read? > > Thanks for your help > Franz > >
Reply by ●August 3, 20062006-08-03
Thanks to all of you guys. You're a great help. The 8052.com indeed is a good place to start and Kai's description clarified all. Thanks a lot! Franz "Joe G (Home)" <joe.g@optusnet.com.au> schrieb im Newsbeitrag news:44d20609$0$1211$afc38c87@news.optusnet.com.au...> Ah! > > Heres a good start > > http://www.8052.com/forum/read.phtml?id=121603 > > > > <@> wrote in message news:44d0bb33$1_1@news.tiscalinet.ch... >> Hello >> >> I am new to the 8051 compatible controller. I am used to PIC as well as >> Renesas and using C. >> The 8051 does not have a "Port Direction" to set. I have some questions >> regarding this: >> >> - How to set it as input? I read something of writing 1 to the latch. >> However, this is as using it as output and set it. I don't get its >> function. >> - How to set it as output correctly? >> - There is a difference between reading the "pin" and reading "latch". >> Can I somehow select which one I want to read? >> >> Thanks for your help >> Franz >> >> > >