An SPI that refuses to work...

Refer the schematic.

A simple ATMega328P interfaced with a nRF24L01 chip and a MOSFET used as a MCU controlled power switch to deliver 3.3V to the RF24 module.

I made totally 5 such ( double sided ) PCBs and sadly out of that, only one is working reliably. Another one works whenever it is in the mood for it. And balance 3 never work and when i say never work it means this :

  1. Program download : Possible
  2. LCD interface : Working

Its only the RF24 that simply refuses to work and not only that, at times it freezes the loop.

All usual and obvious diagnostics like swapping MCUs, RF 24 modules, Crystal , 22pF capacitor , tracing the tracks for any shorts, checking voltages right at the Vcc point of MCU and RF24 et all. done but to no avail to trace the issue.

So what i wanted to know is this :

Look at the schematic. The 3.3V to the RF24 module is switched by the MCU based on need. So when initial power up there will exist a situation where the RF24 SPI bus line is active but the Vcc to the module is not present.

And when the MCU powers up and completes setup() the RF24 module is powered up.

Is the above a reason for my issue ? The natural question then is how is the same code working on one of the PCBs ? For sure i have no answer to this …

Anyone can think of any other basic flaw in the circuit as shown ??
GFM_RF_PCB.PNG

So when initial power up there will exist a situation where the RF24 SPI bus line is active but the Vcc to the module is not present.

This is never a good idea, and completely unnecessary.

First, unpowered modules can be powered and sometimes damaged via their I/O pins. If later powered up, they will usually behave unpredictably and often won't start up correctly.

Second, in sleep mode, the radio consumes negligible power, so the mosfet is unnecessary.

By "negligible power", he means 100 nanoamps.

Just power down the chip when you don't need it, and you'll never notice it.

+1 on the power issue - leave the radio on. Have you tried 100nf bypass caps right on the pins of the 328 and nrf24 socket pins? What physical type of caps are the two 10uf's? You show them as polarized. Are they standard aluminum electrolytics or tantalums?

Thanks folks.

  1. No circus required to save power due to nRF24L01 when MCU is sleeping as the power drawn by the module then is insignificant. This IS a significant point which I overlooked.

  2. The 10uF caps are Electrolytic.

  3. The point on power to bus pins before power to module is well taken. Will avoid.

There are times when such issues hit you and whatever you try the MCU just sits there wryly smiling at you refusing to move its ass. This is one such.

Anyway since the project was on hold took out a GP board, threw in a ProMini and wired it to a Rf24 inserted on a base and it worked first shot.

( Just academic interest - is it any good to probe the SPI CLK pin with a regular 30MHz oscilloscope to know if in fact its doing anything at all ?? )

A couple of wires, shorting traces on the PCB, should fix the design problem.

is it any good to probe the SPI CLK pin with a regular 30MHz oscilloscope to know if in fact its doing anything at all ??

Should work quite well.

The frequency response of a scope needs to be about 10x the frequency of a square wave, in order to show an approximately correct shape.