This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
参考controlsuite例程,编写两个IO灯指示程序,用官方2837xD_FLASH_lnk_cpu1.cmd 2837xD_FLASH_lnk_cpu2.cmd文件,CPU1里的点亮LED程序正常运行,CPU2的程序无法加载,点击DEBUG后会出现如下错误提示:C28xx_CPU2: Error setting the GSxMSEL register for Flash operations
CPU1里的程序:
Int main()
{
_watchdog_reg = WdRegs.WDCR.all;
DisableDog();
InitPeripheralClocks();
IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH);
// InitFlash();
led_init_gpio();
GPIO_SetupPinOptions(99, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(99, GPIO_MUX_CPU2, 0);
Clock_tickStart();
Clock_start(every2ms_clock_hndl);
BIOS_start(); /* does not return */
return(0);
}
CPU2里的程序:
Int main()
{
_watchdog_reg = WdRegs.WDCR.all;
DisableDog();
InitPeripheralClocks();
Clock_tickStart();
Clock_start(every2ms_clock_hndl);
BIOS_start(); /* does not return */
return(0);
}
void every2ms_clock_func()
{
if(_tasks_counter % 500 == 0)
{
_tasks_counter = 0;
if (ed_status()==0)
GPIO_WritePin(99, 1);
else
GPIO_WritePin(99, 0);
}
_tasks_counter++;
}
你要调节到CPU1,CPU2 standalone的configuration。这时候CPU1例程的红色区域是被打开的。
void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2837xD_SysCtrl.c file.
InitSysCtrl();
#ifdef _STANDALONE
#ifdef _FLASH
// Send boot command to allow the CPU2 application to begin execution
IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH);
#else
// Send boot command to allow the CPU2 application to begin execution
IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_RAM);
#endif
#endif
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
#ifdef _FLASH
InitFlash();
#endif
// Step 2. Initialize GPIO:
// This example function is found in the F2837xD_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
InitGpio(); // Skipped for this example
EALLOW;
GpioCtrlRegs.GPADIR.bit.GPIO31 = 1;
GPIO_SetupPinOptions(34, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(34, GPIO_MUX_CPU2, 0);
//TODO Add code to allow configuration of GPADIR from CPU02 using IPC
EDIS;
GpioDataRegs.GPADAT.bit.GPIO31 = 1;// turn off LED
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the F2837xD_PieCtrl.c file.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in F2837xD_DefaultIsr.c.
// This function is found in F2837xD_PieVect.c.
InitPieVectTable();
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
// Step 6. IDLE loop. Just sit and loop forever (optional):
for(;;)
{
//
// Turn on LED
//
GpioDataRegs.GPADAT.bit.GPIO31 = 0;
//
// Delay for a bit.
//
DELAY_US(1000 * 500);
//
// Turn off LED
//
GpioDataRegs.GPADAT.bit.GPIO31 = 1;
//
// Delay for a bit.
//
DELAY_US(1000 * 500);
}
}
我把这个定义#ifdef _STANDALONE
#ifdef _FLASH去掉了 直接写的IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH);可以吗
可是CPU2的程序无法加载,点击DEBUG后会出现如下错误提示:C28xx_CPU2: Error setting the GSxMSEL register for Flash operations
我在CPU2里面加了这句IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH);还是会出现C28xx_CPU2: Error setting the GSxMSEL register for Flash operations的错误提示
另外官方例程的CPU2程序里并没有加IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH);这句话,当然官方例程是在RAM里运行的,但也没有配置IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_RAM
您好请问您找到问题所在了么?我现在也卡在CPU2FLASH无法运行这里了,官方例程烧进CPU里只有CPU1断电能正常运行,CPU2无法正常运行,经过各种分析判断问题出在库函数IPCBOOTCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH)这句没有运行正确,单步调试发现该函数返回值正常,但查看寄存器里BOOTCPU2并没有被置位
跟代码、库函数都没有关系,试试下面的方式来load:
1) Launch the target configuration from the Target configurations window (View -> Target Configurations -> Right click on the F28377D ccxml -> Launch selected configuration)
2) Connect to CPU1 and then to CPU2 (In the debug window, select the C28xx_CPU1, right click -> Connect Target. Do the same thing for C28xx_CPU2).
3) Load the code in CPU2 (Select C28xx_CPU2 and then in the debug window menu click on "Run" -> Load -> Load program and choose the .out file that you want to load in to CPU2)