AnsweredAssumed Answered

SPI Configuration for AD9833

Question asked by LEDD on Jun 5, 2015
Latest reply on Jun 8, 2015 by musach

Hi,

I use C8051 MCU to control the AD9833 and some other SPI devices.

Except for the AD9833 I have to configure the SCLK with the clock pole idle at HIGH level state (CKPOL=1, CKPHA=0) and all other devices using CKPOL=0, CKPHA=0   

 

I make 2 different SPI configurations so if I want to communicate with the AD9833, I initialize SPI_Config1 before starting the communication. On the other hand,  I initialize SPI_Config2 before communicate with other devices.

 

The method works most of the time. However, sometimes I can only communicate with other SPI devices but the AD9833.

In order to communicate with the AD9833 again, I have to reset the MCU.

I observed and saw that, whenever I initialize the COM port from my computer, I would lost control to the AD9833. Sometimes, I lost control to the AD9833 without initialize the COM port and I don't know what did happen.

 

I checked the clock and data bus I saw no change on the waveform when the AD9833 working or not working.

 

Below is the code I use

FREQ_LSBs and FREQ_MSBs are declared as unsigned int and its value received from the UART buffer of the MCU

 

unsigned int CRTL_REG = 0x2028;                 // AD9833 Control register:

 

        AD9833_TranferEnd = 0;                         // Reset indicator

        DIGITAL_Output(CRTL_REG);                // Calling DIGITAL_Output to write CRTL_REG to the AD9833

        while (AD9833_TranferEnd == 0);            // Wait for the writting register complete

        AD9833_TranferEnd = 0;                          // Reset indicator   

        DIGITAL_Output(FREQ_LSBs);                // Calling DIGITAL_Output to write FREQ_LSBs to the AD9833

        while (AD9833_TranferEnd == 0);             // Wait for the writting register complete

        AD9833_TranferEnd = 0;                           // Reset indicator

        DIGITAL_Output(FREQ_MSBs);               // Calling DIGITAL_Output to write FREQ_MSBs to the AD9833

        DIG_S = 1;                                                 // Disable the AD9833 slave select

 

void DIGITAL_Output (unsigned long REG_VAL)

    SPI0DAT = (REG_value>>8) & 0x00FF;       // Send the MSB to AD9833 data register
    while (SPIF==0);                                            // Allow until the transmision complete
    SPIF = 0;                                                        // Clear the flag

    SPI0DAT = REG_value & 0x00FF;                // Send the LSB to AD9833 data register
    while (SPIF==0);                                            // Allow until the transmision complete
    SPIF = 0;                                                        // Clear the flag
    AD9833_TranferEnd = 1;                               // Indicate data word transfer complete

 

Please share your thought if you know or have experienced with this issue.

 

Thanks,

Outcomes