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.

SM470R1B1M SPI

Other Parts Discussed in Thread: TMS470R1B1M, SM28VLT32-HT, SM470R1B1M-HT

#include <intrinsics.h>
#include <TexasInstruments/iotms470r1b1m.h>
#include <TexasInstruments/tms470r1B1m_bit_definitions.h>
int main(void)
{
PCR=CLKDIV_4;
GCR=ZPLL_CLK_DIV_PRE_1;
PCR|=PENABLE;
ECPCTRL|=ECPEN;
ECPCTRL|=ECPCOS;
//ECPCTRL|=0X01;
//GIODIRA_bit.GIODIR1=1;
// Enter SPI reset mode
// Disable SPI receive interrupts
SPI2CTRL2 |= SPIEN; // Activate the SPI
// Configure SPI port 2
SPI2CTRL1 = 0 | CHARLEN_8; // 8 bits/char
SPI2CTRL1 |= PRESCALE_8;
SPI2CTRL2 |= MASTER; // We are the master
SPI2CTRL2 |= CLKMOD; // We drive the clock
SPI2CTRL2 &= ~POLARITY; // CLK Polarity = 0
SPI2CTRL2 |= PHASE; // CLK Phase = 1
SPI2PC6 = 0 | CLK_FUN; // SCLK pin


}

The SPICLK donot have the signal.WHY

  • You can reference working SPI code for the HEATEVM.
    This is located here: http://www.ti.com/tool/HEATEVM
    It is in the Firmware.
    Regards,
    Wade
  • There are not codes in the wedsite. DO you have the code?do you have the code about the chip?if you have it,i will apperciate it.thank you very much.
  • Go to the HEATEVM tool folder located here: http://www.ti.com/tool/HEATEVM
    Scroll down to the "Software" section. You will see a link to "HEATEVM firmware". Download the firmware. The firmware will have the SPI code Wade is referring to.
    Thanks,JV
  • I find it.thanks very much.
    Thanks.WXZ
  • I have a question. when the date donot trasmited, if the SCLK pin can have the clock output frequencies . I find that when the register have been writed ,but the SCLK donot have any response. I donot konw why.Could you help me find the problem?
    /****************************************************************/
    /* Sample code for SM28VLT32-HT flash API
    Platform: IAR Workbench, MSWindows
    Target : SM470R1B1M-HT

    Developed by : Varalakshmi B
    Developed on : 13th Dec 2012
    Release Ver : 1.0 */
    /****************************************************************/

    #include <intrinsics.h>
    #include <TexasInstruments/iotms470r1b1m.h>
    #include <TexasInstruments/tms470r1B1m_bit_definitions.h>

    #include "SM28VLT32.h"

    // Function to test a sector in flash
    int Flash_TestSector(int iSectorToTest);

    void SetupSPI(void); // SPI1 setup for A/DC
    void SetupECP(void); // Set ECLK for A/DC oscillator drive setup
    /**************************************************************/
    /********************** Main Function *************************/
    /**************************************************************/
    void main(void)
    {
    PCR=CLKDIV_2;
    GCR=ZPLL_CLK_DIV_PRE_1;
    PCR|=PENABLE;
    SetupSPI();
    SetupECP();
    }
    void SetupECP(void)
    {
    // spnu202b.pdf ECP Ref for TMS470R1
    // ECPCTRL &= ~ECPEN; // undo enable

    // with ICLK at 20MHz, diviser for ECLK - ECLK is given to ADC CLK
    // ECPCTRL = ECPCOS | 0x03; // ECPCOS is ON, divide by 4 (default 2.5MHz)
    ECPCTRL = ECPCOS | 0x07; // ECPCOS is ON, divide by 8 (default 1.25MHz)
    // ECPCTRL = ECPCOS | 0x0F; // ECPCOS is ON, divide by 16 (625Khz)
    // ECPCTRL = ECPCOS | 0x1F; // ECPCOS is ON, divide by 32
    // ECPCTRL = ECPCOS | 0x3F; // ECPCOS is ON, divide by 64
    // ECPCTRL |= ECPCOS | 0x7F; // ECPCOS is ON, divide by 128

    ECPCTRL |= ECPEN; // enable
    }
    void SetupSPI(void)
    {
    SPI1CTRL1 = 0 | CHARLEN_8; // 8 bits per xfer

    // SYSCLK = 60MHz, ICLK = 10MHz

    // SPI1CTRL1 |= PRESCALE_4; // SPICLK = 2.5MHz
    SPI1CTRL1 |= PRESCALE_8; // SPICLK = 1.25MHz
    // SPI1CTRL1 |= PRESCALE_16; // SPICLK = 0.625MHz
    // SPI1CTRL1 |= PRESCALE_32; // SPICLK = 3125KHz


    // *** swapping SPI:CS and SPI:EN
    // Setup CS for A/DC "SYNCN" sync
    SPI1PC1 |= ENA_DIR;
    // default EN is set already for input
    SPI1PC1 &= ~SCS_DIR;


    SPI1CTRL2 |= MASTER; // We are the master
    SPI1CTRL2 |= CLKMOD; // We drive the clock

    // SPI1CTRL2 |= POLARITY; // CLK Polarity = 1
    SPI1CTRL2 |= PHASE; // PHASE = 1

    SPI1PC6 |= CLK_FUN;
    SPI1PC6 |= SIMO_FUN;
    SPI1PC6 |= SOMI_FUN;

    // Sync'ing input from SPIENA 4-pin mode.
    // SPI1CTRL3 |= ENABLE_HIGHZ;

    // enable
    SPI1CTRL2 |= SPIEN;


    }



    Thanks,JV