Why am I getting this syntax error?! (C) - MPLAB

fouadalnoor

Member
Hi guys, I am currently trying to build a simple mp3 player using an sd card to store the music files and a PIC18f14k50 and a vs1011 decoder.

I am using the Petit FAT File System in order to do it (as it seems the simplest that way..)

Petit FATfs:

I have tried to use the sample PIC24 Sample project as a guide (you can download it from the website).

My code from MPLAB (v8.86) is shown below:


#include "p18f14k50.h"
#include "diskio.h"
#include "pff.h"
#include "string.h"

//Configuration bits set in settings.

//prototypes
void wdtdisable (void);
void oscsetup(void);
void spisetup(void); //SPI setup in FSConfig.h

void main (void){

wdtdisable();
oscsetup();
TRISC = 0;

FATFS fatfs; /* File system object */
DIR dir; /* Directory object */
FILINFO fno; /* File information object */
WORD bw, br, i;
BYTE buff[64];

disk_initialize();


while(1)
{LATCbits.LATC0 = 1;}
}



void wdtdisable (void){
WDTCONbits.SWDTEN = 0; //disable watchdog timer, might be able to use #pragma config WDTEN = OFF at the top
}

void oscsetup(void){

// Setting up internal oscialltor for 32MHz

//using primary clock so that 4xPLL can be used
OSCCONbits.SCS0 = 0;
OSCCONbits.SCS1 = 0;

OSCCONbits.IDLEN =0; //device enters sleep mode on "sleep" instruction
OSCCONbits.IRCF = 0x6; // setting Internal oscillator to 8MHz (so 4xPLL can be used)
OSCCONbits.OSTS =0; // Device running from High frequency internal oscillator
OSCCONbits.IOFS = 1; //Make High frequency oscillator stable

OSCTUNEbits.SPLLEN = 1; //Enable PLL



}

The output console says that there is a syntax error on the "FATFS fatfs;" line. When I remove that line it complains about the next one, until I remove the "BYTE buff[64];" line.

Can you guys help!???

Thanks in advance!
 
Last edited:
Ah, I got some help and it was because I had not defined

FATFS fatfs;
DIR dir;
FILINFO fno;
WORD bw, br, i;
BYTE buff[64];"

at the start of main (before the setup functions).


 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…