-
Notifications
You must be signed in to change notification settings - Fork 0
(FRC) Using SPI
cwm9cwm9 edited this page Mar 15, 2023
·
5 revisions
RoboRio SPI overview:
- Fast 4 Mhz transfer rate (vs 400 Khz I2C transfer rate)
- Supports up to 4 devices using a chip select line to choose which device to communicate with.
- 3 wires are required for one-way communication, 4 for two-way communication.
- A clock select line which both selects a device and indicates the transmission of the first bit
- A clock line synchronizes the transfer of data
- Possibly a COPI - "Controller Out Peripheral In" line (synonymous and preferred to MOSI - "Master Out Slave In")
- Possibly a CIPO - "Controller In Peripheral Out" line (synonymous and preferred to MISO - "Master In Slave Out")
- The STEM community has widely discontinued the use of master/slave terminology. Many terms across the industry have changed as a result.
Hardware details:
-
RoboRio
- The maximum length for SPI wiring is 2.0 m (6.56 ft)
- CS<3..0> all have a 30K pullup resistor to 3.3V
- SCLK, COPI, CIPO have a 40K Ohm pulldown resistor to GND
-
CIPO input logic levels
- VIL ("input low" voltage range)
- 0.0v min
- 0.8v max
- VIH ("input high" voltage range)
- 2.0V min
- 5.25V max
- VIL ("input low" voltage range)
-
COPI/SCLK/CS output voltage levels
- VOL ("output low" volage range, guaranteed only when sinking 4ma or less)
- 0.0v min
- 0.4v max
- VOH ("output high" voltage range, guaranteed only when sourcing 4ma or less)
- 2.4v min
- 3.465v max
- VOL ("output low" volage range, guaranteed only when sinking 4ma or less)
-
Arduino Uno Rev3 (And probably applies to many other Arduinos, but it is your responsibility to check)
-
COIP/SCLK/CS input voltage levels
- VIL ("input low" voltage range, optional pull-up resistor to Vcc guaranteed between 20k-50k ohms)
- -0.5v min
- 1.35v max (actually 0.3 * Vcc, assuming minimum Vcc of 4.5v for 16 Mhz parts)
- VIH ("input high" voltage range, optional pull-up resistor to Vcc guaranteed between 20k-50k ohms)
- 3.15v min (actually 0.6 * Vcc, assuming maximum Vcc of 5.25v for 16 Mhz parts and RoboRio compatibility)
- 6.0v max (actually Vcc + 0.5v)
- THIS IS A PROBLEM! THE ROBORIO ONLY GUARANTEES VOH = 2.4v, BUT ARDUINO VIH REQUIRES 3.15v!
- VOL ("output low" volage range)
- 0.0v min (implied, no actual value given)
- 0.5v max (when sinking 5ma or less)
- 0.8v max (when sinking 20ma or less)
- VOH ("output high" voltage range, guaranteed only when sourcing 4ma or less)
- 4.1v min (when sourcing 20ma or less and Vcc is 5v --- no value given at Vcc = 4.5v)
- Vcc max (implied, no actual value given)
- VIL ("input low" voltage range, optional pull-up resistor to Vcc guaranteed between 20k-50k ohms)
-
COIP/SCLK/CS input voltage levels
Note that the VOH (Logic high output voltage) of the Robio Rio is only guaranteed to be at least 2.4v, but the Arduino VIH (Logic high input voltage) requires at least 3.15v to work properly (if it is run at 5.25v).
The RoboRio output SCLK and COPI (and CIPO, but that isn't important) pins have a PULL-DOWN 40k ohm resistor. The Arduno input lines have an optional PULL-UP 20k-50k ohm resistor. The RoboRio documentation states "optional pull-up resistor to Vcc guaranteed between 20k-50k ohms", but does not give specific details about what the output stage of the pins actually looks like.