I have an SPI slave connected to Due. I send the SPI slave into sleep mode. During sleep, I need to pull all pins low, including MOSI. What's the best way to pull the SPI-4 pin low on a Due?

Here's a similar question but it's about an AVR chip and the answer obviously doesn't apply to SAM3X8 which is an ARM.

  • Is it the only slave that is connected to the Due?
    – Sim Son
    Mar 5 '20 at 13:06
  • @SimSon Yes it's the only one. Mar 5 '20 at 13:11
  • Then you could disable the SPI and set the MISO pin as output low
    – Sim Son
    Mar 5 '20 at 14:23
  • Disable SPI, disable peripheral clock for SPI, change back corresponding pins from alternate functions to normal pin functions and set proper outputs. But you should also disable power for the slave. Otherwise low on its chip select pin means it'll be active
    – KIIV
    Mar 5 '20 at 15:28
  • 1
    @DmitryGrigoryev arduino.cc/en/uploads/Main/arduino-Due-schematic.pdf -> SPI header pin 4 is PA26. So, you have to take a look into datasheet and figure out, how to set/reset it's alternate function
    – KIIV
    Mar 5 '20 at 16:16

I have managed to set MOSI to low by setting bit 26 in PIOA->PIO_PER, PIOA->PIO_OER and PIOA->PIO_CODR registers. To use SPI again, bit 26 in PIOA->PIO_PDR has to be set (this cancels the effect of PIOA->PIO_PER).

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.