![]() |
Software SPI Interface
I have been trying to interface a sensor that uses an SPI interface to the RC. I know the actual SPI bus on the PICs is used by IFI - this is how the two PICs communicate. However, C18 has a set of "Software SPI" functions that use digital input pins to emulate SPI (C18 Library Manual, p.121).
I looked at the default values for the SPI pins in the manual. They appear to correspond to digital inputs 1, 2, 5, and 6 on the RC. I connected the sensor to these pins, included the sw_spi.h header in the project, and tried to talk to the sensor. For some reason I cannot get the data out of the sensor. I either get all 1, or all 0 in a byte :) No real data. I am suspecting a conflict with the default FIRST code. The function that initializes the SPI, OpenSWSPI, is supposed to set up the pins correctly. Could it be that the FIRST library is conflicting with this? I tried to remove all lines that referenced the pins I am using from the default code. Didnt help. Also for some reason if I change the pin assignment in sw_spi.h in the mcc18 folder the program does not build properly. Do I have to recompile something or include any other files in my project? Did anyone use the software SPI functions? Or the software I2C which should be close to what I am doing? |
Re: Software SPI Interface
I have no idea what SPI is, but I'll try to give you some general pointers passed on your message.
Is there any docs on using SPI and how to connect a SPI sensor? Is the hardware wired for this? Did you check for semi-colons and the like? One of my probs Did you wire the sensor wrong? Is the sensor bad? Where is the Actual code for the functions? if it is in a lib, I wouldn't mess with it at this time (get it to work first, then check Editing Main.c for advanced stuff) Could it be that it's working, but not as you expected? Are aliens skrewing around with it wile your not looking? :) |
Re: Software SPI Interface
Quote:
Quote:
|
Re: Software SPI Interface
Quote:
[edit]I went to Google. You know how many things SPI stands for?!?!?!?!?!?!?[/edit] [edit]Is SPI a company, or a format? Or both?[/edit] [edit]Think I have it. http://www.mct.net/faq/spi.html Quote:
|
Re: Software SPI Interface
serial peripheral interface. Don't know how to interface it though.
|
Re: Software SPI Interface
For those who are wondering what SPI is: http://www.mct.net/faq/spi.html
Sorry, I don't have any experience with SPI on a PIC. |
Re: Software SPI Interface
Thank you for conferming my find. I just read through it, And it sounds pretty nifty. Tell us how you figure it out.
|
Re: Software SPI Interface
I have another question. Which PIC controls the digital IO pins on the robot controller - master or the user PIC? In other words, is it possible to update data on those pins without calling Putdata? Or does it only update the state of the digital outouts when putdata is called?
|
Re: Software SPI Interface
Quote:
|
Re: Software SPI Interface
If you want some help your going to have to post some code, what sensor your are using and to what pins it is wired.
|
Re: Software SPI Interface
Quote:
Make a function to do a byte at a time. It shouldn't take more than a half hour to set this up. Most intermediate programmers can do it in several minutes for simpler SPI interfaces. There is normally a select pin to indicate when the device is reading. Bring that low, set it to zero, for the duration of the communication. Assuming I didn't forget anything critical, it's been a while, that should all there is to most SPI communications. |
Re: Software SPI Interface
Thats exactly what I am planning to do now - write my own functions :) It would have been nice to get the pre-written ones working (they should be doing the same thing anyway), but writing my own should not be hard. I'll give it a try in a couple of days (as soon as I finish some school assignments :))and see how it works out.
|
| All times are GMT -5. The time now is 04:21. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi