This question is similar to SPI - Apparently Random pulses on CS/SS line in that I have a single SPI peripheral (a Microchip 23LC512 Serial SRAM) that an Arduino UNO is communicating to.

Everything is set up correctly, and indeed, the chip works. I can write to and read from it without issue (example write function).

void writeSRAM(uint16_t address, uint8_t data) {

  digitalWrite(SS, LOW); // Select chip
  uint8_t addr_h = (address & 0xff00) >> 8;
  uint8_t addr_l = (address & 0xff);
  uint8_t xfer[] = {WRITE_CMD, addr_h, addr_l, data};

  SPI.transfer(xfer, sizeof(xfer));
  digitalWrite(SS, HIGH); // Deselect


Yet, while SPI.transfer is occurring the CS line is occasionally popping up. This doesn't bother the chip apparently as the short blip of 40ns seems to be tolerated, yet it interferes with the logic analyzer decoders (one of which is custom).

My question is whether or not I should "protect" the CS line with (a pull-up or pull-down resistor of 10K appears to make no difference) to eliminate this noise (which I assume is not a bug in the Arduino SPI library as I see no reason a spurious raise CS would be there).

Logic Analyzer

  • 1
    The SPI library at it is for an UNO has essentially no bearing on the operation of your CS line. For a 328P you can't allow the AVR's SS signal (UNO digital 10) to go low as an input when you're in master mode. This is the limit to which the UNO SPI has any intersection with any notion of SS/CS signal. Since your code seems to be using SS as output to operate your device's SS/CS you can pretty well ignore the SPI library as a cause for concern. Given that you are driving SS/CS high and low, a pull resistor won't do much. Seems more likely a circuit layout/measurement problem. Use a scope.
    – timemage
    Dec 28, 2022 at 22:23


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.