How to use ADuC812 SPI

Hello!
I tried to use the on-board SPI of the Analog Devices ADuC812
but I didn't managed it to work. No Data, no SCLK, the Pins
seemed all to be dead at all.
Maybe one of you can give me a hint or working sample code.

Thanks.

Here's some of my code:

// Initialize the SPI Interface

SPICON = 0x37;// configure SPI port for: 0011,0111 = 0x37
// Fosc/64, CPHA=1, CPOL=0, master
IE2 = 0x01; // enable SPI interrupt

EA = 1; // enable interrupts

...

void send_SPI(unsigned int byte)
{
SPIDAT = byte; // trigger data transfer
}


Parents
  • Hello André,

    I'm using the ADuC834, but I expect, that the configuration and usage of the SPI is the same as for the ADuC812.

    Your initialisation seems to be o.k. - just take care, that the clock, polarity and phase settings match the requirements of your slave device. For the following SPI routine, you will not need to enable the interrupt. The routine can be used for sending and reading bytes. To read a byte just send a dummy character.

    UI8 SPI_char( const UI8 c )
    {
        ISPI = 0;
        SPIDAT = c;
        while( !ISPI )
        {
            ; // do nothing but wait
        }
        return( SPIDAT );
    }
    

    Hope this helps,
    Tim

Reply
  • Hello André,

    I'm using the ADuC834, but I expect, that the configuration and usage of the SPI is the same as for the ADuC812.

    Your initialisation seems to be o.k. - just take care, that the clock, polarity and phase settings match the requirements of your slave device. For the following SPI routine, you will not need to enable the interrupt. The routine can be used for sending and reading bytes. To read a byte just send a dummy character.

    UI8 SPI_char( const UI8 c )
    {
        ISPI = 0;
        SPIDAT = c;
        while( !ISPI )
        {
            ; // do nothing but wait
        }
        return( SPIDAT );
    }
    

    Hope this helps,
    Tim

Children
More questions in this forum