please share a schematic and source code to analyze
Main Topics
Browse All TopicsWe are developing an electronic compass using two honeywell 2-axis magnetometers (HMC1052 and HMC1051) connected to a Texas Instruments ADC (ADS1243). The ADC in turn interfaces with a PIC 18F252 via SPI.
Our problem is that we are not able to read data from the ADC even when we are able to read its internal registers. When we read the data we just receive zeros. We are programming the PIC in C. To read the registers we use the command command RREG. To read the data we use the command RDATA. We went to the web site of Texas Instruments but they are not giving us any software support. If anyone has any ideas what we might be doing wrong, please let us know.
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
SPI works in a master-slave fashion. A common mistake is to think that you can receive without sending data.
On SPI reception happens only when the master is sending. You may need to send some dummy data (0xFF or 0x00 usually) to the device before reading the RREG.
Like Public suggested above I would like to see what happens if you measure SDI, SDO, CLK and SS on the ADC to see what all 4 lines are doing. Are you selecting the device correctly, are you sending the clock to the slave in order to trigger the reception and are you set up to receive on the correct clock edge?
At high speeds circuit layout and line lengths may start to be a factor.
I have worked with SPI peripherals with PIC processors in many different cases. The sequence of commands to get the correct response is critical. I have used assembly as well as C and find that writing your own routine is often better than using a built in C function so you can get the timing and all the chip specific sequences just right. I would need to see the source code as well as know which C compiler you are using to get a better feel for what is happening.
You can also get some consulting help from either a consultant contacted via the Microchip Consultants Program or the IEEE Consultants networks. Another good resource is the Piclist which is an email list server.
If he is using RREG it means he is using the buit-in USART on the 18F252 and the startup sequence most probably not the problem.
The only thing that may influence the protocol is whether you sample on the rising or falling edge. There is a config bit to select this. Baud rate and timing is not critical, other than at the sampling point (rising or falling clock edge) in SPI. Because of this the slave does not even have to know the baud rate, data can be sent at any rate the master wants.
It is however likely that you have to send the correct sequence of command data to the sensor before it will respond back to you.
I have had much more problems with sequences using I2C than SPI. In SPI you simply give 8 clocks and the data comes out, never had issues, what startup are you referring to?
An actual snip from the code being used and the configuration section of the PIC would help. I am willing to bet it is a simple oversight on how the ADC is being handled but without a few more details all I can give is general advice like to check the command sequences being sent and the reply packets along with timing.
Larry
Since he is only receiving 0's my bet has been that he is not using the SPI correctly. This can of course be due to setup on the SPI or it can be that they did something silly like swap SDO and SDI around or that the ADC is not getting power ,etc.
I asked for some measurements to confirm that the data is being sent correctly, but as biglarryn is saying, we cannot know for certain without the code as well as the schematics to see if all is 100% ...
In either case this is not something that should take an engineer 2 months to sort out so I assume they found the problem and thus are not following this thread any more.
Business Accounts
Answer for Membership
by: publicPosted on 2005-06-25 at 17:34:10ID: 14302229
You may need to use a logic analyzer or at least a scope to verify that some data is present on the spi lines.