View previous topic :: View next topic |
Author |
Message |
luis.rigoni
Joined: 14 Oct 2010 Posts: 12
|
ex_fat.c problem with SPI |
Posted: Thu Oct 14, 2010 9:33 am |
|
|
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
|
|
Posted: Thu Oct 14, 2010 12:35 pm |
|
|
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
|
|
Posted: Thu Oct 14, 2010 12:42 pm |
|
|
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
|
|
Posted: Thu Oct 14, 2010 2:12 pm |
|
|
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. |
|
|
|