LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NI USB-8452 SPI clock rate

Hello everyone,

I have a NI USB-8452 SPI device, and the hardware and software manual states that the supported clock rates for SPI for this device are:

48 kHz, 50 kHz, 60 kHz, 75 kHz, 80 kHz, 96 kHz, 100 kHz, 120 kHz, 125 kHz, 150 kHz, 160 kHz, 200 kHz, 240 kHz, 250 kHz, 300 kHz, 375 kHz, 400 kHz, 480 kHz, 500 kHz, 600 kHz, 750 kHz, 800 kHz, 1 MHz, 1.2 MHz, 1.5 MHz, 2 MHz, 2.4 MHz, 3 MHz, 4 MHz, 6 MHz, 12 MHz

However if I use ni845xSpiConfigurationSetClockRate to set the clock rate to 1 (meaning 1 KHz) there is no error. If I retrieve the current clock rate with ni845xSpiConfigurationGetClockRate it confirms that the current clock rate is 1 KHz.

Even weirder is that if I set the clock rate to 48 (which the manual says that the board supports), I get an error:

"The passed-in clock rate was lowered to a clock rate value that the hardware supports. Refer to your hardware documentation for supported clock rates."

If I set to 15KHz it gives me the same error. For clock rates of 2, 3, 5, 10, 20, 100 or 1000 KHz it does not complain.

Am I missing something? It seems that the driver behavior does not match what is specified in the manual.

Best regards,
André

0 Kudos
Message 1 of 3
(3,263 Views)

Hello AndreMarques,

 

Thank you for posting on the NI Forum.

Looking at the datasheet of your product, this is the expected behaviour.

 

When you look at this documentation: http://www.ni.com/pdf/manuals/371746e.pdf

1- You have, at page 496, the list of Frequencies allowed by the clock of the SPI protocol:

"25 kHz, 32 kHz, 40 kHz, 50 kHz, 80 kHz, 100 kHz, 125 kHz, 160 kHz, 200 kHz, 250 kHz, 400 kHz, 500 kHz, 625 kHz, 800 kHz, 1 MHz, 1.25 MHz, 2.5 MHz, 3.125 MHz, 4 MHz, 5 MHz, 6.25 MHz, 10 MHz, 12.5 MHz, 20 MHz, 25 MHz, 33.33 MHz, 50 MHz"

 

2- At page 277, it is said that if you don't select a proper clock value, this will send a warning for at least warned the programmer of the change that has been made for him. You can ignore that warning if you want or get the real value by using the GetClockRate VI :

"Specifies the SPI clock rate. Refer to Chapter 3, NI USB-845x Hardware Overview , to determine which clock rates your NI 845x device supports. If your hardware does not support the supplied clock rate, a warning is generated, and the next smallest supported clock rate is used. If the supplied clock rate is smaller than the smallest supported clock rate, an error is generated. The configuration does not validate the clock rate until it is committed to hardware. The default value for this property is 1000 kHz (1 MHz)."
 
However, it does not explain the behavious for your clock rate of: 2, 3, 5, 10, 20. You should get an error in this case. Would you be able to check and eventually, send us your code for us to have a look at it. We will also need a max report for us to know the software you are using.
 
Thank you  in advance for your answer.
 
Bye.
 

 

 

0 Kudos
Message 2 of 3
(3,212 Views)

Hello Pierre,

 

sorry for the late reply.

 

This is my MAX report:

 

Operating System(OS)                     Windows 7 Professional
OS Version                               6.01.7601
OS Info                                  Service Pack 1
Processor                                Intel(R) Core(TM) i5-2300 CPU @ 2.80GHz / Intel64 Family 6 Model 42 Stepping 7 / GenuineIntel / 2793 MHz
Number of Processors                     4
Physical Memory                          7.91 GB of RAM
Drive C:\                                9.17 GB of 111 GB free
                                         
National Instruments Software:           Version:
                                         
NI-DAQmx Device Driver                   16.0.0f0
NI-DAQmx ADE Support                     16.0.0
NI-DAQmx MAX Configuration               16.0.0
NI I/O Trace                             16.0.0f0
LabVIEW Runtime 2014 SP1 f5              14.0.1
Measurement & Automation Explorer        16.0.0f0
Measurement Studio                       Visual Studio 2010 Support - See individual versions below.
     DotNET                               
          Common                         15.1.40.49152
          Common (64-bit)                15.1.40.49152
NI-845x                                  15.0.0f0
NI-845x Runtime                          15.0.0f0
NI PXI Platform Services Configuration   16.0.0f0
NI PXI Platform Services Runtime         16.0.0f0
NI-PAL Software                          16.0.0
NI System Configuration                  16.0.0f0
NI-VISA                                  15.0
NI-VISA Runtime                          15.0
LabVIEW Runtime 2015 SP1 f3              15.0.1

 

How can I send you my sample code? I have two tests: in one I try to send data in a loopback configuration, and set the clock rate to 15 KHz and it fails (as expected). If I set the clock rate in this test to 1,2, 5, 10 and 20 for instance it does not complain. It complains with 3,15 and 48 KHz as expected. Worthy of note is that in this loopback (MISO and MOSI connected) test I send three bytes (255 255 255) and I receive:

 

1 KHz -> 63 255 255

2 KHz -> 15 255 255

10 KHz -> 0 0 255

20 KHz -> 0 0 0

 

In another test I set each of the 8 slaves with a different clock rates (1,2,3,5,10,15,48,50) and then close. In this test the driver never raises any issue (while none of these rates are valid for this hardware).

 

Please tell me how I can send you this code.

 

Thanks,

André

 

0 Kudos
Message 3 of 3
(3,153 Views)