Post Go back to editing

About ADIS16355 SPI-OUT

Hello,

I've bought ADIS-16355 and choose AT89C51ED2 to read this chip.

I would like to connect ADSP21369 with ADIS16350 by SPI.

Please help me, show me how it works.

My code like follow

/************************************************************/

void main(void)

{

    uart_init();

    spi_init();

    timer2_start(DELAY_50MS);

    while(1)

    {

      SPDAT=data_example;        /* send an example data */

      while(!transmit_completed);/* wait end of transmition */

          transmit_completed = 0;    /* clear software transfert flag */

 

      SPDAT=0x00;                /* data is send to generate SCK signal */

      while(!transmit_completed);/* wait end of transmition */

          transmit_completed = 0;    /* clear software transfert flag */

      data_save = serial_data;  /* save receive data */

    }

    void spi_init(void)

   {

     SPCON |= 0x10;                /* Master mode */

     P1_1=1;                       /* enable master */

     SPCON |= 0x82;                /* Fclk Periph/128 */

     SPCON &= ~0x08;               /* CPOL=0; transmit mode example */

     SPCON |= 0x04;                /* CPHA=1; transmit mode example */

     IEN1 |= 0x04;                 /* enable spi interrupt */

     SPCON |= 0x40;                /* run spi */

     EA=1;                         /* enable interrupts */

   }

   void it_SPI(void) interrupt 9 /* interrupt address is 0x004B */

   {

     switch ( SPSTA )         /* read and clear spi status register */

     {

        case 0x80:

          serial_data=SPDAT;   /* read receive data */

          transmit_completed=1;/* set software flag */

          break;

        defaule:

          break;

      }

   }

}

/*****************************************************************************/

Plz give me some example code to access ADIS-16355.

Thanks

Anson

  • Hello,

       the configuration of spi interface is CPOL = 1 and CPHA = 1 and I would also check if Slave Select pin is Driven high before enabling spi interface and if frequency of spi serial clock meets specification in datasheet. Here is my code of sending and receiving function:

    uint16_t spi_transmit_receive(uint16_t x)
    {
        uint16_t pom = 0, pom1 = 0;


        SPI_PORT &= ~(_BV(SS)); // SS to low
       
        // LSB to transfer
        SPDR = x;
        while(!(SPSR & (1<<SPIF)))
        {
        }

        // getting received data
        pom1 = SPDR;
       
        // MSB to transfer
        SPDR = x >> 8;
        while(!(SPSR & (1<<SPIF)))
        {
        }
       
       
        SPI_PORT |= _BV(SS); // SS to high
       
        // getting received data
        pom = SPDR | (pom1 << 8);

        return pom;
    }

    Regards.

    Ladislav

  • this problem was be solved, thanks for your reply