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 CCS Technical Support

ex_fat.c problem with SPI

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



Joined: 14 Oct 2010
Posts: 12

View user's profile Send private message

ex_fat.c problem with SPI
PostPosted: Thu Oct 14, 2010 9:33 am     Reply with quote

Hello,

I'm starting to develop an SD card reader with the PIC18F4550. Communication with the PC is via USB. USB communication is OK.
However when compiling the file ex_fat.c generates 100 errors.
The main errors are:

Code:
Library in USE not found "SPI"
line: #use spi(MASTER,CLK=MMCSD_PIN_SCL, DO=MMCSD_PIN_SDO, DI=MMCSD_PIN_SDI, BITS=8, MODE=3, stream=mmcsd_spi, FORCE_HW)

Undefined identifier - output_drive
line: output_drive(MMCSD_PIN_SCL);

Undefined identifier - spi_xfer
line: spi_xfer(mmcsd_spi, 0xFF);


What can cause these errors? What changes must I do to compile?

I'm using PCB / PCM / PCH version 3.242. PCD version 4.093.

Thanks in advance
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 14, 2010 12:35 pm     Reply with quote

Quote:

I'm starting to develop an SD card reader with the PIC18F4550.

I'm using PCH version 3.242.

Your compiler version doesn't support those new features.
luis.rigoni



Joined: 14 Oct 2010
Posts: 12

View user's profile Send private message

PostPosted: Thu Oct 14, 2010 12:42 pm     Reply with quote

PCM programmer wrote:
Your compiler version doesn't support those new features.


Is there any way to fix the code to make it compatible with the compiler?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 14, 2010 2:12 pm     Reply with quote

Get rid of the #use spi() and substitute a setup_spi() statement near
the start of main(). Then do it like this:
Code:

// SPI mode definitions.
#define SPI_MODE_0  (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1  (SPI_L_TO_H)
#define SPI_MODE_2  (SPI_H_TO_L)
#define SPI_MODE_3  (SPI_H_TO_L | SPI_XMIT_L_TO_H)

void main()
{
setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_16 );

Then in every case where spi_xfer() is used, edit the line and change
it to spi_read().


Quote:

output_drive(MMCSD_PIN_SCL);
output_drive(MMCSD_PIN_SDO);
output_drive(MMCSD_PIN_SELECT);

In the case of the lines above, you can substitute this below:
Code:

   output_low(MMCSD_PIN_SCL);
   output_low(MMCSD_PIN_SDO);
   output_high(MMCSD_PIN_SELECT);

Each one is initialized to it's inactive state (low or high, as required).


I don't guarantee that these are the only things you need to do, or that
it will even work. What I've shown in correct, to my knowledge, but I
don't know if your compiler version will work with driver code you have.
It's up to you to make it work.
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