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.

C6745 SPI communication register doubt

Other Parts Discussed in Thread: TMS320C6745, STARTERWARE-DSPARM

hi,

   am using tms320c6745 kit , now planning to interface the SPI BASED TFT. I have sample driver code ., the only thing is i want to know how to transmit 8 bit data through SIMO pin. if possible please write the spi code data transfer.please refer the following code to solve my problem


void GLCD_Write_Command(unsigned char GLCD_Command)
{
TFT_CS_LOW();                                                            // Enable GLCD Interface

  GLCD_SPI_Read_Write(0x70);                                // Sent Byte 1 = [Device ID Code:01110[0]]+[RS:0] + [R/W:0]
  GLCD_SPI_Read_Write(0x00);                                // Sent Byte 2 = data 8 bit High Index Reg.: 0x00
  GLCD_SPI_Read_Write(GLCD_Command);       // Sent Byte 3 = data 8 bit Low index reg. : cmm
    
TFT_CS_HIGH();                                                           // Disable GLCD Interface
}
 

void GLCD_Write_Data(unsigned int GLCD_Data)
{    
TFT_CS_LOW();                                                             // Enable GLCD Interface
 
  GLCD_SPI_Read_Write(0x72);                                // Byte 1 = [Device ID Code:01110[0]]+[RS:1] + [R/W:0]
  GLCD_SPI_Read_Write(GLCD_Data >> 8);         // Byte 2 = Data 8 bit High
  GLCD_SPI_Read_Write(GLCD_Data);                  // Byte 3 = Data 8 bit Low
 
TFT_CS_HIGH();                                                           // Disable GLCD Interface
}

/********************************/
/* Initial GLCD :                 */
/*      (Driver SPFD5408A)      */
/********************************/
void Initial_GLCD_Hor(void)
{
  unsigned long cnt;

  GLCD_Write_Command(0x00);                        // Command Start Oscillater
  GLCD_Write_Data(0x0001);                        // Enable the oscillator.   
  delay_ms(10);                                    // Delay for 10ms while the oscillator stabilizes.
   
  // Display Setting
  GLCD_Write_Command(0x01);                        // Configure the output drivers.
  GLCD_Write_Data(0x0100);
 .......................

................

.............

    TFT_BL_ON();                                     //Back Light ON      
       delay_ms(20);                                 //Delay for 20ms, which is equivalent to two frames.
}

To transmit the above command we have to write the spi read write function? can anyone help me in this ? the following is SPI read / write function.

/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
unsigned char GLCD_SPI_Read_Write(unsigned char DataByte)    
{
    .............................

   .........................

........................................ i need the some body has to fill this function to successfully transfer the command to GLCD of TFT.

}

Many Thanks,

