It works fine if I compile and download the flash file without powering off. But it doesn't work if I power off and then power on again.
It is suspected that there is no startup code for CPU2 in the CPU1 project, so it needs to be added:
// Send boot command to allow the CPU2 application to begin execution
IPCBootCPU2(0x0000000B);
Of course, in order for the above line of code to compile and run normally, you need to include the relevant brain file: #include "F2837xD_Ipc_drivers.h"
And the import of the source file where the function is located: F2837xD_Ipc_Driver_Util.c
The main function of CPU1, adc_epwm_cpu01.c, is changed to the following:
#include "F28x_Project.h"
#include "F2837xD_Ipc_drivers.h"
void main(void)
{
InitSysCtrl();
// Send boot command to allow the CPU2 application to begin execution
IPCBootCPU2(0x0000000B);
InitGpio();
GPIO_SetupPinMux(31, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(31, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(34, GPIO_MUX_CPU2, 0);
GPIO_SetupPinOptions(34, GPIO_OUTPUT, GPIO_PUSHPULL);
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
InitEPwm1Gpio();
// Transfer ownership of EPWM1 and ADCA to CPU02
EALLOW;
DevCfgRegs.CPUSEL0.bit.EPWM1 = 1;
DevCfgRegs.CPUSEL11.bit.ADC_A = 1;
EDIS;
while(1)
{
GPIO_WritePin(31, 0);
DELAY_US(1000*500);
GPIO_WritePin(31, 1);
DELAY_US(1000*500);
}
}
The main function of CPU2, adc_epwm_cpu02.c, basically does not need to be changed.
|