Lab 2: Log Data to SD Card

Step 3: With MHC, configure SDSPI Driver, SPI Peripheral Library, and SPI pins

1

Attach an SD Card Driver to the FILE SYSTEM service. Right-click the red square next to DRV_MEDIA to bring up a list of Satisfiers that can be used to attach to this component. Select the SD Card (SPI) driver by clicking on it.

lab2_step3_01a.png
Figure 1: Add SD Card (SPI) Driver

Select Instance 0 of the SD Card (SPI) Driver and choose RB7 as the Chip Select Pin.

lab2_step3_01b.png
Figure 2: Configure Chip Select Pin

2

Attach an SPI peripheral (PLIB) to the SD Card Driver. Right-click on the yellow diamond next to SPI. From the Satisfiers list, select SPI2. This matches the hardware SPI peripheral of the WFI32E Module that is routed to the IO1 Xplained Pro's SD Card.

lab2_step3_02a.png
Figure 3: Add SPI2 Peripheral

The SPI2 Component is now part of the Project Graph. Leave the configuration with default values.

lab2_step3_02b.png
Figure 4: SPI2 Configuration Options

3

Enable and configure the pins connected to the SPI2 Peripheral. Open MHC > Tools > Pin Configuration and select Pin Table. In addition to I2C and BSP pins you enabled during Lab 1, you should enable the following pins for SPI operations:

  • SDI2 (Pin #B19) and SDO2 (Pin #B18) for SPI PLIB
  • GPIO RB7 (Pin #A57) for SPI2 Chip Select
  • GPIO RB2 (Pin #B51) for SD Card detect feature
lab2_step3_03a.png
Figure 5: Pin Table

Apply the following configuration in the Pin Settings tab:

  • GPIO RB7 (Pin #A57) configured as Digital Output with high level by default
  • GPIO RB2 (Pin #B51) configured as Digital Input with Change Notification and Pull-up both enabled
lab2_step3_03b.png
Figure 6: Configure RB2 and RB7 in Pin Settings



Next Step >

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.