Serial Peripheral Interface (SPI) is used to communicate to the AS1100.
Thusly described is my coming to understand SPI a bit more, and setting it up on the Arduino with the Arduino SPI library.
Oscilloscope connected to Arduino, and both to a common ground.
The breadboard is just used for common ground. Other elements here are for the bus sign, which is out of the scope of this file.
This code uses the Arduino SPI library to repeatedly send an SPI message.
The SPI settings come from the AS1100 datasheet, with help on choosing them from the Arduino SPI library. They are tabulated here
Setting | Value | Reason |
---|---|---|
Frequency | 10000000 (10 MHz) | The datasheet (section 6, table 3) says 10 ns is the minimum clock cycle time, so 10 MHz is thus the maximum frequency. |
Bit-significance | MSBFIRST |
The AS1100 expects the MSB to be first (section 8.1, table 4) |
SPI Mode | SPI_MODE3 |
This mode has the clock HIGH when no data is being sent, and the data is read on the RISING clock signal. The datasheet requires (section 8.1) the opposite polarity (clock to be LOW when idling), but the electronics use an inverter (as per Hardware.md#ribbon-cable), so we must invert it. |
/*
* SPI test
*/
#include <SPI.h>
#define DATA_PIN 11
#define CLK_PIN 13
void setup(){
SPI.begin();
}
void loop()
{
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE3));
SPI.transfer16(0x0e02);
SPI.endTransaction();
delay(100);
}
Here is the result: a pretty nice SPI signal. The peak to peak is around 5 V.
Now we can use this instead of bit banging to communicate with the screens.