1

I have a setup of 2 Arduino Leonardo boards. Let's refer to them as Board A and Board B.

Board A is a master SPI board that is constantly communicating via SPI to an array of sensors. At some point, board A will need to be flashed with a new sketch. That's where Board B comes in.

I want to use Board B go use an Arduino as ISP sketch to go and flash a new sketch onto board A. Problem is that Arduino as ISP uses SPI, which conflicts with the code on board B since board B is a master device communicating to other sensors via SPI.

Is it possible for board B to flash board A via ISP?

2
  • 2
    the ISP flashing is done in reset state. there is no SPI used then. but the connected SPI slave can interfere
    – Juraj
    Dec 21 '20 at 9:25
  • Your code is not running when your new code is uploaded.
    – Gerben
    Dec 21 '20 at 16:25
2

Yes, you can flash an MCU using ISP even if the MCU acts as an SPI device (be it master or slave). The programmer puts the MCU into reset mode, so at the time the sketch is uploaded, SPI will be disabled anyway. Another thing you need to think of are the other SPI devices (the sensors or what ever the MCU controls). They can pick up the SPI signals sent by the programmer and occasionally write on the bus themselves, therefore disturb communication on the MISO line, which would be critical. There are two options to handle this:

  1. Simply disconnect any SPI slaves during code upload
  2. Make sure there are pullups on the CS lines so they have a defined state (they might be floating while the MCU is in reset). Some slaves might require pulldowns to be deactivated, but that's uncommon.
3
  • Thanks for the detailed reply! Questions: when you say CS lines, are you referring to the slave select lines? And are pull ups resistors where one end goes to vcc, and the other goes to the slave select port on the sensor? Right now I'm imagining that somehow the pull up resistor is keeping the slave select line high during reset. I guess because it's common for slaves to be active low. If a pull-up keeps the SS high, how does board A in normal operation drive the SS line low to say "hey sensor, send me data"?
    – SomeGuy
    Dec 21 '20 at 16:51
  • the SPI protocol says that the selected slave has SS LOW and slaves with SS HIGH should not access the bus
    – Juraj
    Dec 22 '20 at 7:22
  • 1
    @SomeGuy yes, I'm referring to slave select lines. yes, pullups are connected between Vcc and the line to be pulled up. if all of your slaves have pullups anyway, you should have no problems to upload code
    – Sim Son
    Dec 23 '20 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.