Auto-increment address of SPI device?

Is it possible to utilize the address auto-increment feature of some SPI devices with the Arduino SPI library? Basically, reading the datasheet of the MCP795xx family of real time clocks, after you send a READ request, as long as you continue to send SCK pulses, the RTC will automatically increment the internal address pointer so you can quickly shift all the register data out of the device.

"After the READ instruction and address are sent, the
data stored in the memory at the selected address is
shifted out on the SO pin. Data stored in the memory at
the next address can be read sequentially by
continuing to provide clock pulses to the client. The
internal Address Pointer automatically increments to
the next higher address after each byte of data is
shifted out. The Address Pointer allows the entire
memory block to be serially read during one operation.
The read operation is terminated by driving CS high"

You have nothing to add in your code to use the auto-increment feature of this SPI device. As you said, just send SCK pulses or whatever, and the address will auto-increment automatically. What do you want to do exactly ?

1 Like

Be notified, that this auto increment is a feature of MCP795x and not the feature of SPI.
Random SPI device doesn't have an auto increment

I wasn't sure about the syntax to do this but I realized that on reading data, SPI.transfer() ignores whatever's passed to it so I can just call it over and over with a dummy argument and it and I'll get all the data I need.

I'm actually finding the feature a bit irritating now, since the chip seems to always auto-increment starting from the first address you pass it. For instance, if I want to read or write two non-consecutive addresses, I have to pull the SS pin high then low, send another READ/WRITE instruction then pass the new address.

Sure.
And otherwise how do you inform the chip that you need the data from another address?

With addresses yes, but from what I understand usually you don't have to reset the SS pin between address selections.

For instance, say I only want to read addresses 0x03 and 0x06.

I should just be able to go:

SPI.begin();
digitalWrite(SS, LOW);

SPI.transfer(READ);
SPI.transfer(0x03);
dataA = SPI.transfer(0);
SPI.transfer(0x06);
dataB = SPI.transfer(0);

But with the 79510 I need to re-select the chip between non consecutive addresses:

SPI.begin();
digitalWrite(SS, LOW);

SPI.transfer(READ);
SPI.transfer(0x03);
dataA = SPI.transfer(0);
digitalWrite(SS, HIGH);
delay(10);
digitalWrite(SS, LOW);
SPI.transfer(READ)
SPI.transfer(0x06);
dataB = SPI.transfer(0);

If I don't re-select the chip like above, dataB will end up with the data from address 0x04 due to the auto increment feature. It ignores new instructions and addresses until it's reselected.

Because the chip read the address just after selection only. After that it will ignore all next data that you send until new selection.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.