This example shows how to configure the device in SPI Host mode, control a client and send dummy data (value 0).
More details and code examples on the AVR128DA48 can be found at the following links:
- TB3215 - Getting Started with Serial Peripheral Interface (SPI)
- AVR128DA48 Product Page
- AVR128DA48 Code Examples on GitHub
- AVR128DA48 Project Examples in START
- MPLAB® X IDE 5.40 or newer (microchip.com/mplab/mplab-x-ide)
- MPLAB® XC8 2.30 or a newer compiler (microchip.com/mplab/compilers)
- MPLAB® Code Configurator (MCC) 4.0.1 or newer (microchip.com/mplab/mplab-code-configurator)
- MPLAB® Code Configurator (MCC) Device Libraries 8-bit AVR MCUs 2.5.0 or newer (microchip.com/mplab/mplab-code-configurator)
- AVR-Dx 1.4.75 or newer Device Pack
- AVR128DA48 Curiosity Nano (DM164151)
The AVR128DA48 Curiosity Nano Development Board is used as a test platform.
The following configurations must be made for this project:
- System clock is configured at 3.33 MHz
- SPI
- SPI clock configured at 416.66 kHz
- SPI in Host mode
- Data mode 0
- LSB transmitted first
- Clock Double enabled
- SCK - PA6, SS - PA7, MOSI - PA4, MISO - PA5
Pin | Configuration |
---|---|
PA4 (MOSI) | Digital output |
PA5 (MISO) | Digital input |
PA6 (SCK) | Digital output |
PA7 (SS) | Digital output |
-
Connect the board to the PC.
-
Open the Sending_Data_as_Host.X project in MPLAB® X IDE.
-
Set the Sending_Data_as_Host.X project as the main project. Right click the project in the Projects tab and click Set as Main Project.
- Clean and build the Sending_Data_as_Host.X project. Right click the Sending_Data_as_Host.X project and select Clean and Build.
- Select AVR128DA48 Curiosity Nano in the Connected Hardware Tool section of the project settings:
- Right click the project and click Properties;
- Click the arrow under the Connected Hardware Tool;
- Select AVR128DA48 Curiosity Nano (click the SN), click Apply and then click OK:
- Program the project to the board. Right click the project and then click Make and Program Device.
The image below shows the MOSI (PA4), SCK (PA6) and SS (PA7) signals captured by a logic analyzer. Every time the client is selected (SS line low), the device outputs the SCK signal and sends 0x00
through MOSI line.
This example showed how to configure the device in SPI Host mode, control a client and send dummy data (value 0x00
).