EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: gmc on February 28, 2020, 10:13:07 pm

Title: Atmega32u4. Correct way to sharing SPI pins?
Post by: gmc on February 28, 2020, 10:13:07 pm
I've got a project I'm working on and about to go get some PCB's made up.

It consists of a AtMega34u2 connected to a MAX3421E using SPI bus.  Once all the components are soldered onto the PCB I need to program a bootloader on the atmega using the SPI inteface.

What is the correct way to share the SPI pins between the programmer (USBTiny) and the other components. I've read a few posts where it ranged from using 330R resistors on the SCK/MOSIO lines, or only needing a pullup resistor on the SS lines.

I've attached a schematic for my project. The atmega32u is connected to the max3421e using level shifters. Do I need to be concerned with using inline resistors? Or  can I just program the chip by connecting the usbtiny to the spi bus.

I would to fix any possible issues before any prototype pcb's are made up.




Title: Re: Atmega32u4. Correct way to sharing SPI pins?
Post by: thm_w on February 29, 2020, 01:11:59 am
See here: https://www.avrfreaks.net/forum/isp-spi-resistors (https://www.avrfreaks.net/forum/isp-spi-resistors)
I think the current schematic might be OK as is, as you have the level translators and L_SS is pulled up via a resistor. So the SPI slave (max3421) should not be able to interfere with the programming lines. Debugging might be a different story, but you could use debugwire instead (uses reset line).

Generic recommendations:
- I would consider connecting the INT pin on the MAX3421 unless you are sure its not needed.
- Add a bit of bulk capacitance on the 3.3V rail, it looks like only 100nF is present.
- Check that MISO level translator is working as you expect, since signal is coming from the slave, to the master, not from master to slave as SCK/SS/MOSI are.
Title: Re: Atmega32u4. Correct way to sharing SPI pins?
Post by: gmc on February 29, 2020, 09:51:13 am
Thanks for the tips.  Good spot on the cap for the 3v3 rail.  I'll get some prototype pcb's done and see how it goes.

The level shifter is working on the MISO line. I've got the MAX3421E hooked up to an Arduino via a level shifter and don't have any issues.