Author Topic: ATmega328p SPI interference  (Read 533 times)

0 Members and 1 Guest are viewing this topic.

Offline kuzm1nsk1Topic starter

  • Contributor
  • Posts: 30
  • Country: hr
ATmega328p SPI interference
« on: May 12, 2024, 03:00:21 pm »
Hi, I'm experiencing problems with SPI communication when I use ATmega328p on the breadboard. It's running at 16 MHz with external crystal oscillator and it has necessary components connected to it. If I upload the code on the Arduino Uno, which has the same microcontroller, there are no problems with SPI interference. Code uploaded to both versions is the same and fuse bits are identical. Programmer is USBasp. I'm also using max7219 matrix display with 4 modules. The problem on the breadboard version is that it's SPI pins are super sensitive to any interference, meaning that, if I touch any of the SPI pins except the power and ground, it completely bricks the matrix. Matrix can change intensity, display random pixels, turn off some displays etc. I know the breadboard is far from ideal when it comes to higher frequencies signals, but can it be that bad? I tried lowering CPU and SPI frequency but it doesn't help. I tried adding decoupling capacitors to power lines but it doesn't help. I tried using separate power supply for matrix but it doesn't help. I tried using different breadboard and it didn't help. Can breadboard cause such problems because of it's parasitic capacitance?
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 3067
  • Country: us
Re: ATmega328p SPI interference
« Reply #1 on: May 12, 2024, 03:08:30 pm »
... If I upload the code on the Arduino Uno, which has the same microcontroller, ...

Is the same physical IC or just the same kind of IC? Have you tried using the chip on the breadboard in the UNO (and also vice versa)? Might reveal something

 

Offline kuzm1nsk1Topic starter

  • Contributor
  • Posts: 30
  • Country: hr
Re: ATmega328p SPI interference
« Reply #2 on: May 12, 2024, 03:35:08 pm »
Just tried and it works fine now. I really don't understand why, they both have the same markings on them.
 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6326
  • Country: ro
Re: ATmega328p SPI interference
« Reply #3 on: May 12, 2024, 04:11:04 pm »
SPI pins are super sensitive to any interference, meaning that, if I touch any of the SPI pins except the power and ground, it completely bricks the matrix

You are not supposed to touch the pins at all.  When you touch the pins, you apply a few hundreds volts at low current.  Those 200-300V are induced from the surroundings and from the Y capacitors in the power supply.  Usually there are protection input diodes that limits the hundreds of volts to only Vcc+0.7V and GND-0.7V, but it is never a good idea to abuse them.

Depending on grounding, and the desktop/laptop/power supply, you may even permanently damage your circuits.

- You may try removing the capacitors connected to the quartz (in case the oscillator stops when you touch the circuit, also check the oscillator fuses are the same and set properly - unlikely that this is the cause, but possible).
- Another thing you may try is to add 50...100 ohms resistors in series with the SPI lines, to reduce reflections in the SPI wires.
- Make sure the wires are well connected and are making good contact, have less than 1 ohm resistance (DuPont wires and other cheap Aliexpresss wires are famous for making very bad contacts sometimes)

Find an isolated plank to put on the floor, or sit on a wooden chair and lift your feet from the floor first, then touch the GND of the Atmega circuit (second), then touch a SPI wire (third - but again, you are not supposed to touch the wires, in the first place).

After all the above, does the display still goes erratic when SPI is touched?

(If the cause was over-voltage induced by your body, by isolating yourself from ground/floor/other masive objects, you should see less interference when touching the SPI)
« Last Edit: May 12, 2024, 04:19:24 pm by RoGeorge »
 

Offline kuzm1nsk1Topic starter

  • Contributor
  • Posts: 30
  • Country: hr
Re: ATmega328p SPI interference
« Reply #4 on: May 12, 2024, 05:17:01 pm »
Well, the only variable I see here is the chip itself. On the second chip, you can touch anywhere on the SPI line, even with wet fingers, and it doesn't cause any problems whatsoever.
 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6326
  • Country: ro
Re: ATmega328p SPI interference
« Reply #5 on: May 12, 2024, 06:55:43 pm »
Yes, best guess is the sensitive one already lost one or more of its Vcc/GND protection diodes.


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf