I am having problems with SPI communications. I have initialized my SPI inteface with cpol=0, cpha=1, MSB first, and 4-wire mode.
Attached is a jpg file showing CSB, SCLK, MOSI, and MISO when trying to read CH0_CONFIG Register 0x21.
What am I doing wrong?
Hi Bradley,
Your LA trace looks a little unusual - I'm not used to seeing the SCLK, MOSI and MISO all have what look to be the exact same set of data. How are you connecting into the LMP90100? Can you post us a schematic of your setup?
Regards,
Tom
I did have a connection problem with my Microcontroller and LMP90100. I have corrected that problem now and I am attempting to read CH0_CONFIG Register 0x21 from LMP90100 ADC and I should get the default value of 0x70, but I always get back zero.
My LMPread function for register 0x21 sends Transaction-1 which is: INSTR1, URA and then sends Transaction-2 which is INSTR2
spiWrite(chr(INSTR1)) #sends 0x90 spiWrite(chr(URA)) #sends 0x02 x = ord(spiXfer(chr(INSTR2))) #sends 0x81
Attached is the updated LA trace.
Is there something that I am missing because I only receive zero back when the default vaule for this register is suppose to be 0x70? I have tried other registers whose default value is also non-zero with the same result of zero.
I am try to do a simple read and only receive back zero. Do I need to write something before I can try a simple read?
Please take a look at the MSP430-LMP90100 interfacing application note and code zip for examples
http://www.ti.com/lit/an/snaa134/snaa134.pdf
http://www.ti.com/litv/zip/snac029 <-- code zip
Hey.
I have a similar problem. You gotta fix it?, You could tell me what you did?. Thank you.
I did have some problems with the SPI data I was trying to send to the ADC. I now can send the correct SPI data, but still get no response from ADC.
The logic analyzer attachment was created when I tried to follow the example on page 41 of the LMP90100 RevN Datasheet which is 17.4.2 Reading from Register Example. That simple example would not even work correctly. address=34, 0x22 INSTR1=16, 0x10 URA=2, 0x02 LRA=2, 0x02 INSTR2=130, 0x82 return value=0, 0x00
I did not receive any support other than look at the example code which I already had done. I think this ADC is a great product and I would love to get it working, but it took too long and no real support for it. My solution was to use a different ADC (LTC2498). If I can figure out what went wrong or get some support to find a solution, then I will post it here.
Good luck, Javier!
Bradely/Javier,
I attach here a scope shot for the register read transaction you mention above. The top waveform is CSB, then MISO, MOSI and CLK. If you look at the MOSI waveform, you can see first the instruction byte1 INSTR1 (0x10) is sent, followed by upper address byte URA (0x02) and instruction byte2 INSTR2 (0x82). Following this, we read the data byte on MISO (0x13) which is the default value for register 0x22. I used MSP430 USCIA1 (SPI mode) peripheral to control LMP90100. I also did a gpio bit bang version example (instead of using USCIA1 peripheral) and the scope shot is also attached below.
Let me know if this helps. Please check if LMP90100 Evaluation Board is powered correctly. You need to provide two supplies (VA & VIO).
Thanks,
Vishy
I attach the scope shots below
Vishy Viswanathan I also did a gpio bit bang version example (instead of using USCIA1 peripheral) and the scope shot is also attached below. Let me know if this helps. Please check if LMP90100 Evaluation Board is powered correctly. You need to provide two supplies (VA & VIO). Thanks, Vishy
I also did a gpio bit bang version example (instead of using USCIA1 peripheral) and the scope shot is also attached below.
Vishy,
I was using an 8-bit Atmel AVR micro-controller and separate board that I made for the LMP90100 (attached is picture of the LMP90100 board).
I have tried using both the built-in SPI interface (hardware) and wrote a gpio bit bang version (software). With either the hardware or software SPI, I do not receive a response from LMP90100 (trying the example on page 41 of the LMP90100 RevN Datasheet which is 17.4.2 Reading from Register Example).
The steps you outlined in your explanation of the oscilloscope attachments, specifically:
1) instruction byte1 INSTR1 (0x10) is sent
2) followed by upper address byte URA (0x02)
3) instruction byte2 INSTR2 (0x82)
4) we read the data byte on MISO which should be (0x13) the default value for register 0x22
are exactly what I have tried doing using both methods the hardware and software SPI. Could you provide the code you wrote for your gpio bit bang version? I don't know if it will help, but maybe there is something simple that I am missing.
Brad
Brad,
I attach here a zip file with the bitbang code. The file TI_MSP430_spi_BITBANG.c has all the functions you need to look at. There’s a SPI setup function to setup bitbang pins. There’s also SPI read and write functions that calls bitbang_in and bitbang_out to read and write out data. Let me know if you have questions.
Vishy4670.bitbang.zip
Since the bit-banged SPI software version is slower than the hardware SPI, I noticed on the logic analyzer capture the drdyb signal asserting about every 4.6ms.
Do I need to complete writing INST1, UAB, INST2 before the next assertion of drdyb, right?
Previously, I had not waited for drdyb to assert after asserting CS. Using the hardware SPI, I have written INST1, UAB, INST2 before next drdyb, but I still get no response when trying to read from ADC.
What suggestions, if any, do you have for me to try?
drdyb matters when reading out of ADC_DOUT registers. There's no timing dependency for reading other registers with drdyb. Could you share with me your atmel bit bang code & also the schematic showing how the atmel MCU SPI (or GPIO) pins are setup?
Attached is Adobe PDF file with schematic and bit-bang code. I am using an RF200 module from Synapse Wireless. The microcontroller on the module is Atmel ATMega128RFA1.
I have also used the Synapse Wireless Forum (http://forums.synapse-wireless.com/showthread.php?t=2152&highlight=spi+communications+problems) to make sure I was using their version of Python to program the module correctly. I have tried their built-in version of SPI and the attached code is my bit-bang implementation. I think there must be something that I am missing when trying to read from the ADC.
3034.TI Forum - Post.pdf
In your code, I see both the spiWriteReg and spiReadReg functions use SPI_MOSI line. Shouldn't the spiReadReg function use SPI_MISO line instead?
>>> My bad: At the end I see you are using the MISO line.
I am still reviewing. If I find something else, will let you know.
thanks,
Please see below my inputs after reviewing your python code:
a) In lmpSetupSPI(), please include
SetPinDir(SPI_MISO, False) #just to be sure pin is configured as GPIO input
b) In SPIReadReg and SPIWriteReg, please try with clock polarity low to high instead of high to low (as in the bit bang code)
writePin(SPI_SCK, False) # Toggle the clock line ( low to high polarity)
writePin(SPI_SCK, True) # Toggle the clock line
c) SPIWriteReg: How is this function used? Not particularly useful as it won’t work with a lmp register address. At the end of SPIWriteReg why there is \CS toggle?