Albert Hu

SPI for MAX5250

Discussion created by Albert Hu on Apr 25, 2007
Latest reply on May 3, 2007 by Albert Hu
Hello, All
         I am using DP256 SPI to communicate with MAX5250(DAC) to output analog voltage. The following is my code:

PTS &= ~PTS3_msk; //clear pin3 of port S to select SPI for the first MAX5250

// ????
SPI_Data_HIGH_Tmp = (unsigned char)(0x30 + ((Current1_uc &0xF0) >>4));
SPI_Data_LOW_Tmp
= (unsigned char)((Current1_uc &0x3F) <<4);

SPI0DR
= SPI_Data_HIGH_Tmp; // send the High byte data of SPI Data
while(!(SPI0SR &SPTEF0_msk)); //wait till data transfer finish
while(!(SPI0SR &SPIF0_msk ));
SPI_Data_HIGH_Tmp
= SPI0DR;

SPI0DR
= SPI_Data_LOW_Tmp; // send the Low byte data of SPI Data
while(!(SPI0SR &SPTEF0_msk )); //wait till data transfer finish
while(!(SPI0SR &SPIF0_msk ));
SPI_Data_LOW_Tmp
= SPI0DR;

PTS |= PTS3_msk;  //disable the Max5250

Using the osilliscope, I can check the SCLK and MOSI wave is correct. And the Data in MOSI is exactly what I sent.But I can get the analog voltage output, Does anybody know the reason? Thanks in advance!

 

Albert

 

Outcomes