S..Thiyagarajan.



  • hi,

        please c6000 or SPI knowledge engineers reply me the above, by studying the spi data manual, i wrote  one function for GLCD_SPI_READ_WRITE.

    whether tell this is correct or not, or please convey any mistakes i made, expecting the replies soon.

    /****************************/
    /* GLCD SPI Sent Data 8 bit */
    /****************************/
    unsigned char GLCD_SPI_Read_Write(unsigned char DataByte)    
    {
        SPI_SPIDAT1 = DataByte;
        while(!(SPI_SPIFLG && (1 << 9)));
        return 0;      
    }


    is this function i wrote is correct ? whether this function will communicate to spi glcd, ?

  • hi,

     please reply soon ,, whether this project code is ok , to transfer  8 bit data to TFT.

    /****************************/
    /* GLCD SPI Sent Data 8 bit */
    /****************************/
    unsigned char GLCD_SPI_Read_Write(unsigned char DataByte)    
    {
        unsigned char dummy;
        /* Clear any old data */
        SPI_SPIBUF;
        
        // Wait for transmit ready
        while( SPI_SPIBUF & 0x20000000 );    // checking tx buf is empty
        while( SPI_SPIBUF & 0x10000000 );    // checking bit error
            SPI_SPIDAT1 = DataByte;
            
        // Wait for receive data ready
        while ( SPI_SPIBUF & ( 0x80000000 ) );

       /* Read 1 byte */
       dummy = SPI_SPIBUF;
       
       return dummy;
      
    }


    if any mistake please correct it, and i want to know how to check whether it is transmitted correctly to slave ?.

    Many Thanks,

    Thiyagarajan.S

  • You usually have to setup the pinmux, clock, phase and polarity. There are many SPI driver implementations. Not many people code this from scratch. StarterWare is suppose to be OS-less or "Bare-Metal". Might be the best reference for you.

    TI's Linux
    http://arago-project.org/git/projects/?p=linux-davinci.git;a=blob;f=drivers/spi/spi-davinci.c;h=ba79b5261b415a7078a9197801195e0fa553cd16;hb=HEAD

    TI's U-Boot
    http://arago-project.org/git/projects/?p=u-boot-davinci.git;a=blob;f=drivers/spi/davinci_spi.c;h=13aca52c7e2add329fb2c4334f9d3bb4d1752684;hb=HEAD
    http://arago-project.org/git/projects/?p=u-boot-davinci.git;a=blob;f=drivers/spi/davinci_spi.h;h=8d36a42a44c848e669c783ea762e18183ebf68cd;hb=HEAD

    TI'S BIOS/PSP
    http://software-dl.ti.com/dsps/dsps_public_sw/psp/BIOSPSP/01_30_00_06/index_FDS.html

    TI's StarterWare
    http://www.ti.com/tool/starterware-dsparm

  • hi norman wong,

         s i done pinmux, clock  for 12.5 Mhz, phase  -1 and polarity -1. the following are i initialized, please check and tell sir whether it is correct?

    void spi_0_tft_init( )
    {
        /* Reset SPI */
        SPI_SPIGCR0 = 0;
        C6745_wait( 1000 );

        /* Release SPI */
        SPI_SPIGCR0 = 1;

        /* SPI 4-Pin Mode setup */
        SPI_SPIGCR1 = 0
            | ( 0 << 24 )
            | ( 0 << 16 )
            | ( 1 << 1 )
            | ( 1 << 0 );

        SPI_SPIPC0 = 0
            | ( 1 << 11 )   // DI - SPIx_SOMI
            | ( 1 << 10 )   // DO - SPIx_SIMO
            | ( 1 << 9 )    // CLK - SPIx_CLK
            | ( 1 << 1 )    // EN1 -
            | ( 1 << 0 );   // CS - SPIx_SCS ACTIVE LOW SIGNAL
       
       
       
        SPI_SPIFMT0 = 0
            | ( 8 << 24 )   // WDELAY
            | ( 0 << 20 )   // SHIFTDIR
            | ( 1 << 17 )   // Polarity //Selva
            | ( 1 << 16 )   // Phase
            | ( 11 << 8 )    // Prescale to 12.5MHz
            | ( 8 << 0 );   // Char Len 8 BIT

        spidat1 = 0
            | ( 1 << 28 )   // CSHOLD
            | ( 0 << 24 )   // Format [0]
            | ( 2<< 16 )   // CSNR   [only CS0 enbled]
            | ( 0 << 0 );   //

        SPI_SPIDAT1 = spidat1;

        SPI_SPIDELAY = 0
            | ( 8 << 24 )   // C2TDELAY
            | ( 8 << 16 );  // T2CDELAY

        SPI_SPIDEF = 0
            | ( 1 << 1 )    // EN1 inactive high
            | ( 1 << 0 );   // EN0 inactive high
       SPI_SPIINT = 0
            | ( 0 << 16 )   //
            | ( 0 << 9 )   // TXINTENA interrupt generate when data is written to shift register
            | ( 0 << 8 )    //
            | ( 0 << 6 )    //
            | ( 0 << 4 );   //

        SPI_SPILVL = 0
            | ( 0 << 8 )    // EN0
            | ( 0 << 6 )    // EN0
           | ( 0 << 4 );   // EN0

        /* Enable SPI */
        SPI_SPIGCR1 |= ( 1 << 24 );
    }

  • It has been a while since I have had to program this SPI controller. I can't remember the speciifcs of each register. Looks okay. Best thing to do is to run the code and check the signals with an oscilloscope. Much will be will be dependent on what the LCD device expects.

    If you have problems, post a detailed description of the symptoms. People are more likely to help you fix a specific symptom. People are less likely to do a complete code review for you.

  • hi Norman Wong,

       as per ur adviced i watched the signals whenever a chip select is low the simo pin transmitting something, but at a time i cant able to watch three signal, . in my oscilloscope only two channel provision is available .i dont know about the clock signal.

    ok sir, is any possible to check the code by single stepping method, by seeing register update. ?

    Many Thanks

    Thiyagarajan.S

  • I'm not sure about single stepping through code. The SPI controller will probably continue to shift data while the processor is stopped.

    The key is getting the pinmux settings correct. Your sample code has SPI_SPIPC0 set to 5 pin mode. Suggest not using ENA for now. Scope out SCLK, SIMO and SCS. Send data with alternating bits like 0xAAAAAAAA or 0x55555555. If the scope shows the expected activity, the pinmux is verified. For the SOMI pin, tie it high or low and check the SPIBUF register. Again verifies the pinmux settings.

    Next check heck frequency and timing. Look at the SCLK on scope to see if that's the frequency you are expecting. The timing between edges probably needs more than 2 channels. Probably safe to leave them at default which I believe is the slowest relaxed times. You can tune it faster later. I'd expect LCDs to be fairly slow.

    I think checking polarity and phase requires at least 3 channels. You might be able to compare SCN to SCLK or SIMO for polarity. Compare SCK to SIMO for phase. Or vice verse. Forgotten which is which. Or just permute polarity and phase until the LCD understands.