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.

TMS320F28377D: Why does cpu2 hate me? Unable to fire a GPIO

Part Number: TMS320F28377D
Other Parts Discussed in Thread: UNIFLASH

Tool/software:

This should be the most basic question, but I am stumped. I want cpu2 to toggle GPIO44.

On cpu2, I have:

#include "F28x_Project.h"
#include "F2837xD_device.h"
#include "F2837xD_Gpio.h"

void main(void)
{
InitSysCtrl();

//
// cpu1 will give us this pin: let's toggle one line at a time to watch in debugger
//

GpioDataRegs.GPBSET.bit.GPIO44 = 1;
GpioDataRegs.GPBSET.bit.GPIO44 = 0;
GpioDataRegs.GPBSET.bit.GPIO44 = 1;
GpioDataRegs.GPBSET.bit.GPIO44 = 0;

//
// Or try a simple blink loop with toggle:
//
for(;;)
{
    GpioDataRegs.GPBTOGGLE.bit.GPIO44 = 1;
    DELAY_US(10000); // 10 000 µs = 0.01 s at 200 MHz SYSCLK
}
}

But obviously I need to start with cpu1 first to get hold of that pin, so I have:


#include "F28x_Project.h"
#include "F2837xD_Ipc.h"
#include "F2837xD_device.h"
#include "F2837xD_GlobalPrototypes.h"
#include "F2837xD_Gpio_defines.h"
#include "F2837xD_Ipc_drivers.h"

static void BootCPU2_FromFlash(void)
{
EALLOW;
IpcRegs.IPCBOOTSTS = 0; // clear stale boot status flags
IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH);
EDIS;
}

void main(void)
{
InitSysCtrl();


EALLOW;
DevCfgRegs.CPU2RESCTL.bit.RESET = 1;   // make sure CPU2 is held in reset
EDIS;

InitGpio();

EALLOW;
GpioCtrlRegs.GPBMUX1.bit.GPIO44 = 0;   // detach from any peripheral
GpioCtrlRegs.GPBDIR.bit.GPIO44 = 1;    // enable for output
GpioDataRegs.GPBSET.bit.GPIO44 = 1;    // turn on just to check scope
GpioCtrlRegs.GPBCSEL2.bit.GPIO44 = 1;  // hand over to CPU2 owns GPIO44
GpioDataRegs.GPBTOGGLE.bit.GPIO44 = 1; // should not toggle
EDIS;

// Basic interrupt/PIE init 
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EINT

// Minimal flash wait state init for CPU1 code
InitFlash();

// Do the boot
BootCPU2_FromFlash();

// CPU1 go idle
for(;;) { asm(" NOP"); }
}

when cpu1 fires up, I see GPIO44 rise on the scope and once GPBCSEL2 is set then the subsequent call to GPBTOGGLE does nothing, which is appropriate. When I then boot cpu2 I do see GPI044 drop to zero which is intriguing, (but I guess ok ?). But no matter what I do from inside cpu2, I cant get the pin to budge. I also tried setting GPBGMUX1 to zero.

What am I missing?  Thanks.

(I am using compiler 20.4 if it is pertinent. I get the same behaviour if I load the code with CCS or Uniflash.)

  • Apparently I just needed to post the question and then almost immediately I would find the answer :-)

    My bug is/was that I am mixing up some older style code with some newer style. If I change cpu1 code to instead do this:

    GPIO_SetupPinMux(44, GPIO_MUX_CPU2, 0);

    GPIO_SetupPinOptions(44, GPIO_OUTPUT, GPIO_PUSHPULL);

    then everything works perfectly.