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.

CCS/TMS320F28069M: Program stops running when I try to use the data received through SPI interface

Part Number: TMS320F28069M
Other Parts Discussed in Thread: DAC128S085EVM

Tool/software: Code Composer Studio

Hello,

I am using the C2000 board to collect data from an ADC (MAX1202) and I am also using the DAC booster pack (DAC128S085EVM). I have no issues with sending or receiving data from these devices, however, when I try to use the data received from the ADC for some calculations, my program stops running.

Here is the contents of the project: https://db.tt/QHnD94zKVM

Code is pretty big, the main issue is:

1) spibphb =  SpibRegs.SPIRXBUF;
     while(SpibRegs.SPIFFRX.bit.RXFFST !=1) { }
    spibphc =  SpibRegs.SPIRXBUF;

2) I combine the data that I get from ADC: (spibphb<<5) | (spibphc>>3);

3) Assign a variable to it: v1x = (spibphb<<5) | (spibphc>>3);

4) Now If I try to use v1x for any arithmetic operation, my code stops. If I do not use v1x, then the code runs fine.

For example: If i use it in: beta = QMul(OneBySqrRtThree,v1x,15) - QMul(OneBySqrRtThree,v3,15);

Where #define QMul(x,y,n) (Int16)(((Int32)(x)*(Int32)(y))>>n), the code stops working.

I found out by putting the breakpoint that using v1x stops my code.

Please help me resolve this issue, I would greatly appreciate it. Thanks.

  • Hello,
    I am writing to let you know that a C2000 team member has been assigned to this post and should be answering shortly.

    Regards
    Baskaran
  • Hello,

    What do you mean by "the code stops working"? Is the device resetting? Are you hitting an ESTOP0 somewhere?

    Can you try swapping v1x with a constant value in the statement that causes the issue? What happens?

    Thanks,
    Whitney
  • Hi,

    The EPWM interrupt stops working, the device is not resetting. Yes, swapping v1x with a constant value enables the interrupt. But, using the value from ADC in the calculations disables the EPWM interrupt.
  • Can you place breakpoints to look at what the values of v1x and the result of your QMult calculation are to make sure they are in an expected range? Is there a connection between these calculations and the PWM? Are you using them to configure the PWM?

    Whitney
  • Hello,

    Thanks for your reply.

    1) Yes, the value of v1x is in the expected range, data is not corrupted

    2) I am using the value to do an abc to dq transformation, the period register of EPWM is unaffected. I am not configuring PWM, its fixed.

    I also noticed something over the weekend:

    A) When I try to just read the ADC data and send it through DAC channel, the code works fine, (working code --https://db.tt/tQ01tniytk )

    B) Previously, I was using a separate function for SpiA and SpiB, I put both of them in a single function, and pretty much put my entire code in the ISR souce file. Now the interrupt works fine ONLY if the power supply for the ADC is disconnected. Whenever I try to power up the ADC, the interrupt is disabled and the code stops working, here's the code --> https://db.tt/txOeHgCEhs.

    Here's the EPWM intialization:

    void Init_Epwm7 (void){

    EPwm7Regs.TBCTL.bit.CTRMODE = 0; // up 00, dw = 1, up_down = 2
    EPwm7Regs.TBCTL.bit.PHSEN =0;
    EPwm7Regs.TBCTL.bit.PRDLD =0;
    EPwm7Regs.TBCTL.bit.SYNCOSEL =3;
    EPwm7Regs.TBCTL.bit.SWFSYNC =0;
    EPwm7Regs.TBCTL.bit.HSPCLKDIV =0x0;
    EPwm7Regs.TBCTL.bit.CLKDIV = 0x0;
    EPwm7Regs.TBCTL.bit.PHSDIR = 0x0;
    EPwm7Regs.TBCTL.bit.FREE_SOFT = 3;

    EPwm7Regs.TBPRD = dPrdscale; //4000L

    EPwm7Regs.TBCTR = 0;


    EPwm7Regs.CMPA.half.CMPA = dPrdscale/2;// 0x6000;
    EPwm7Regs.CMPB = dPrdscale/2;// 0x3000;

    EPwm7Regs.CMPCTL.all = 0x0000;


    EPwm7Regs.AQCTLA.bit.ZRO = 2;
    EPwm7Regs.AQCTLA.bit.PRD = 0; // updown
    EPwm7Regs.AQCTLA.bit.CAU = 1;
    EPwm7Regs.AQCTLA.bit.CAD = 0;
    EPwm7Regs.AQCTLA.bit.CBU = 0;
    EPwm7Regs.AQCTLA.bit.CBD = 0;

    EPwm7Regs.AQCTLB.bit.ZRO = 2;
    EPwm7Regs.AQCTLB.bit.PRD = 0;
    EPwm7Regs.AQCTLB.bit.CAU = 0; // updown
    EPwm7Regs.AQCTLB.bit.CAD = 0;
    EPwm7Regs.AQCTLB.bit.CBU = 1;
    EPwm7Regs.AQCTLB.bit.CBD = 0;

    EPwm7Regs.DBCTL.bit.OUT_MODE = 0;
    EPwm7Regs.DBCTL.bit.POLSEL = 2;
    EPwm7Regs.DBCTL.bit.IN_MODE = 0; //pwma used for both A & B
    EPwm7Regs.DBCTL.bit.HALFCYCLE = 1;

    EPwm7Regs.ETSEL.bit.INTSEL = 1;
    EPwm7Regs.ETSEL.bit.INTEN = 1; // pg 54 in ppt

    EPwm7Regs.ETPS.bit.INTPRD = 3;

    EPwm7Regs.DBFED = 100;
    EPwm7Regs.DBRED = 100;


    }

    Any guesses as to what might cause the interrupt to be disabled when other devices are powered up?, the power supply to the ADC is via batteries.

    Is there an optimum way to call a function in the ISR?

    Thanks for your help, greatly appreciate it.
  • Hello,

    The problem was solved, in the PieCtrlRegs, I was not clearing the ACK3 flag. I put this section of the code just before ending my ISR.

    EPwm7Regs.ETCLR.bit.INT = 1; // Clear INT flag for this timer
    PieCtrlRegs.PIEACK.bit.ACK3 = 1; // writing 1 clears this flag
    EPwm8Regs.ETCLR.bit.INT = 1; // Clear INT flag for this timer
    PieCtrlRegs.PIEACK.bit.ACK3 = 1; // writing 1 clears this flag

    Thanks for your prompt replies, greatly appreciate it.
  • Glad to hear you found the issue!

    Whitney