November 22, 2024, 03:21:28 AM

SD-SPI Compile errors

Started by Newburt, August 08, 2014, 04:09:00 PM

Previous topic - Next topic

Newburt

Hi,

I'm new to Microchip programming and am trying to teach myself. I want to make a program that reads a file from an SD card does some editing and writes a new file back to the SD card. Most of the example projects I've found online use SD-SPI.h.

My problem is that when I try to compile their code, I get the errors below. I would expect example projects to have all the files you need, but there is obviously some undefined variables/functions. What am I missing? Every project I try with SD-SPI gives the same 'undeclared' errors (SPI3BUF is usually the first one). If it matters, I am using a Duinomite-Mega with a p32mx795f512h microchip.

Most recently, I got the mmbasic source code for the duinomite and tried to compile that with the same results below.

----------------------------------------------------------------------
..\SDCard\Microchip\MDD File System\SD-SPI.c: In function `MDD_SDSPI_AsyncReadTasks':
..\SDCard\Microchip\MDD File System\SD-SPI.c:1024: error: `SPI3BUF' undeclared (first use in this function)
..\SDCard\Microchip\MDD File System\SD-SPI.c:1024: error: (Each undeclared identifier is reported only once
..\SDCard\Microchip\MDD File System\SD-SPI.c:1024: error: for each function it appears in.)
..\SDCard\Microchip\MDD File System\SD-SPI.c:1030: error: `SPI3STATbits' undeclared (first use in this function)
..\SDCard\Microchip\MDD File System\SD-SPI.c: In function `MDD_SDSPI_AsyncWriteTasks':
..\SDCard\Microchip\MDD File System\SD-SPI.c:1449: error: `SPI3BUF' undeclared (first use in this function)
..\SDCard\Microchip\MDD File System\SD-SPI.c:1451: error: `SPI3STATbits' undeclared (first use in this function)
..\SDCard\Microchip\MDD File System\SD-SPI.c: In function `CloseSPIM':
..\SDCard\Microchip\MDD File System\SD-SPI.c:1858: error: `SPI3STAT' undeclared (first use in this function)
..\SDCard\Microchip\MDD File System\SD-SPI.c: In function `OpenSPIM':
..\SDCard\Microchip\MDD File System\SD-SPI.c:1985: error: `SPI3STAT' undeclared (first use in this function)
..\SDCard\Microchip\MDD File System\SD-SPI.c:1992: error: `SPI3BRG' undeclared (first use in this function)
..\SDCard\Microchip\MDD File System\SD-SPI.c:1994: error: `SPI3CONbits' undeclared (first use in this function)
..\SDCard\Microchip\MDD File System\SD-SPI.c: In function `InitSPISlowMode':
..\SDCard\Microchip\MDD File System\SD-SPI.c:2151: error: `SPI3BRG' undeclared (first use in this function)
Halting build on first failure as requested.
----------------------------------------------------------------------

JohnS

Maybe the wrong version of the compiler or other tools, or the wrong path(s).

Mchp use versions of gcc they've modified and only somewhat feed back the changes i.e. are in violation of GPL, which doesn't help their customers.

John

KeesZagers

I'm quite sure that you have some incompatibility between the sources and the version of the compiler.
I used the last Olimex DM-Basic version 2.7 (which was still an open software) It is more than 2 years old, but still works with complete support for the SD-card.
You can find it on GITHUB (follow the link on the Olimex site) and you can compile it with:
MPLAB C 32 version 1.11b (will not compile on 2.0 and later versions!)
MPLAB-X 1.10
Maybe not the most recent versions, but it works.

By the way: I'm trying to get the SD card (as well as other peripherals) working in MPIDE. I think I know how they control it, but I have to change some libraries to get it on the right SPI port.

Newburt

Thanks JohnS and KeesZagers! I was using the wrong compiler version. I reverted back to an older one and it compiled no problem.

Is there anyway to know which compiler is required for code that has already been written? I'm assuming not and that you have to rely on whoever wrote the code to include that info in the source files.

Thanks again!

KeesZagers

You are absolutely right; you have to rely on what they write in the source files or readme's.
In the past you had things as "upwards compatible" and "one standard". Nowadays the marketing issue is: "This new tool sets a new standard!". Unfortunately it is the 10th standard, so there is no standard at all. Mr. Kernighan and mr. Ritchie had not this in mind when they created the C-language, I think.