0

-SOLVED- ATMega not found when MISO is in use by other chip
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

-SOLVED- ATMega not found when MISO is in use by other chip

by EJdeViking on Tue Aug 21, 2018 1:05 pm

Hi all,

Working with ATMega and USBTiny is going great, no news there.

Using hardware-SPI with '595s in daisy chain also goes smoothly.

But using a '589 PISO does not work.
Well, it works when I unplug the wire that comes from "out" of the 589 and goes to MISO of the Tiny.

So every time I want to program I have to unplug that wire.
I tried using pull-ups, it seemed to help a little sometimes.

avrdude says this:

Code: Select all | TOGGLE FULL SIZE
avrdude -p atmega328p -c usbtiny -U flash:w:parallel_in.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: safemode: Verify error - unable to read lfuse properly. Programmer may not be reliable.
avrdude: safemode: To protect your AVR the programming will be aborted


So, what can I do to use USBTiny when MISO is active on that '589 shift register?
It is a shift register that reads parallel and outputs serial.
It is working great, only programming is the problem.

Anyone had that happen?


Eric-Jan
Last edited by EJdeViking on Fri Aug 24, 2018 4:07 am, edited 1 time in total.

EJdeViking
 
Posts: 3
Joined: Mon Aug 20, 2018 10:20 am

Re: ATMega not found when MISO is in use by other chip

by EJdeViking on Fri Aug 24, 2018 4:07 am

OK, here is the answer.

adafruit_support should have gotten this one, I am the legal owner of three USBTiny kits.


Here goes.

Short story:
There is a special pin called "Output Enabled" (OE) on my extra chip.
If that pin has a logic high value, the MISO pin, which was interfering with the programming, is lifted from the crcuit, as if it is not there.

A pull-up for the OE guarantees that the MSIO pin will be out of the circuit while the microcontroller is being programmed, it cannot interfere anymore.

Just like the pull-up in the SpokePOV shematic, at the SS-pin of theEEPROM.

Long story:


Programming with USBTiny goes via SPI.
MISO and MOSI are part of SPI.

Of course you can use the MISO and MOSI pins with your microcontroller.
But only when it is executing code, not while it is being programmed by USBTiny.

So, if you have an extra chip connected to those pins, it should not have 0 or 1 or whatever value.
No logoc low, 0, zero volts or logic high, 1, 3.3 or 5V.
It should appear to have no value or not even a connection at all.
As if there is no wire to that pin.

To do that, some very clever people have created a "high-impedance" or "high-Z" mode.
A chip with that on a pin has a tristate pin: 0, 1 and high-impedance.
My extra chip has tristat on thje MISO pin, just what I needed!
Because high-impedance means there is no logic level, you cannot put a logic level on that pin to put it in high-impedance mode.

That is why they use another pin just for that purpose.
In my chip, and many others, it is called "Output Enabled", or OE.

When you put logic level high on that OE pin, the tri-state pin goes into high-impedance mode.
Now that's nifty!
In high-impedance mode the pin cannot interfere with MISO or MOSI, it is as if it just isn't there!

Only one problem: when the microcontroller is being programmed, it does not do anything.
It is just listening to the new code to store.
So it is not sending a high level to the OE-pin, to tell the extra chip that it should keep the tri-state pin in high-impedance mode.

How to fix that?
With a pull-up.
A pull-up is a resistor connected to 3.3 / 5V at one side (so logic level high), and a pin on the other side.
If we connect the pull-up to the OE pin, the OE pin will be high when the microcontroller is not doing anything with that pin.
OE high means MISO in high-impedance mode, so it is of the map and cannot interfere.

Brilliant!

When the microcontroller is running code and sends a low signal to the OE pin, it will be set to low because the resistor is only a tiny signal.
It will be overruled (did you know there is no translation of that word to Dutch???) by the microcontroller.
MISO will be in play again, but only if the microcontroller is running code.


Eric-Jan

EJdeViking
 
Posts: 3
Joined: Mon Aug 20, 2018 10:20 am

Please be positive and constructive with your questions and comments.