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.

[参考译文] TMS320F2.8379万D:SDFM输出没有数据更新

Guru**** 663810 points
Other Parts Discussed in Thread: AMC1303E2520
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1098173/tms320f28379d-no-data-update-from-sdfm-output

部件号:TMS320F2.8379万D
主题中讨论的其他部件:AMC1303E2520</s>2520

大家好,我正在使用AMC1303E2520测量2520测量电流,它具有 曼彻斯特编码的 Δ-Σ 调制器,我使用 以下代码初始化SDFM模块:

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;
}

没有信号时 ,Sdfm1Regs.SDDATA1不读取任何内容。

接下来,Deita-Sigma信号开始传输,Sdfm1Regs.SDDATA1寄存器锁定到1000万00000000 (0万 (二进制)并停止更新, 这不是正确的行为。

正确的读数应如下所示(它应自动更新并读取几乎为零):

 

 如果问题能够得到解决,那将是极好的。

此致,

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    首先,我建议您查看器件勘误表中有关曼彻斯特模式的顾问文档。 其次,您是否尝试改变AMC设备输入端的压差,以查看是否对SDFM寄存器有影响? 您的pinmux和SDFM配置看起来正常。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你(们)好

    我确定这不是硬件问题,因为我以前在同一硬件上执行过相同的功能。 硬件方面没有变化。

    完整代码如下:

     

    //###########################################################################
    //
    // 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
    //
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你(们)好

    问题是 由错误的CPU时钟频率引起的,

    将PLLSYSCLK更改为200MHz后,一切都能正常工作。