Several of the data sheets have comments about changing port direction. If you don't do it "right", you can get an unwanted single-instruction transient on the port pin. At the moment, I don't recall the details but it might be worth checking one of the newer data sheets (such as Mega48). Jim On Tue, 23 Jan 2007 15:15:26 -0600 David Kelly <dkelly@hiwaay.net> wrote: > On Tue, Jan 23, 2007 at 09:02:43PM -0000, billsputters > wrote: > > What is the considered wisdom regarding changing a port > from output to > > input? I am trying to interface to a LCD display and > attempting to > > read the busy flag which is available on the data lines > of the device. > > I've looked around and some code just changes the DDR > as required and > > some set the outputs of the port to all 0's before this > so as not to > > get a flase reading. Is this a belts and braces > approach or a > > requirement. BTW, I've tried both versions of changing > the port over > > and the LCD does not function how I want, but it's a > case of > > eliminating errors. Thanks in advance. > > Just clobber the DDR bits to toggle between input and > output. I get CPUs > confused sometimes so check the documentation for > "internal pull ups" on > the ports. No need to change the output value to > something else unless > the output value in input mode enables pullups that you > need. You > shouldn't need internal pullups, "But what do I know? > (about your > hardware)". > > And that is likely why you are having problems: when you > change the > output values you tell the LCD to do something unexpected > and its off > doing that rather than the next thing you tell it to do. > Make sure your > R/-W, E, and -CS lines are stable and reasonable for > changing data line > values when you change the DDR. > > -- > David Kelly N4HHE, dkelly@HiWAAY.net > ======================================================================== > Whom computers would destroy, they must first drive mad. --------------------------------------------------------------- The Think Different Store http://www.thinkdifferentstore.com/ For All Your Mac Gear ---------------------------------------------------------------
Message
Re: [AVR-Chat] Changing ports from output to input
2007-01-23 by Jim Wagner
Attachments
- No local attachments were found for this message.