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: No data update from SDFM output

Part Number: TMS320F28379D
Other Parts Discussed in Thread: AMC1303E2520

Hi, I'm using AMC1303E2520 to measure the current, which has a Manchester-Encoded Delta-Sigma modulator, and I iinit the SDFM module with the  following code:

void SDFM_init()
{
    //
    // GPIO Init
    //
    EALLOW;
    GpioCtrlRegs.GPDQSEL2.bit.GPIO122 = 3;   //GPIO ASYNC
    GpioCtrlRegs.GPDGMUX2.bit.GPIO122 = 1;
    GpioCtrlRegs.GPDMUX2.bit.GPIO122 = 3;
    EDIS;

    //
    // Configure Input Control Mode: Manchester decoded
    //
    EALLOW;
    Sdfm1Regs.SDCTLPARM1.bit.MOD = 2;               //2: The data from the modulator is Manchester decoded
    EDIS;

    //
    //Configure Data filter modules filter type, OSR value and filter.
    //
    EALLOW;
    Sdfm1Regs.SDDFPARM1.bit.FEN  = 1;               ////Enable  filter
    Sdfm1Regs.SDDFPARM1.bit.SST  = 3;               //Sinc3 filter
    Sdfm1Regs.SDDFPARM1.bit.DOSR  = 255;            //over sampling
    Sdfm1Regs.SDDFPARM1.bit.AE = 1;                 //Ack enable
    Sdfm1Regs.SDDPARM1.bit.DR = 0;                  //0->16-bits, 1->32-bits
    Sdfm1Regs.SDDPARM1.bit.SH = 9;                  //shift 9 bits
    Sdfm1Regs.SDMFILEN.bit.MFE = 1;                 //Master Filter bit is enabled
    EDIS;
}

When there's no signal, Sdfm1Regs.SDDATA1 read nothing.

Next, a Deita-Sigma signal started to transmit, Sdfm1Regs.SDDATA1 register locked to 1000000000000000(Binary) and stop updating,  which is not a correct behavior.

The correct read out should look like this(it should update automatically and read almost zero):

 

It will be awesome if the issue can be solved.

