Re: 2313 output pin problem

Richard Urwin <[email protected]> Wed, 24 Dec 2003 10:05:36 +0000
Newsgroups gmane.comp.hardware.avr.general
Message-ID <[email protected]>
On Tuesday 23 Dec 2003 11:11 pm, Robert Baruch wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Anderas Strodl wrote:
> | I've connected the data lines of a lcd-module to the upper 4 pins of
> | PORTB using
> | DDRB = 0xFF;
> |
> | There were no problems at all.
>
> Hmm... In that case, I'm completely stumped. And I think there has to be
> an error in the logic diagrams of PB5 and PB7 (Figures 41 and 43)
> because they seem to show that the output buffer will only be enabled if
> DDBn is 0 or SPIEN is 1, which can't be right, because DDBn=0 configures
> a pin as an input. All the other diagrams show the output buffer being
> enabled when DDBn is 1.

That diagram is wrong. There must be an inverter in the DDB7 Q line between 
the RD line and the pull-up line. Otherwise the pull-up is only enabled if 
the DDB7 Q is 0.

(PB5 likewise, of course.)

With that addition, the NAND gate is active if both DDB7 and SPIEN are 0, and 
an active NAND gate disables the buffer. So the port is an input only if DDB7 
is 0 and SPIEN is 0. In all other cases it is an output.

To put it another way, by De-Morgan,  NOT (NOT X   AND  NOT Y)  = X OR Y
So the buffer is enabled if DDB7 OR SPIEN.

So the port might be stuck as an output, but not an input.

In serial programming PB7 has to be an input, which it can be, because RESET 
clears DDB7, but if SPIEN is inactive then the port would be an output at all 
times. Clearly nonesense.

My conclusions:
1. The diagram is a crock.
2. SPIEN is not necessarily the SPIEN fuse, but may be an internal signal 
generated from it and other state.
3. These diagrams are never the absolute and true circuits, they are only ever 
a simplified recreation of it.
4. Your problems come from other causes.

I notice that no-one else has said that they have used a high current device 
on these pins, although nothing in the datasheet says that you can't.

Try:
Connecting a second LED on an uncommitted B pin and flash both of them. That 
will test conclusively if the part is programmed correctly. Then remove the 
(PB7/5) LED and check the output with a volt meter. That will show if the 
port is being driven but is incapable of driving the LED.

I do have some 2313 parts here, but unfortunately I have a 12MHz crystal in 
the development board at the moment. It's probably not the right time of year 
to be soldering PCBs.

Merry Christmas everyone.

-- 
Richard Urwin