SPI external loopback polling
This example demonstrates SPI communication using polling-based transmit and receive operations. The application configures two SPI instances (controller and peripheral) and performs an external loopback test where data sent from the controller instance is received by the peripheral instance. The transfer uses polling methods to check for completion of transmit and receive operations.
Example Usage
Connect the SPI pins as described in the External Connections table.
Build and run the example on the device.
The application initializes both SPI instances with:
Controller configured at 500 kbps bit rate
Both using SPI phase 1 (data sampled on trailing edge)
Polling-based operation
The controller sends test data to the peripheral.
The peripheral receives the data using polling methods.
The application verifies that the received data matches the transmitted data.
The console will display the result of the test, indicating success or failure.
This example demonstrates:
SPI controller and peripheral configuration
Polling-based SPI transfers
External loopback validation of SPI communication
External connections
Controller (UC3) |
Peripheral (UC1) |
|---|---|
SCLK (PB5) |
SCLK (PB4) |
MOSI (PB10) |
MOSI (PA30) |
MISO (PA20) |
MISO (PA28) |
CS0 (PA21) |
CS0 (PA31) |
Controller (UC3) |
Peripheral (UC1) |
|---|---|
SCLK (PA25) (HSECDOCK-71) |
SCLK (PB22) (HSECDOCK-72) |
MOSI (PC4) (HSECDOCK-86) |
MOSI (PB20) (HSECDOCK-70) |
MISO (PA24) (HSECDOCK-67) |
MISO (PB21) (HSECDOCK-68) |
CS0 (PA21) (HSECDOCK-73) |
CS0 (PB19) (HSECDOCK-74) |