Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Labjack u6 SPI communication with AD9833

SPI U6 AD9833

  • Please log in to reply
3 replies to this topic

#1 Max_1536

Max_1536
  • Members
  • 1 posts

Posted 30 October 2013 - 11:16 AM

Hi,

 

I am trying to use the chip AD9833 with the labjack u6 and i got some issues.

 

When i try to chose the mode of the SPI communication I tried with value of x=0,1,2 or 3 :m_pAddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSPI_MODE,x,0,0);

and when i was looking the signals, the MOSI always send is data on a rising edge of the CS... why? i read when CPHA = 0 it should be on falling edge of the CS

 

Here is my code:

//Comunication SPI
//First, configure the SPI communication.
//Enable automatic chip-select control.

m_pAddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSPI_AUTO_CS,1,0,0);
//Do not disable automatic digital i/o direction configuration.

m_pAddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSPI_DISABLE_DIR_CONFIG,0,0,0);
//Mode A: CPHA=1, CPOL=1.

m_pAddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSPI_MODE,3,0,0);
//Maximum clock rate (~100kHz).

  m_pAddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSPI_CLOCK_FACTOR,0,0,0);
//Set MOSI to FIO2.

m_pAddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSPI_MOSI_PIN_NUM,2,0,0);
//Set CLK to FIO0.

m_pAddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSPI_CLK_PIN_NUM,0,0,0);
//Set CS to FIO1.

m_pAddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSPI_CS_PIN_NUM,1,0,0);

//Use the 48 MHz timer clock base.

m_pAddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_BASE, LJ_tc48MHZ, 0, 0);

//Enable 1 timer. It will use FIO3.

m_pAddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chNUMBER_TIMERS_ENABLED, 2, 0, 0);
//Configure Timer1 as frequency output(Master clock).

 m_pAddRequest (lngHandle, LJ_ioPUT_TIMER_MODE, 0, LJ_tmFREQOUT, 0, 0);
//Initialize frequency output(Master clock) at 48M/(2*12) = 2 MHz.

m_pAddRequest (lngHandle, LJ_ioPUT_TIMER_VALUE, 0, 12, 0, 0);

//Execute the configuration requests.

m_pGoOne(lngHandle);   

//Transfer the data.

double numBytesToTransfer = 5; //unsigned long dataArray[4] = {0};

unsigned long dataArray[5] = {0};

long pdataArray = (long)&dataArray[0];
dataArray[0] = 0b0010000101101000; // set reactangular output

dataArray[1] = 0b0101100010010011;

dataArray[2] = 0b0100000000010000;

dataArray[3] = 0b1100000000000000;

dataArray[4] = 0b0000000001101000;

m_peGet(lngHandle, LJ_ioSPI_COMMUNICATION, 0, &numBytesToTransfer, pdataArray);

 

Thanks for your help!
 



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 30 October 2013 - 01:19 PM

You have 4 requests to configure a timer.  Are these for something else?  I would get rid of these.

 

You say the timer will use FIO3, but I don't see a request setting pinoffset=3.  By default pinoffset is likely 0, so this freqout timer might be appearing on FIO0, which is where the SPI clock is supposed to be.

 

Each element of the array should be 1 byte.  Looks like you are putting in 16 bits of information in each element, but only the lower 8 bits will be used.

 

Check out the U6_SPI example in the VC6 archive:

 

http://labjack.com/s...ud/examples/vc6



#3 bhavya

bhavya
  • Members
  • 1 posts

Posted 08 February 2014 - 05:56 AM

hi,

 any Examples for SPI communication for LabJack U6 in Labview. 



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 10 February 2014 - 11:09 AM

Look under \LabVIEW_LJUD\Examples\SPI.  Also, for general documentation see Section 4.3.10 of the U6 User's Guide.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users