4.2.4 Configuring PIC24 MCU using MCC
The SPI, UART, Timer and external interrupt of the PIC24 MCU must be configured as described below using the MPLAB Code Configurator (MCC).
- Open MCC, then save the
MyConfig.mc3
file to the root of the project.The pin mapping configuration of the MCC is stored in the
MyConfig.mc3
file. - From the “Device Resources” menu of MCC, add the required modules, such as SPI, UART, Timer and external interrupt, to the project.
- SPI Configuration
The ATWINC15x0 PICtail plus module is connected to the J9 connector from pin 33 to pin 62. Therefore, set the SPI2 configuration parameters as shown in the following image. The PIC24 SPI works in the Master mode, and ATWINC15x0 works in the Slave mode.
- UART Configuration
Set the UART configuration parameters as shown in the following image. The user can also set the UART baudrate as required.
- Timer configuration
Set the Timer configuration parameters as shown in the following image. The Timer is used for generating a delay in the ATWINC15x0 driver.
- External Interrupt configuration
Set the external interrupt configuration parameters as shown in the following image. The ATWINC15x0 uses the external interrupt for changing the notification. In this case, INT3 resource of PIC24 is used for generating a change in the notification.
- Pin Manager Configuration
Based on the hardware design, the user needs to configure the pins of the different modules.
The external interrupt pin must be configured using the MCC pin manager grid view as follows.- Connect pin 18 of the ATWINC15x0 PICtail plus to pin 55 of the PICtail plus J9 connector.
- Map pin 55 of the J9 connector to pin 66 of the PIC24 PIM connector.
- Configure pin 66 (RA14) of the PIC24 for INT3 and configure the SPI, UART, ICD, GPIO pins based on the hardware design.
The pin mapping of PIC24 PIM and ATWINC15x0 PICtail plus is shown in the following pin manager grid view snapshot. The user only needs to modify the pin mapping in the pin mapping grid view.
The pin module view shows the details of all of the pin mapping. The user can redefine the name of each of the modules. Based on the user-defined name, the MCC auto-generated modules enable/disable the functionality.
Similarly, user-defined names are updated in the pin manager package view, as shown in the following snapshot.
After adding all of the modules and configuring the pins based on the hardware design, click “Generate” to generate the code, as shown in the following snapshot.