CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC 16f877a to SD interface with SPI HELP!!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
biomec_11



Joined: 16 Nov 2011
Posts: 1
Location: rome

View user's profile Send private message

PIC 16f877a to SD interface with SPI HELP!!
PostPosted: Wed Nov 16, 2011 10:23 am     Reply with quote

Good evening,

I have been assigned with a project where I need to interface a PIC 16f87a to write datas on a SD card using the SPI protocol.
Anyone has any idea on how I should do it?

I have checked the SPI_WRITE() and SPI_READ() functions but I am finding difficulties in understanding how to set the different registers for configuring the PIC.

Can anyone help?
I was planning to us a timer2 with the following specs setup_timer_2(255,div_by16,1) using so a 1.2 kHz frequency to generate interrupts.

Please someone help me I'm so new in those things!

Thank you
Ttelmah



Joined: 11 Mar 2010
Posts: 19469

View user's profile Send private message

PostPosted: Wed Nov 16, 2011 10:46 am     Reply with quote

Questions/comments.
First, rethink what chip you can use. The SD card, would normally transfer data in sectors, and you need to buffer this in your PIC (or waste useable space). The PIC you are talking about (either an 877, or an 87), does not have enough RAM to do this.
Then, how do you intend to handle the card?. Two options. As a linear memory device (only for your own use), or as a filesystem (for use in a PC). If the latter, you need to handle the FAT filesystem on the card. EX_FAT.C, and fat.c have the drivers for this, but you are talking significant size. Again may be a problem in your chip.
Then your interrupt comment. Look at the manual. Is the format you show right?. What order are the values?. Is the syntax of the clock divisor value right?. What is your clock rate?. T2_DIV_BY_16, 255, 1, will give an interrupt at every 16384 cycles of your master clock. 1.2mSec, if your master clock is 13.65MHz. Otherwise, no. Also what do you intend to do at this rate?. Not a lot?. Remember you have just 4096 machine instructions between interrupts at this rate. It already takes about 60 to get into and out of the interrupt. A simple operation like accessing an element in an array can easily use 50 cycles, so it doesn't take much to run out of time....

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group