Lecture 8 - Review of SPI, Process of DAC

Review of SPI

1/26/24
Comms in SPI initiated by controller
Controller activates the /CS and provides the SCK Both the controller and the peripheral device must be expecting the same clock
Clock may idle high or low Data may be valid on the leading or the trailing edge
To initiate data transfer, send dummy data over SDO, this will make the hardware send a clock over SCK.
Set /CS low. The peripheral device will then send data back to the MCU. For multiple peripheral devices, use multiple /CS pins.
SDO - MOSI (master out, slave in) COPI (controller out, peripheral in)
SDO - MISO (master in, slave out) CIPO (controller in, peripheral out)
On STM32: 3 independent SPI ports Selectable through the alternate function
MODER and AFR registers in the GPIO Pins listed in table 17 of the datasheet
AF5 or AF6 - many options: SPI1 can be found on PA4-7, PB3-5, PE12-15, PG2-5

DAC Approach

Recall what a Digital-Analog-Converter is:

So to go from hex number (digital) to analog voltage, the formula is:

3.3/(2101)

So 0x3FF maps to 3.3V. We can go backwards via:

Vexp3.3V(2101)=Digital,value