Step 3.1 - Enable and Configure the SD Card
In the MPLAB® Harmony Configurator (MHC) Options tab, expand the Harmony Framework Configuration > Drivers > SD Card selection tree. Check the Use SD Card Driver? box.
After you check this box, all SD Card driver configuration options become visible. Note the Use SD Card Driver? selection option is now highlighted, indicating this selection has been changed from its default value.
1
Configure the Number of SD Card Clients to 2. This is because the SD Card will be accessed by the application code as well as the TCP/IP stack.
2
The SD Card driver has the Serial Peripheral Interface (SPI) protocol lying underneath. The SPI gets the clock from CLK_BUS_PERIPHERAL_2. Configure the Clock To Use to CLK_BUS_PERIPHERAL_2.
3
Micro SD Cards do not have a write protection pin on them. As we are using a micro SD Card for our application, we will have to disable this action. If this is not disabled, we will not be able to write anything to the SD Card. So, uncheck the Enable Write Protect Check? option.
4
For SD Cards operating in SPI mode, the DATA3/CD line of SD Card is used as a chip select line and the same is connected to port pin RB14. Configure the options Chip Select Port and Chip Select Port Bit to PORT_CHANNEL_B and PORTS_BIT_POS_14 respectively.
Expand the following section to see descriptions of all SD Card configuration options.
Step 3.2 - Configure SPI driver
The SD Card is connected to one of the PIC32's SPI ports (SPI2). Configure the SPI driver used by the SD Card driver.
In the MHC Options tab, expand the Harmony Framework Configuration > Drivers > SPI selection tree. Note that when you checked the box beside the Use SD Card Driver? selection, MHC automatically checked the Use SPI Driver? box for you. Configure the SPI driver as shown:
Expand the following section to see descriptions of all SPI driver configuration options.
Step 3.3 - Verify and Configure the SPI I/O Pins
Verify and Configure the I/O Pins used by the SPI module using the Graphical Pin Manager. Select the Pin Table tab and configure the SPI pins as shown:
SDI2 is not configured in the pin table because pin RD7 is shared between the SPI bus (SPI2) and Ethernet Transmit Clock (ETXCLK) of TCP/IP.
Pin RD7 is mapped to SDI2 in the application code.