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.

TMS320F28379D: speed measurement on CPU2

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Hi everyone,

I am trying to measure motor speed on CPU2. For this purpose;

I used TI-example "eqep_pos_speed_cpu01" in C2000Ware. 

Seeking to transfer the operation to CPU2 we did the following steps:

1- in Gpio.c ;

GpioCtrlRegs.GPACSEL3.all = 0x22222222; // GPIO 16-23  |. 0=CPU1, 1=CPU1.CLA1, 2=CPU2, 3=CPU2.CLA1

2- I copied POSSPEED_Init  and POSSPEED_calc functions from CPU1 to CPU2.

But I cannot read speed on CPU2. 

I am thankful for any hint and advice.

Best regards...

  • Hi,

    Did you also configure CPUSEL2.EQEP1 to "1" so that ownership of eQEP1 now belongs to CPU2 to read register content and be able to calculate POSSPEED?

    Best Regards,

    Nirav

  • Hi 

    I added "DevCfgRegs.CPUSEL2.bit.EQEP1 = 1;" to begining of main_cpu1.

    In addition, I added "CpuSysRegs.PCLKCR4.bit.EQEP1 = 1;" to begining of main_cpu2.

    However, the speed value still cannot be measured.

    Even though I run the following code for qep registers in cpu2 (POSSPEED_Init), I see that

    these registers do not change (all values are 0) in the Expressions window of cpu2.

    void POSSPEED_Init()
    {

    EQep1Regs.QUPRD=2000000; // Unit Timer for 100Hz at 200 MHz SYSCLKOUT

    EQep1Regs.QDECCTL.bit.QSRC=00; // QEP quadrature count mode

    EQep1Regs.QEPCTL.bit.FREE_SOFT=2;
    EQep1Regs.QEPCTL.bit.PCRM=00; // PCRM=00 mode - QPOSCNT reset on index event
    EQep1Regs.QEPCTL.bit.UTE=1; // Unit Timeout Enable
    EQep1Regs.QEPCTL.bit.QCLM=1; // Latch on unit time out
    EQep1Regs.QPOSMAX=0xffffffff;
    EQep1Regs.QEPCTL.bit.QPEN=1; // QEP enable

    EQep1Regs.QCAPCTL.bit.UPPS=5; // 1/32 for unit position
    EQep1Regs.QCAPCTL.bit.CCPS=6; // 1/64 for CAP clock
    EQep1Regs.QCAPCTL.bit.CEN=1; // QEP Capture Enable

    }

  • Hi,

    If you are reading eQEP registers all 0 that tells me that the access by CPU2 is blocked. Can you also dump CPUSEL2 and PCLKCR4 register to make sure it did not get reset?

    Best Regards,

    Nirav

  • Hi

    My main program of CPU1 is as follow.

    void main(void)

    {

    //--- CPU Initialization

    InitPieCtrl(); // Initialize and enable the PIE (FILE: PieCtrl.c)

    InitWatchdog(); // Initialize the Watchdog Timer (FILE: WatchDog.c)

    DevCfgRegs.CPUSEL2.bit.EQEP1=1;

    //--- Enable global interrupts

    asm(" CLRC INTM, DBGM"); // Enable global interrupts and realtime debug

    //--- Clear IPC1 Flag

       IpcRegs.IPCCLR.bit.IPC1 = 1;

       PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

    //--- Enable IPC PIE interrupts

       PieCtrlRegs.PIEIER1.bit.INTx14 = 1; // Enable IPC1 ISR

    IER |= 0x0001;                          // Enable INT1 in IER to enable PIE group 1

    //--- Let CPU1 know that CPU2 is ready

    IpcRegs.IPCSET.bit.IPC17 = 1; // Set IPC17 to release CPU1

    //--- Enable global interrupts

    asm(" CLRC INTM, DBGM"); // Enable global interrupts and realtime debug

    while(1) // endless loop - wait for an interrupt

    {

    asm (" NOP");

    }

    }

    My main program of CPU2 is as follow.

    void main(void)

    {

    //--- CPU Initialization

    InitSysCtrl(); // Initialize the CPU (FILE: SysCtrl.c)

    InitGpio(); // Initialize the shared GPIO pins (FILE: Gpio.c)

    InitPieCtrl(); // Initialize and enable the PIE (FILE: PieCtrl.c)

    InitWatchdog(); // Initialize the Watchdog Timer (FILE: WatchDog.c)

    CpuSysRegs.PCLKCR4.bit.EQEP1=1;

    //--- Peripheral Initialization

    InitAdca(); // Initialize the ADC-A (FILE: Adc.c)

    InitDacb();                         // Initialize the DAC-B (File: Dac.c)

    InitEPwm(); // Initialize the EPwm (FILE: EPwm.c)

    inithiz();

    //--- Clear IPC Flags

    IpcRegs.IPCCLR.all = 0xFFFFFFFF;

    //--- Wait here until CPU2 is ready

    while (IpcRegs.IPCSTS.bit.IPC17 == 0) ; // Wait for CPU2 to set IPC17

    IpcRegs.IPCACK.bit.IPC17 = 1; // Acknowledge and clear IPC17

    //--- Enable global interrupts

    asm(" CLRC INTM, DBGM"); // Enable global interrupts and realtime debug

    //--- Main Loop

    while(1) // endless loop - wait for an interrupt

    {

    asm (" NOP");

    }

    }

    Best regards.

  • Hi Nirav,

    You are right.  In my code, access to eqep register by CPU2 is blocked. I solved this problem with "eallow" and "edis". Thanks for your interest.

    Best regards.