Documentation Bug in SPI Reference
i refer first table (spi modes) on page: https://www.arduino.cc/en/reference/spi
problem: in last column (output edge) lower 2 entries have swapped.
the correct table should be:
spi_mode0: cpol=0, cpha=0, data out on falling clock, data sample on rising clock
spi_mode1: cpol=0, cpha=1, data out on rising clock, data sample on falling clock
spi_mode2: cpol=1, cpha=0, data out on rising clock, data sample on falling clock
spi_mode3: cpol=1, cpha=1, data out on falling clock, data sample on rising clock

source: www.corelis.com
somre more notes side:
- internet full of descriptions these modes , many of them different. last 2 modes exchanged (as happend on arduino reference)
- should document behavior of arduino boards (which differs table on spi reference page)
- table on reference page includes column data output. misleading, because first data output has happen without clock edge in modes 0 , 2.
- think more important mention time when data sampled client.
- picture helpful here too...
- finally: think topic important. spent days on topic , had apply modern measure equipment figure out problem in hardware setup.
thanks,
oliver
problem: in last column (output edge) lower 2 entries have swapped.
the correct table should be:
spi_mode0: cpol=0, cpha=0, data out on falling clock, data sample on rising clock
spi_mode1: cpol=0, cpha=1, data out on rising clock, data sample on falling clock
spi_mode2: cpol=1, cpha=0, data out on rising clock, data sample on falling clock
spi_mode3: cpol=1, cpha=1, data out on falling clock, data sample on rising clock
source: www.corelis.com
somre more notes side:
- internet full of descriptions these modes , many of them different. last 2 modes exchanged (as happend on arduino reference)
- should document behavior of arduino boards (which differs table on spi reference page)
- table on reference page includes column data output. misleading, because first data output has happen without clock edge in modes 0 , 2.
- think more important mention time when data sampled client.
- picture helpful here too...
- finally: think topic important. spent days on topic , had apply modern measure equipment figure out problem in hardware setup.
thanks,
oliver
i took screenshots arduino uno, due , 101 boards following code:
the byte 0x053 (bit pattern 01010011) sent via spi in 4 modes. left right spi mode 0, 1, 2 , 3.
please @ attached screenshots scope.
you can see (1) 3 plattforms behave in same way , (2) output data changed on falling edge of clock signal mode 0 , 3 (and not mode 0 , 2 mentioned on spi reference page).
oliver
code: [select]
#include <spi.h>
void setup() {
spi.begin();
}
void loop() {
spi.begintransaction(spisettings(1000000, msbfirst, spi_mode0));
spi.transfer(0x053);
spi.endtransaction();
delaymicroseconds(1);
spi.begintransaction(spisettings(1000000, msbfirst, spi_mode1));
spi.transfer(0x053);
spi.endtransaction();
delaymicroseconds(1);
spi.begintransaction(spisettings(1000000, msbfirst, spi_mode2));
spi.transfer(0x053);
spi.endtransaction();
delaymicroseconds(1);
spi.begintransaction(spisettings(1000000, msbfirst, spi_mode3));
spi.transfer(0x053);
spi.endtransaction();
delaymicroseconds(16*8);
}the byte 0x053 (bit pattern 01010011) sent via spi in 4 modes. left right spi mode 0, 1, 2 , 3.
please @ attached screenshots scope.
you can see (1) 3 plattforms behave in same way , (2) output data changed on falling edge of clock signal mode 0 , 3 (and not mode 0 , 2 mentioned on spi reference page).
oliver
Arduino Forum > Development > Other Software Development > Documentation Bug in SPI Reference
arduino
Comments
Post a Comment