You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
4.5 KiB
4.5 KiB
Creating a dual CPU project
- Open a new folder; not workspace
- Import project from
C2000Ware_26_01_00_00:driverlib/f2837xd/examples/dual/empty_projects/css - Change project names
gpio_bitfield_cpu1gpio_driverlib_cpu2
- Change the
.cfiles also - Driverlib project does not require changes for compiling
- Bitfield project needs some additional compilation variables
- Path type var named
C2000_Commonpoint to/Users/gmarx/ti/C2000Ware_26_01_00_00/device_support/f2837xd/common/include - Path type var named
C2000_Headerspointing to/Users/gmarx/ti/C2000Ware_26_01_00_00/device_support/f2837xd/headers/include
- Path type var named
- Also at
C2000 CompilerandInclude Optionswe should add the previous created vars as:${C2000_Common}${C2000_HEaders}
- Additionally at
C2000 CompilerandPredefined Symbolsadd the entry:_DUAL_HEADERS
- Additional source files must be added from
/Users/gmarx/ti/C2000Ware_26_00_00_00/device_support/f2837xd/common/source:F2837xD_SysCtrl.cF2837xD_usDelay.asm
- Adding the file
F2837xD_GlobalVariableDefs.c-data structure to map all peripherals- that is at/Users/gmarx/ti/C2000Ware_26_00_00_00/device_support/f2837xd/headers/source/F2837xD_GlobalVariableDefs.c - Adding the GPIO file ...
- One last file must be included the
F2837xD_Headers_nonBIOS_cpu1.cmdfrom the path/Users/gmarx/ti/C2000Ware_26_00_00_00/device_support/f2837xd/headers/cmd/F2837xD_Headers_nonBIOS_cpu1.cmdwe are using the nonBIOS option because the code will run in debug mode - However, the CPU2 has an issue at the
Predefined symbols, we must change the nameCPU1toCPU2
GPIOs example
CPU1 - Bitfield
/*
Example project to handle GPIOs from both CPUs using
bitfield and driverlib approaches, respectively on each CPU.
-------------
CPU1: GPIO22 and GPIO97 using bitfield
CPU2: GPIO52 using driverlib
*/
// Included Files
#include "driverlib.h"
#include "device.h"
#include "F28x_Project.h"
// Main
void main(void)
{
// 1: init system
InitSysCtrl();
// 2: configure gpios
EALLOW;
//2.1: GPIO22:
GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 0; // pin as gpio
GpioCtrlRegs.GPADIR.bit.GPIO22 = 1; // configured as output
GpioCtrlRegs.GPACSEL3.bit.GPIO22 = 0; // cpu1 by default
//2.2: GPIO52:
GpioCtrlRegs.GPBMUX2.bit.GPIO52 = 0; // pin as gpio
GpioCtrlRegs.GPBDIR.bit.GPIO52 = 1; // as output
GpioCtrlRegs.GPBCSEL3.bit.GPIO52 = 2; //cpu2
//2.3 GPIO 97:
GpioCtrlRegs.GPDGMUX1.bit.GPIO97 = 0; // pin as gpio
GpioCtrlRegs.GPDDIR.bit.GPIO97 = 1; // output
EDIS;
// 3: Change the gpios state
// 3.1: gpioo22:
GpioDataRegs.GPASET.bit.GPIO22 = 1; // set a logic 1 in the output
// 3.2: gpio97:
GpioDataRegs.GPDSET.bit.GPIO97 = 1; // set a logic 1 in the output
// 4: Infinite loop
}
// End of file
CPU2 - driverlib
The main code is:
/*Gerardo Marx
16th July 2026
GPIOs management with dual CPUs
----------------
CPU1: GPIO22 and GPIO97 using bitfield approach
CPU2: GPIO52 using driverlib approach
|-----------|
| |
|GPIO22 |
| |
| ---- |
|GPIO97 |
| |
|GPIO52 |
|-----------|
*/
// Libraries and includes
#include "driverlib.h"
#include "device.h"
void main(void){
// 1: init uc does not required for CPU2
// 2: config gpios
//GPIO_setPadConfig(52, GPIO_PIN_TYPE_STD);
//GPIO_setDirectionMode(52, GPIO_DIR_MODE_OUT);
//GPIO_setControllerCore()
// 3: change state
GPIO_writePin(52, 1);
// 4: finite loop
for(;;)
{
// control task
}
}
Pin type at gpio.h file
//*****************************************************************************
//
// Values that can be passed to GPIO_setPadConfig() as the pinType parameter
// and returned by GPIO_getPadConfig().
//
//*****************************************************************************
#define GPIO_PIN_TYPE_STD 0x0000U //!< Push-pull output or floating input
#define GPIO_PIN_TYPE_PULLUP 0x0001U //!< Pull-up enable for input
#define GPIO_PIN_TYPE_INVERT 0x0002U //!< Invert polarity on input
#define GPIO_PIN_TYPE_OD 0x0004U //!< Open-drain on output
#endif
Files to explore and use with a second approach instead of GPIO_writePin you can useHWREG function:
hw_memmap.hhw_gpio.h
Compilation error GPIO_EnableUnbondedIOPullups
- /Users/gmarx/ti/C2000Ware_26_00_00_00/device_support/f2837xd/common/include/F2837xD_GlobalPrototypes.h
F2837xD_Gpio.c