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.

Problem initializing AD9833 using SPI on MSP432



Hello! I'm using a MSP-EXP432P401R Rev. 2.0 Launchpad to program an AD9833 programmable waveform generator. The problem is that I cannot get it to generate anything.

My SPI configuration is the following (SPI mode 3 with 1 MHz clock):

eUSCI_SPI_MasterConfig config =
	{
		EUSCI_B_SPI_CLOCKSOURCE_SMCLK,
		6000000,
		1000000,
		EUSCI_B_SPI_MSB_FIRST,
		EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,
		EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH,
		EUSCI_B_SPI_3PIN
	};
	// ----Configure SPI Pins are UCB0 on P1.5, P1.6
	// Pin 1.5 = UCB0_SPI_CLK
	MAP_GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_P1, GPIO_PIN5, GPIO_PRIMARY_MODULE_FUNCTION);
	// Pin 1.6 = UCB0_SPI_SIMO
	MAP_GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_P1, GPIO_PIN6, GPIO_PRIMARY_MODULE_FUNCTION);
	MAP_SPI_initMaster(EUSCI_B0_BASE, &config);
	MAP_SPI_enableModule(EUSCI_B0_BASE);

I've used the driver provided on the Analog Devices website and I've closely followed the initialization procedure example described in the application note AN-1070.

This is my initialization:

MAP_GPIO_setAsOutputPin(ADI_CS_PORT, ADI_CS_PIN);
MAP_GPIO_setOutputHighOnPin(ADI_CS_PORT, ADI_CS_PIN);
AD9833_SetRegisterValue(AD9833_B28 | AD9833_REG_CMD | AD9833_RESET); // 0x2100
AD9833_SetFrequency(AD9833_REG_FREQ0, 0x10C7); // 400 Hz; 0x50C7, 0x4000
AD9833_SetPhase(AD9833_REG_PHASE0,0x00); // 0xC000
AD9833_SetRegisterValue(AD9833_B28); // 0x2000

I've checked the SPI waveforms and I can confirm that the data is transmitted as described in the application note. I have attached my schematic and screen captures. From the captures you can see that the data is transmitted correctly (I used delays of a few microseconds). In the schematic, at DDS_Vout I get a DC voltage, around 1,1 V.

Does anybody have an idea about what could be the problem?

  • Hello Cristian,

    Data can only be transferred when FSYNC is low, I assume this is controlled by CS_PIN/P4.0. Serial data is shifted into the input shift register of the device on the falling edges of SCLK. Your initialization however sets the SPI for EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH and EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT, which means that the data is changed on a high-to-low transition and captured on a low-to-high transition. Your SPI settings are therefore out-of-phase, you need to either change the clock polarity to inactive low or swap the phase select settings in order to communicate with the AD9833.

    Regards,
    Ryan
  • Thank you, Ryan! That was the problem. I guess I was too annoyed by it to notice the incorrect configuration.

**Attention** This is a public forum