This is a basic tutorial for the steps required to get SPI working on the PIC18F47Q10 Curiosity Nano
Prepare your IC
Surface-Mount Solder: If you have not yet surface-mount soldered your IC, you will need a DIP adapter board and 12 male header pins
ALERT: If you are using the DIP adapter boards supplied in Peralta 109, you should not drive a high current because the ground plane is not connected to a heat-sink pad.
Test: ensure connectivity to all pins after soldering with no connectivity between neighboring pins
Mount your DIP adapter board on a breadboard
Connect ALL pins according to the motor controller datasheet. For the purposes of this assignment, use two different-colored LEDs mounted in opposite directions between OUT1
and OUT2
(with an appropriate current-limiting resistor) to emulate a bidirectional motor.
Note: All pins must be connected to SOMETHING in order for the IC to work. The datasheet explains connection requirements in various sections.
Set up MCC
Set up the MSSPX Pins according to the primary pins given by the PIC18F47Q10 Curiosity Nano Hardware Manual
Note: Chip Select is not a part of the MSSP system and should be set as a GPIO Output Pin
Set the EUSARTX Pins according to the dedicated pins given in the PIC18F47Q10 Curiosity Nano Hardware Manual
Code
SYSTEM_Initialize()
function initializes SPIX.while
loop, open SPIX using one of the functions identified abovewhile
loop,
N
bytes to be written to the motor controller according to the data sheetX
ms (see the data sheet)Y
ms (see the data sheet)N
bytes that were received in the exchange and save to a temporary variable.