Step-by-Step dsPIC33CH Programming Example in MPLAB® Code Configurator (MCC) Melody

Last modified by Microchip on 2024/04/10 14:22

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.

Illustration of mailbox communications within dual core device

Back to Top

Reference Materials

Related Documentation

See the dsPIC33CH512MP508 datasheet for more information and specifications.

Software

Hardware

Back to Top

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

Create an MPLAB X IDE project with the dsPIC33CH128MP508 device and name the project "Main".

Back to Top


Load MCC.

Back to Top


Under Project Resources, click on Secondary Core1.

Project Resources

Back to Top


Switch to the Secondary Core1 module UI.

Back to Top


Enable Configure Secondary Core.

Enable Secondary Core

Back to Top


Enter the secondary project name as "Secondary".

Naming Secondary Project

Back to Top


In the MSI settings:

  • Enable Protocol A and change the direction to M->S.
  • Enable Protocol B.

Secondary Core MSI Setting

Back to Top


Under Pins Grid View select RE0 as GPIO output.

Pins Grid View

Back to Top


In Secondary Core UI assign Output pin ownership for RE1 to Secondary Core1.

Output Pin Ownership

Back to Top


Under Pins view, change the custom name of RE0 to "LED_Main".

Pins Custom name

Back to Top


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.

Save Secondary Configurations

Back to Top


Generate the code.

Back to Top

Configuring the Secondary Project

Create an MPLAB X IDE project with the dsPIC33CH128MP508S1 device and name the project "Secondary".

Back to Top


Load MCC.

Back to Top


Under Project Resources, click on Main Core.

Project Resource

Back to Top


Switch to the Main Core module UI.

Back to Top


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.

Import Secondary Settings

Back to Top


Upon Import, All MSI Protocol settings related to the Secondary Core that were configured in the main project get updated to the secondary project.

Back to Top


Under Pins Grid View, select RE1 as GPIO output.

Secondary Pins Grid View

Back to Top


Under the Pins view, change the custom name of RE1 to "LED_Secondary".

Secondary Pins Custom name

Back to Top


Generate the code.

Back to Top

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….

Add Secondary

Back to Top


Browse to the secondary project location and select the Secondary.X image.

Secondary Image Path

Back to Top


In the main project, select Secondaries in the folders list. Right-click to change the properties. Select the Build checkbox.

Secondary Build

Back to Top


Build the main project and program.

Back to Top