• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » C2000™ Microcontrollers » C2000 32-bit Microcontrollers Forum » F28335 SPI problem with AD7699
Share
C2000™ Microcontrollers
  • Forums
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
C2000 Resources
  • Product Folder
  • C2000 Training Portal
  • C2000 Technical Training Catalog
  • C2000 Datasheets, App Notes, User Guides
  • C2000 Hardware Design Kits
  • controlSUITE for C2000 Software Library


  • InstaSPIN Resources
  • What is InstaSPIN?
  • Videos and Support


  • InstaSPIN-FOC and InstaSPIN-MOTION Resources
  • What is InstaSPIN-FOC?
  • What is InstaSPIN-MOTION?
  • Product Folder: F28069F, F28068F, F28062F, F28068M, F28069M
  • User’s Guide
  • Technical User’s Manual
  • Tools
  • Forums

    F28335 SPI problem with AD7699

    This question is not answered
    Hale Petersen
    Posted by Hale Petersen
    on Jul 17 2012 13:15 PM
    Prodigy100 points

    Hi,

    I'm currently having problems communicating via 4-wire SPI between the F28335 and the AD7699. I believe I have the SPI configured correctly on the F28335 by observing the inputs/outputs on a scope. My main two problems are: 1) while trying to configure the SPI clock above a lower freq (above ~5 MHz) it becomes an ugly triangle wave which could or could not be a problem and 2) It looks like I am sending the proper configuration to the ADC on the MOSI but while on the read back configuration setting, the MISO is not properly reading back the configuration or the correct voltage reading output (3.3 VDC). I have attached a scope print out and code below. I used an example program for the SPI setup. Any help is appreciated, thanks in advance.

    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

    void spi_init(void);

     Uint16 data1;
     Uint16 data2;

    void main(void)
    {
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the DSP2833x_SysCtrl.c file.
       InitSysCtrl();

    // Step 2. Initalize GPIO:
    // This example function is found in the DSP2833x_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
    // InitGpio();  // Skipped for this example
    // Setup only the GP I/O only for SPI-A functionality
       InitSpiaGpio();

    // Step 3. Initialize PIE vector table:
    // Disable and clear all CPU interrupts
       DINT;
       IER = 0x0000;
       IFR = 0x0000;

    // Initialize PIE control registers to their default state:
    // This function is found in the DSP2833x_PieCtrl.c file.
       InitPieCtrl();

    // 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 DSP2833x_DefaultIsr.c.
    // This function is found in DSP2833x_PieVect.c.
       InitPieVectTable();

    // Step 4. Initialize all the Device Peripherals:
    // This function is found in DSP2833x_InitPeripherals.c
    // InitPeripherals(); // Not required for this example
       spi_init();   // Initialize the SPI only


    // Step 5. User specific code, enablenfiguration();

       while(1)
       {  
     GpioDataRegs.GPBCLEAR.bit.GPIO57 = 1; /* set CS low */


     data1 = spiBSendByte(0x71E0);  /* keep configuration and read back data from IN0 (71E4) from IN1 (73E4) */
     DELAY_US(1);
     data1 = spiBSendByte(0);  /* read back configuration */


     GpioDataRegs.GPBSET.bit.GPIO57 = 1; /* set CS high */

     DELAY_US(6);
       }
    }

    int spiBSendByte(const unsigned int data)
    {
     SpiaRegs.SPITXBUF = data;    /* Load TX buffer with data */

     DELAY_US(6);  /* Delay to load TX buffer */

     data2 = SpiaRegs.SPIRXBUF;   /* Read data from RX buffer */
     
     return (1);

    }

    void spi_init()  */ SPI setup */
    {
       Uint16 dummy;

       SpiaRegs.SPICCR.bit.SPISWRESET=0; // Reset SPI

       SpiaRegs.SPICCR.all=0x000F;       //16-bit character
       SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1;   // Master mode enabled
       SpiaRegs.SPICTL.bit.TALK = 1; // Transmit capability enabled
       SpiaRegs.SPISTS.all=0x0000;
       SpiaRegs.SPIBRR = 0x0002;           // Baud rate ~ 10 MHz
       SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;  // Rise edge w/o delay
       SpiaRegs.SPICTL.bit.CLK_PHASE = 0;

       SpiaRegs.SPICCR.bit.SPISWRESET=1;  // Enable SPI

       GpioDataRegs.GPBCLEAR.bit.GPIO57 = 1; /* set CS low */
       dummy = spiBSendByte(0xF1E0);  /* Set ADC to factory settings by holding DIN high for two conversions */
       GpioDataRegs.GPBSET.bit.GPIO57 = 1; /* set CS high */
      
       DELAY_US(10);  /* Delay between dummys */

       GpioDataRegs.GPBCLEAR.bit.GPIO57 = 1; /* set CS low */
       dummy = spiBSendByte(0xF1E0);  /* second dummy (F1E4 for IN0) */
       GpioDataRegs.GPBSET.bit.GPIO57 = 1; /* set CS high */
    }

     

    Yellow = clock,   blue = MISO,   purple = CS (above)  or MOSI (below)

    Hale Petersen

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Daniel Chang
      Posted by Daniel Chang
      on Jul 17 2012 13:49 PM
      Expert4120 points

      Hi Hale,

      1) 5MHz should be no issue for an F28335.  The triangle waveforms you see may be due to a combination of your scope's maximum sampling frequency and the timescale it is set to during capture.  Try going to a smaller timescale and observe the waveform then.

      2) You can try setting the SPI to loopback mode to verify the commands you are sending out to the ADC.  If those commands are correct, perhaps your code is mis-interpreting the data it receives from the ADC.  If you can determine what the raw data the ADC is supposed to send back, you can compare that with the raw data the SPI saves.

      Regards,
      Daniel

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Hale Petersen
      Posted by Hale Petersen
      on Jul 17 2012 14:12 PM
      Prodigy100 points

      Daniel,

      Thanks for getting back to me so quickly. As for your first suggestion, I am using a 300MHz scope which should be able to sample quickly enough. For your suggestion on loopback mode, that is what i meant by "read back" in my first post. So, I am sending 0x71E0 and should be receiving that back as well as 3.3 VDC or 0xCE40. As you can see in my scope print outs, the word I'm sending to the ADC is correct, but I am getting back junk.

      My ADC configuration is set up for:

      keep current config, unipolar and inputs referenced to GND, input channel IN0, full BW, external reference and internal buffer, disabled sequencer and to read back current config

      Hale Petersen

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Daniel Chang
      Posted by Daniel Chang
      on Jul 17 2012 19:04 PM
      Expert4120 points

      If you have confirmed the data being sent over SPI using loopback mode, then let's assume the command is being sent to the ADC correctly.  BTW, you are probably doing this, but make sure you disable loopback mode when actually trying to talk to the ADC.

      Assuming the data sent to the ADC is correct, the problem is then in the ADC interpreting the command and responding.  Can you post some shots of the waveforms being sent to the ADC?  I am not familiar with the ADC, but I would first verify the timings and sequencing matches the ADC specs. 

      I took a quick look and it said it requires two dummy conversions to perform configuration.  That would be where I would start looking at.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • BrandonAzbell
      Posted by BrandonAzbell
      on Aug 17 2012 11:54 AM
      Guru54880 points

      Hale,

      Have you had progress in working through this issue?  If so, what resolution did you get to?

      Brandon

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Hale Petersen
      Posted by Hale Petersen
      on Aug 31 2012 09:17 AM
      Prodigy100 points

      Brandon,

      I apologize for not keeping up with the forum. I ended up changing the ADC module I was using in order to more easily communicate with it.

      Thanks,

      Hale

      Hale Petersen

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use