Step-by-Step dsPIC33CH Programming Example in MPLAB® Code Configurator (MCC) Melody
This demo illustrates the process involved in using MPLAB® Code Configurator (MCC) Classic version to configure the system, Master Slave Interface (MSI) module for Mailbox data transfer between the Main and Secondary Core, input/output (I/O) pins ownership in a main project, and the secondary project of a dual-core device.
Objective
- Create an MPLAB X IDE project for the Main Core of a dsPIC33CH128MP508 device.
- Start MCC in the main project.
- Set up the configuration for MSI, and I/O pin ownership in the main project and export the settings.
- Configure the MSI mailbox to transfer one word of data from the Main Core to the Secondary Core.
- Configure the MSI mailbox to receive one word of data from the Secondary Core to the Main Core.
- Assign an output pin ownership to the Secondary Core.
- Create a MPLAB X IDE project for the Secondary Core of a dsPIC33CH128MP508S1 device.
- Start MCC in the secondary project.
- Import the settings from the main project into the secondary project.
- Include secondary project in a main project.
- Generate code to:
- Transfer data 0xAAAA from the Main Core to the Secondary Core using MSI.
- Retransmit the received data at the Secondary Core to the Main Core.
- Flash an LED on data match at the Main Core.
- Flash an LED on valid data reception at the Secondary Core.
Reference Materials
Related Documentation
See the dsPIC33CH512MP508 datasheet for more information and specifications.
Software
- MPLAB X IDE v6.10 or newer.
- MPLAB XC16 v2.10 or newer.
- Device Family Pack: dsPIC33CH-MP_DFP v1.15.367.
- MPLAB Code Configurator (MCC) 5.3.7 or newer.
- Example Code for this tutorial - dsPIC33CH Curiosity MSI Mailbox Demo
Hardware
Configuring the Projects with MCC Melody
The following sections provide procedures to configure the main project and the secondary project using MCC.
Configuring the Main Project
Under Project Resources, click on Secondary Core1.
Enable Configure Secondary Core.
Enter the secondary project name as "Secondary".
In the MSI settings:
- Enable Protocol A and change the direction to M->S.
- Enable Protocol B.
Under Pins Grid View select RE0 as GPIO output.
In Secondary Core UI assign Output pin ownership for RE1 to Secondary Core1.
Under Pins view, change the custom name of RE0 to "LED_Main".
To export the settings, click on the Save File button. The settings are saved in the MainCoreConfig.json file, which resides in the selected file path while saving the config file.
Configuring the Secondary Project
Under Project Resources, click on Main Core.
To import the settings, click on the Load File button in the Main Core. The settings are saved in the MainCoreConfig.JSON file, which resides in the file path that has been considered at the time of export configurations. Select the file for import.
Under Pins Grid View, select RE1 as GPIO output.
Under the Pins view, change the custom name of RE1 to "LED_Secondary".
Including the Secondary Project in the Main Project
In the main project, select Secondaries in the folder listing. Right-click and select Add Secondary Project….
Browse to the secondary project location and select the Secondary.X image.
In the main project, select Secondaries in the folders list. Right-click to change the properties. Select the Build checkbox.