Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Changing ports from output to input

2007-01-23 by David Kelly

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.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.