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.

spi code help

I have written SPI Code for DM6446 processor, plz guide me where i am wrong ...., i am checking spi clock and it low.....

can any body plz send me spi code as a help...

 

void main( void )
{
    /* Initialize BSL */
        /* Reset SPI */
    SPI_SPIGCR0 = 0;
    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
        | ( 1 << 10 )   // DO
        | ( 1 << 9 )    // CLK
        | ( 1 << 1 )    // EN1
        | ( 1 << 0 );   // EN0

    SPI_SPIFMT0 = 0
        | ( 0 << 20 )   // SHIFTDIR
        | ( 0 << 17 )   // Polarity
        | ( 1 << 16 )   // Phase
        | ( 4 << 8 )    // Prescale
        | ( 8 << 0 );   // Char Len

    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 << 8 )    //
        | ( 0 << 6 )    //
        | ( 1 << 4 );   //

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


    /* Enable SPI */
    SPI_SPIGCR1 |= ( 1 << 24 );
   
    while(1)
    {
      while ( SPI_SPIBUF & 0x10000000 );   // writing data to spi
      SPI_SPIDAT1 = spidat1 | 0x1122;
    }
   
}

   void wait (int i)
   {
      int j;
      for(i=0;j<=i;j++)
      ;
   }