PDA

View Full Version : 877a and SPI



tico
- 10th April 2007, 17:13
I am looking for code examples to use SPI on the 877a I have searched a few times but the search engine complains that SPI is too short.

My long term goal is to interface with one of the dos on chip IC for sd cards available from sparkfun.com .

I have a project working using serial comm to a PC what I would like is the option to datalog using SPI so that I dont interfere with my serial link to the PC.

Any help would be greatly appreciated.
Thanks in advance.

skimask
- 10th April 2007, 17:20
I am looking for code examples to use SPI on the 877a I have searched a few times but the search engine complains that SPI is too short.

My long term goal is to interface with one of the dos on chip IC for sd cards available from sparkfun.com .

I have a project working using serial comm to a PC what I would like is the option to datalog using SPI so that I dont interfere with my serial link to the PC.

Any help would be greatly appreciated.
Thanks in advance.

http://www.picbasic.co.uk/forum/showthread.php?t=4751

tico
- 10th April 2007, 18:23
Thanks for the quick reply but still cant seem to find an example.

skimask
- 10th April 2007, 18:35
Thanks for the quick reply but still cant seem to find an example.

Check the little green book, enough examples in there to get you started.

Pic_User
- 10th April 2007, 18:54
Hi tico,


Thanks for the quick reply but still cant seem to find an example.

Paste this into your Google search engine.

spi site:http://www.picbasic.co.uk/forum/

or

spi pic16f876a site:http://www.picbasic.co.uk/forum/


hope that helps

-Adam-

tico
- 10th April 2007, 19:06
So since its to the manual should I use hserin or shiftin. I am wrapping my head around this.

I have also found this example from melabs
http://www.melabs.com/resources/samples/pbp/spimast.bas

Since I am new to SPI am I correct that the PIC is the master and the SD card is the slave.

I am just looking for a recomended starting point so I dont spin my wheels more that I already have.

skimask
- 10th April 2007, 20:03
So since its to the manual should I use hserin or shiftin. I am wrapping my head around this.
I am just looking for a recomended starting point so I dont spin my wheels more that I already have.

Simple things first. The DOSonChip datasheets says it'll handle UARTs, SPI (I2C/SMBus coming soon).
Stick with the simplest first...Serial ports...fast, easy to handle, built in string handling in PBP, well documented, easy for a beginner, fast enough with the right code, the right processor, etc. I believe, SPI is overkill in this situation.
So, go with serial. SerIn/SerOut, SerIn2/SerOut2, HSerIn/HSerOut, any one of those combinations will work just fine, no matter what PIC, no matter what speed (up to a point of course). Pretty much it depends on how well and how efficiently you can write your code.

tico
- 10th April 2007, 21:50
I understand that the DosOnChip will handle Uart and SPI with I2c comming soon,
As I stated previously I am already using the serial port for data to the PC, I would like to add SPI for datalogging.
I am using a 16f877a and It only has one TX pin RC.6 I believe, looking at the other pins available and with the specs for th DosOnChip I have the ability for SPI, that is why I chose this part.
Unless I am missing something and I can use another pin to TX serial data, this is my only option for now.

SteveB
- 10th April 2007, 22:18
Unless I am missing something and I can use another pin to TX serial data, this is my only option for now.


This is exactly what you can do with the software serial comm. See the SERIN/SEROUT AND SERIN2/SEROUT2 sections of the manual. Also, do a search of the forum for these and you will have more info that you can use.

SteveB

skimask
- 10th April 2007, 23:05
I understand that the DosOnChip will handle Uart and SPI with I2c comming soon,
As I stated previously I am already using the serial port for data to the PC, I would like to add SPI for datalogging.
I am using a 16f877a and It only has one TX pin RC.6 I believe, looking at the other pins available and with the specs for th DosOnChip I have the ability for SPI, that is why I chose this part.
Unless I am missing something and I can use another pin to TX serial data, this is my only option for now.

Use HSERIN/OUT for the hardware serial pins, and SerIn/Out or SerIn2/Out2 and use seperate pins driven by software. Or forget about HSerIn/Out and use the software serial commands to handle it. If your code is sound and efficient enough, the software commands will handle it just fine. If it's sloppy, then you'll be fighting missed characters, getting out of sync, etc. But the DOSonChip has CTS/RTS pins and so does your PC...so you can use those to your advantage.

tico
- 11th April 2007, 15:57
I am assuming that I need to use inverted mode for communication between the pic and DosOnChip module, can I also us the same method with resistors for rts/cts or should I use a max232.

tico
- 14th April 2007, 02:20
any regard to my questions, I would like to know that I am starting out right.

Archangel
- 14th April 2007, 02:57
I am looking for code examples to use SPI on the 877a I have searched a few times but the search engine complains that SPI is too short.

My long term goal is to interface with one of the dos on chip IC for sd cards available from sparkfun.com .

I have a project working using serial comm to a PC what I would like is the option to datalog using SPI so that I dont interfere with my serial link to the PC.

Any help would be greatly appreciated.
Thanks in advance.
SPI is only 3 letters and the search engine wants 4 so add a wildcard to your search: SPI* and you will get everything that starts with spi - maybe useful, or not.