06-01-2010 09:20 AM
Hello all!
A couple of days ago I asked a question about which card I could use to communicate Labview Via SPI Interface (4-Wire). I was recommended the NI USB 8451 and my supervisor got it for me (I'm only doing my internship). It's finally arrived.
Now I have a lot of questions 😞 So please help me. I've been reading a lot and seeing the examples, and I've managed to understand it, but so far no luck in controlling my device, because I do get readings but they mean nothing related to the datasheet, so I think I'm doing something wrong.
Right now I'm trying to read the registers of Chip CC1100 from Chipcon (Texas Instruments).
I will attach the VI that I have done so far which is in LV2009 (quite simple, I must say... but I'm still learning) and just in case you don't have the version I'll post snippet of both front panel and block diagram.
Additionally these are the main points for reading a register in the chip:
*The chips have 47 configuration registers (address 0 to address 0x2E). The R/W bit in the address header controls if the register should be written or read, and the burst bit controls if it is a single access or a burst access.
The address header byte is as follows:
- - - - - - - - - - - - - - - - - - - - - - - - - - -
_
[R/W] [B] [A5] [A4] [A3] [A2] [A1] [A0] <---- Address header
- - - - - - - - - - - - - - - - - - - - - - - - - - -
_
Which is why I'm sending a 0x80 to read register 0x00 (W as 0 bit and B= burst access bit, must be also 0 to do a single reading) and then I suppose I should send a dummy byte in order to get 2 bytes out of the chip (the last one being the data, according to the diagrams of the chip's design note)... I send a random byte, I send nothing and I still get a number which makes no sense for me, but it is always the same and it's on the index 0, so no idea. I expect to have the reset values because I send first the SRES Strobe (in the design note explained) and I wait about a millisecond until I run the program again so I think MISO should be low by then meaning the chip has stabilized... because I haven't yet figured out how to read the MISO signal alone (help with this is also very very appreciated!!)
Thus, maybe I'm not even writing correctly the SRES strobe I don't really know what's happening. To read I would send a bit 0 to write another 0 to make it single access and then the 6 bit address of the register, and then immediately the 8-bit data I want to write, but for the strobes one must not write any data, just a particular address like 0x30 which is SRES, so that's what I'm sending.
Here is the datasheet of the chip that I'm currently working with and the design note that specifies how to access it via SPI, and additionally the datasheet of the evaluation module (Page 9 and 12) just in case I'm doing something wrong in the connections. I looked for the pinout of the NI 8451 and connected my evaluation module accordingly (using CS 0)
Please help me make work my VI or tell me what am I doing wrong. Anything that you can share it's hugely appreciated... I only have a month left here and want to go with my best effort to advance this proyect, so please help me. If you have any questions please ask me, I'll make my best to answer you.
Thanks in advance!!!! Very very much!!
Sincerely,
Gisela
06-01-2010 12:29 PM
Why are you trying to create a script? Have you taken a look at the "General SPI Read" example that ships with the 8451? The part in the middle is creating the message. This is the part that you would need to change. In your case to read a register you'd OR the register address with 0x80, as you indicated, and tack on an extra byte. This array of 2 bytes is what you'd feed to the "SPI Write Read" VI. The output of that VI should be 2 bytes. The second one is the one you're interested in.
You would not be controlling the transmission at a bit-level - the 8451 takes care of that.
06-02-2010 04:28 AM
First of all, thanks for your answer, I appreciate your time.
Second, okay... I did try that a bunch of times before but no luck. Here is the snippet
But I don't get any useful information. I think the problem may lay on the physical connection but when I only connect the 4-Wires, I don't know how to supply the voltage, but I do still get readings, none of them accurate. My boss really doesn't know how the evaluation board works, and I've looked everywhere for more info and no luck. They only give the pinout for the Port B which is the one that has the 4 wire SPI Interface in the document I linked previously, and the Atmel in the other NI Tutorial is connected to VCC and GND. I've also tried that (but my board says 3.3V, I still connect the 5V output of the USB 8451 to this terminal) and I connect one of the GND of my evaluation board to one in the USB 8451. All I get is FF, no matter what I do, even for a Chip select that it's not even connected (I know SPI offers the master no way of knowing wheather it's being listened or just talking to air). How to know what I'm doing wrong, then?
I fully understand what you said, and had tried it myself a bunch of times, but now I'm lost.
I know I should send the address OR'd with an 0x80 to read and with a 0x00 to write. I should send a dummy byte when I read (can be anything I think) in order to get the 2 bytes out of the device in which case the second one is the content of the register I addressed. Sounds simple enough! I also read that I have to reset the chip first or it is in unknown state. That was the main reason for using the Script. They say I have to pull CSn low and then high, and wait for at least 40um (microseconds) and then pull CSn low again and issue a "SRES" command strobe, which is writing the address 0x30 with no data (or any data I think), that's how you issue the strobe. I do it, and that's when I get all zeros. And they should be all the default values, which are definitely not all zero. Here is my coding... (correct if wrong)
Please offer any kind of advise or experience... 😞 I feel lost. I understand but I can't get anything that makes sense out of it. Should I use an additional voltage source and just connect the 4 Wires with GND or without GND?? I don't know if that would work. But is there anything wrong with the program? If there is please tell me, if there isn't I should start looking out for a way to fix a possible physical misconnection. The proyect is quite urgent, so your replies and truly and hugely appreciated.
For all the datasheets and links to .pdf documentation, please see my previous post. Thanks again specially to smercurio_fc. I deeply thank you for all your advice, I'll keep trying anyway.
Have a nice day everyone!
Sincerely,
Gisela
06-02-2010 11:04 AM
I've used the USB-8451 with SPI and it works fine. My device also was a 3.3v device. I connected 5v for the supply and used the 8451 as it is(5v logic). This did not seem to bother the device I was communicating with. However, your device may differ. You may need to use level shifters in order to knock down 5v to 3.3v to the device, and 3.3v from the device to 5v for the 8451.
You do not need scripting. I've never used it. The 8451 will automaticlly set CS low when you write or read to any address. If you need to set CS low then high, just read address 0. CS will go low then high. You don't have to control the CS line yourself. Just use the simple write/read SPI vi's. You need to connect all 4 wires (SCLK, DI, DO, CS), VCC, and GND. The 8451 takes care of sending the clock, data, and chip select in the right timing order.
If the simple write/read doesn't work, I would try using level shifters to take the voltage down to 5v. Read the specs on your device to see if it can handle 5v. Try supplying 3.3v to VCC using a separate power supply. Be sure to tie the power supply ground to the 8451 ground. The 8451 should be able to see 3.3v from the device as a high. Not sure how your device will respond to a 5v level for clock and data in. Instead of level shifters, you could use a voltage divider made of resistors.
06-04-2010 04:04 AM
Thanks so much for your insight -tbob!!
But I'm afraid I'm still lost. I have the following connections with an external power supply (naturally with 3.3V):
* VCC to an external digital power supply 3.3 Volts, ground tied to the device AND to the NI 8451.
*SO of my device to pin 15 of NI 8451 (which says SDI)
*SI of my device to pin 14 of NI 8451 (which says SDO)
*CSn of my device to CS0 of NI 8451 (Chipselect = 0)
*GND of my device to one of the GND of NI 8451 (pin 1)
I've checked with a multimeter the voltage and it is 3.293V so pretty much what I need, meaning the device is well supplied and the GND of both device and NI 8451 is tied. The maximum fsclk for my device is crystal oscillator frequency (26MHz) divided by 8, so 3.25 is my maximum. I use 1000kHz and get nothing but 0xFF on both bytes (I get two bytes, the second one being my register's content). It doesn't do anything. I change the parameters, and nothing but those horrible 0xFF. The coding is awfully simple, so I know that can't be it, can it??
I'm just desperate at this point... !! I can't keep up with my internship proyect as long as I can't make any sort of usable communication with the device. What am I doing wrong here? Could it possibly be the part that I mentioned about the reset. Here is what it says in my datasheet:
When the power supply complies with the requirements specified in the data sheet, proper Power-On-Reset functionality is guaranteed. Otherwise, the chip should be assumed to have unknown state until a SW reset is implemented (see Figure 12).
• Strobe CSn low / high.
• Hold CSn high for at least 40 μs relative to pulling CSn low
• Pull CSn low and wait for SO to go low (CHIP_RDYn). (How can I check the SO of my device??? There are no VI's that do that, are there?
• Issue the SRES strobe on the SI line. (which is sending 0x30 to the device)
I've tried to read address 0 and I get those 0xFF, and when I try a new address it is the same. I don't know if that should be working.
How to achieve that diagram with using only the basic API?? Can anyone point me where my mistake is? I really know it should be something obvious that I'm missing but I don't know what. I've tried waiting and issuing the strobe but it doesn't change anything. Can these 0xFF values be due to an unstable condition because I don't reset the device? If so, how can I build the VI that does the reset?
Thanks again for your time -tbob and smercurio_fc!! I appreciate your responses...!!
Sincerely thankful,
Gisela
06-04-2010 09:09 AM
Simple question: Have you tried using the SmartRF Studio software that TI makes available. This is just to make sure the chip is working in the first place.
As noted in the documentation, you should not need to send SRES as long as the power connections are made properly. It's not clear what datasheet you are referring to. Figure 12 in the device datasheet doesn't look anything like what you've shown.
You've provided links to several documents, and I'm not sure what you actually have. One of the links you provided is to an evaluation board. Are you actually using this, or do you have the chip breadboarded?
06-04-2010 11:12 AM
Do you have access to an oscilloscope? You need one. If you have a 4 channel scope, you should probe SCLK, SDI, SDO, and CS. When you first power up and send CS low, then high for at least 40uS, then low again, look on the scope to see if SO is going low to signify OSC stability. If this checks out OK, then I am really puzzeld as to your problem. Your code is very straight forward and I don't see anything wrong with it. I suspect you have an electrical problem, meaning that the waveforms are not getting to the device properly. I would need to see scope waveforms to determine if there is a problem there. Things to look for on the waveform, especially the clock, are overshoot, ringing, very slow rise time, voltage level not what it should be, and any distortion of a square wave. Look for the same on the SDO line (data from the 8451 going into the device). Although you read FF, look at the SDI line (data from the device) to see if it is truly always high. Check the CS line to see if it is actually going low. You need to probe these signals at the device end as close as possible to the device itself.
06-07-2010 02:50 AM
Hi smercurio_fc!
To answer your questions:
Yes, I've tried to use the SmartRF Studio software to check the chip, and everything is in order there.
The power connection is a power source at exactly 3.3V and I think I shouldn't use a SRES strobe but I tried it though. The datasheet I put the image from is the one that says SPI Connection or Interface. It's a small pdf document on how to connect via SPI with different chips (among which, CC1100, is one of them).
I have an evaluation board, we evaluate the chips in the lab, we always use the evaluation board and the evaluation module. I have all those things, this is no prototype.
But funny thing, on Friday it actually worked. It read all the registers, I could actually write to them and reset the device. It worked about an hour before I left for home... and I was so happy. And today I come to work, and it is doing the same thing again. Now I know my program is not the problem!! I don't know what's going on with the board, but it works fine with SmartRF Studio and I left it exactly as it was on Friday, no changes, nobody touches my desk 😞
I'll try the oscilloscope to see what is going on, but have any of you had any of these problems. The task sounds simple enough for my boss and he's now angry at me for not being able to communicate with the damned board.
One thing that I would like to point out is that the current consumption (marked by the supply) was 0.062A when it actually worked... and now it's 0.047A and it doesn't. Should I need to add resistors or capacitance to the circuit? The board should work as it is when supplied correctly!! What on Earth is happenning!!
By the way when it worked I actually didn't believe it, and turned it on and off a couple of times, you know, to be sure it would work today... and it did work all those times, but today it just doesn't. The thing is somehow instable 😞
Please, any insight would be marvelous.
Thanks again for your comments and time... it is totally and ultra appreciated.
Sincerely,
Gisela
06-07-2010 03:04 AM
Hi tbob!
Thank you very much for your answer! I truly appreciate it!
I'll try the oscilloscope tests... when I get my hands on one today. But as I told smercurio_fc... on Friday it did actually work. I could read, write and reset the device with labview, I was happy. I turned it on and off a bunch of times and still worked... did many tests, and still worked. And today it's just back to square one!
Current consumption changed as it was always 0.062A when it worked (always!!) and now it's just 0.047A (also in every tried time). How could this happen if I left it just as it was on Friday and nobody touches my desk...??
I'll try to get the oscilloscope to find out what is really happening, but I suspect there is something wrong with the signals, as you say. The connections are also pretty simple and I see no reason for it to be unstable. The power supply is industrial as we work on a lab.
I'll get back to you later today, to see how it went with the oscilloscope and how to proceed from there.
Thanks so very very much again! It's nice that someone offeres insight and help, even more as a volunteer. You guys are amazing! Truly!! Here in the lab all I get are angry looks and almost shouting 😞
'til later!
In case you want to see how it worked... and didn't work I put some images... because I did print screens so someone would believe I'm actually working.
Friday 🙂
Today 😞
Sincerely thankful,
Gisela
06-07-2010 09:40 AM
The fact that you had it working for a while, and that you power-cycled it and it still worked but now it doesn't seems to me to point to a hardware problem, not a software problem. When it stopped working did you try switching back to talking to it with the SmartRF Studio software? It's possible you may have a bad connection with the board and the NI-845 or you may have a faulty evaluation board.
g.garzam wrote:One thing that I would like to point out is that the current consumption (marked by the supply) was 0.062A when it actually worked... and now it's 0.047A and it doesn't. Should I need to add resistors or capacitance to the circuit? The board should work as it is when supplied correctly!! What on Earth is happenning!!
This implies that something is not getting powered. If you can you should check the voltages with a DMM at the chip to see if it's actually powered. No, you should not be adding resistors or capacitance to the board willy-nilly.