Regards,

  • First, I would recommend you review the advisories relating to Manchester mode in the device errata. Second, have you tried to vary the diff voltage at the input to the AMC device to see if there an effect on the SDFM registers? Your pinmux and SDFM configuration looks ok.

  • Hi

    I'm sure it's not a hardware issue, because I've done the same function on the same hardware before. There's no change on the hardware side.

    Here's the full code:

     

    //###########################################################################
    //
    // FILE:    Control_Board_GPIO_Test.c
    //
    // TITLE:   Device GPIO Setup
    //
    //! \addtogroup cpu01_example_list
    //! <h1> Device GPIO Setup (GpioSetup)</h1>
    //!
    //! Configures the F2837xD GPIO into two different configurations
    //! This code is verbose to illustrate how the GPIO could be setup.
    //! In a real application, lines of code can be combined for improved
    //! code size and efficiency.
    //!
    //! This example only sets-up the GPIO. Nothing is actually done with
    //! the pins after setup.
    //!
    //! \b In \b general: \n
    //!  - All pullup resistors are enabled.  For ePWMs this may not be desired.
    //!  - Input qual for communication ports (eCAN, SPI, SCI, I2C) is asynchronous
    //!  - Input qual for Trip pins (TZ) is asynchronous
    //!  - Input qual for eCAP and eQEP signals is synch to SYSCLKOUT
    //!  - Input qual for some I/O's and __interrupts may have a sampling window
    //!
    //
    //###########################################################################
    //
    // $Release Date: $
    // $Copyright:
    // Copyright (C) 2013-2022 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without 
    // modification, are permitted provided that the following conditions 
    // are met:
    // 
    //   Redistributions of source code must retain the above copyright 
    //   notice, this list of conditions and the following disclaimer.
    // 
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the 
    //   documentation and/or other materials provided with the   
    //   distribution.
    // 
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    // 
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //###########################################################################
    
    //
    // Included Files
    //
    
    #define SPI_BRR        ((200E6 / 4) / 500E3) - 1
    
    
    
    #include "F28x_Project.h"
    #include "F2837xD_sdfm_drivers.h"
    
    unsigned int counter_1 = 0;
    unsigned int counter_2 = 0;
    unsigned int en_sw =0;
    unsigned int LED_mode = 0;
    unsigned int sdata;  // send data
    unsigned int rdata;
    unsigned int val = 0;
    
    float theta = 0;
    int SDFM_RAW = 0;
    //
    // Function Prototypes
    //
    void Gpio_setup1(void);
    void Gpio_setup2(void);
    void ConfigureGPIO(void);
    void delay_loop(void);
    void spi_xmit(Uint16 a);
    void spi_fifo_init(void);
    void spi_init(void);
    void SDFM_init(void);
    void error(void);
    
    interrupt void Encoder1_isr(void);
    interrupt void Encoder2_isr(void);
    interrupt void Encoder1sw_isr(void);
    
    
    
    //
    // Main
    //
    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();
    
    //
    // 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
       ConfigureGPIO();
       spi_fifo_init();     // Initialize the SPI FIFO
       SDFM_init();
    
    
    // Step 3. Clear all __interrupts and initialize PIE vector table:
    // Disable CPU __interrupts
    //
       DINT;
    
    //
    // Initialize 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();
    
    //
    // Map ISR functions
    //
        EALLOW;
        PieVectTable.XINT1_INT = &Encoder1_isr;
        PieVectTable.XINT2_INT = &Encoder2_isr;
        PieVectTable.XINT3_INT = &Encoder1sw_isr;
        EDIS;
    
    //
    // enable PIE interrupt
    //
        PieCtrlRegs.PIEIER1.bit.INTx4 = 1;          // Enable PIE Group 1 INT4(XINT1)
        PieCtrlRegs.PIEIER1.bit.INTx5 = 1;          // Enable PIE Group 1 INT5(XINT2)
        PieCtrlRegs.PIEIER12.bit.INTx1 = 1;         // Enable PIE Group 12 INT1(XINT3)
    
    
    //
    // Enable global Interrupts and higher priority real-time debug events:
    //
        IER |= M_INT1;  //Enable group 1 interrupts
        IER |= M_INT12; //Enable group 1 interrupts
    
        EINT;  // Enable Global interrupt INTM
        ERTM;  // Enable Global realtime interrupt DBGM
    
    
    
    //
    // Step 4. User specific code:
    //
    
        while(1)
        {
    
            //
            // Transmit data
            //
            //DELAY_US(1);
            theta = theta + 0.01;
            if(theta >= 6.283)
                theta=0;
            sdata = 0x2000 + 2048 + 2047*(__sin(theta));
            spi_xmit(sdata);
            //
            // Wait until data is received
            //
            while(SpibRegs.SPIFFRX.bit.RXFFST !=1) { }
    
            //
            // Check against sent data
            //
            rdata = SpibRegs.SPIRXBUF;
    
    
            //
            // Read data from SDFM
            //
            SDFM_RAW = Sdfm1Regs.SDDATA1.bit.DATA32HI;
     
    
    
        }
    }
    
    //
    // ConfigureGPIO
    //
    void ConfigureGPIO(void)
    {
        //
        //Configure SPI-B pins using GPIO regs
        //
        EALLOW;
        GpioCtrlRegs.GPBQSEL2.bit.GPIO63 = 3; // Asynch input GPIO16 (SPIMOSIA)
        GpioCtrlRegs.GPCQSEL1.bit.GPIO64 = 3; // Asynch input GPIO17 (SPIMISOA)
        GpioCtrlRegs.GPCQSEL1.bit.GPIO65 = 3; // Asynch input GPIO18 (SPICLKA)
        GpioCtrlRegs.GPCQSEL1.bit.GPIO66 = 3; // Asynch input GPIO19 (SPISTEA)
    
        GpioCtrlRegs.GPBMUX2.bit.GPIO63 = 3; // Configure GPIO16 as SPIMOSIA
        GpioCtrlRegs.GPCMUX1.bit.GPIO64 = 3; // Configure GPIO17 as SPIMISOA
        GpioCtrlRegs.GPCMUX1.bit.GPIO65 = 3; // Configure GPIO18 as SPICLKA
        GpioCtrlRegs.GPCMUX1.bit.GPIO66 = 3; // Configure GPIO19 as SPISTEA
    
        GpioCtrlRegs.GPBGMUX2.bit.GPIO63 = 3; // Configure GPIO16 as SPIMOSIA
        GpioCtrlRegs.GPCGMUX1.bit.GPIO64 = 3; // Configure GPIO17 as SPIMISOA
        GpioCtrlRegs.GPCGMUX1.bit.GPIO65 = 3; // Configure GPIO18 as SPICLKA
        GpioCtrlRegs.GPCGMUX1.bit.GPIO66 = 3; // Configure GPIO19 as SPISTEA
        EDIS;
    
    }
    
    
    
    //
    // Encoder1_isr - External Interrupt 1 ISR - Encoder S2A
    //
    interrupt void Encoder1_isr(void)
    {
        //Trigger by phase A, read phase B
        if(GpioDataRegs.GPCDAT.bit.GPIO94 == 0)
            counter_1++;
        else
            counter_1--;
    
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }
    
    //
    // Encoder2_isr - External Interrupt 2 ISR - Encoder S2B
    //
    interrupt void Encoder2_isr(void)
    {
        //Trigger by phase A, read phase B
        if(GpioDataRegs.GPCDAT.bit.GPIO67 == 0)
            counter_2++;
        else
            counter_2--;
    
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }
    
    //
    // Encoder1_isr - External Interrupt 3 ISR - Encoder SW1
    //
    interrupt void Encoder1sw_isr(void)
    {
        LED_mode++;
        if(LED_mode >= 3)
            LED_mode = 0;
    
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
    }
    
    
    //
    // delay_loop - Loop for a brief delay
    //
    void delay_loop()
    {
        long i;
        for (i = 0; i < 1000000; i++) {}
    }
    
    //
    // spi_xmit - Transmit value via SPI
    //
    void spi_xmit(Uint16 a)
    {
        SpibRegs.SPITXBUF = a;
    }
    
    //
    // spi_fifo_init - Initialize SPIA FIFO
    //
    void spi_fifo_init()
    {
        //
        // Initialize SPI FIFO registers
        //
        /*
        SpiaRegs.SPIFFTX.all = 0xE040;
        SpiaRegs.SPIFFRX.all = 0x2044;
        SpiaRegs.SPIFFCT.all = 0x0;
        */
    
        SpibRegs.SPIFFTX.all = 0xE040;
        SpibRegs.SPIFFRX.all = 0x2044;
        SpibRegs.SPIFFCT.all = 0x0;
    
        //
        // Initialize core SPI registers
        //
        //InitSpi();
        // Initialize SPI-B
    
        // Set reset low before configuration changes
        // Clock polarity (0 == rising, 1 == falling)
        // 16-bit character
        // Enable loop-back
        SpibRegs.SPICCR.bit.SPISWRESET = 0;
        SpibRegs.SPICCR.bit.CLKPOLARITY = 0;
        SpibRegs.SPICCR.bit.SPICHAR = (16-1);
        SpibRegs.SPICCR.bit.SPILBK = 1;
    
        // Enable master (0 == slave, 1 == master)
        // Enable transmission (Talk)
        // Clock phase (0 == normal, 1 == delayed)
        // SPI interrupts are disabled
        SpibRegs.SPICTL.bit.MASTER_SLAVE = 1;
        SpibRegs.SPICTL.bit.TALK = 1;
        SpibRegs.SPICTL.bit.CLK_PHASE = 0;
        SpibRegs.SPICTL.bit.SPIINTENA = 0;
    
        // Set the baud rate
        SpibRegs.SPIBRR.bit.SPI_BIT_RATE = SPI_BRR;
    
        // Set FREE bit
        // Halting on a breakpoint will not halt the SPI
        SpibRegs.SPIPRI.bit.FREE = 1;
    
        // Release the SPI from reset
        SpibRegs.SPICCR.bit.SPISWRESET = 1;
    }
    
    void SDFM_init()
    {
        //
        // GPIO Init
        //
        EALLOW;
        GpioCtrlRegs.GPDQSEL2.bit.GPIO122 = 3;   //GPIO ASYNC
        GpioCtrlRegs.GPDGMUX2.bit.GPIO122 = 1;
        GpioCtrlRegs.GPDMUX2.bit.GPIO122 = 3;
        EDIS;
    
        //
        // Configure Input Control Mode: Manchester decoded
        //
        EALLOW;
        Sdfm1Regs.SDCTLPARM1.bit.MOD = 2;               //2: The data from the modulator is Manchester decoded
        EDIS;
    
        //
        //Configure Data filter modules filter type, OSR value and filter.
        //
        EALLOW;
        Sdfm1Regs.SDDFPARM1.bit.FEN  = 1;               ////Enable  filter
        Sdfm1Regs.SDDFPARM1.bit.SST  = 3;               //Sinc3 filter
        Sdfm1Regs.SDDFPARM1.bit.DOSR  = 255;            //over sampling
        Sdfm1Regs.SDDFPARM1.bit.AE = 1;                 //Ack enable
        Sdfm1Regs.SDDPARM1.bit.DR = 0;                  //0->16-bits, 1->32-bits
        Sdfm1Regs.SDDPARM1.bit.SH = 9;                  //shift 9 bits
        Sdfm1Regs.SDMFILEN.bit.MFE = 1;                 //Master Filter bit is enabled
        EDIS;
    }
    //
    // End of file
    //
    

  • Hi

    It turns out that the issue was caused by a wrong CPU clock rate,

    After change the PLLSYSCLK to 200MHz, everything works perfectly.