View previous topic :: View next topic |
Author |
Message |
uni_student
Joined: 01 Aug 2007 Posts: 38 Location: AUckland, NEW ZEALAND
|
Problem with functions: Compiling in MPLAB |
Posted: Thu Oct 11, 2007 12:00 am |
|
|
Just trying to set up a simple function in my program, but MPLAB doesn't like it when compiling. These are the errors:
"Expecting a basic type"
for function declaration line
"Expecting an identifier"
and
"Expecting a declaration"
for within the function.
Heres the code:
Code: | #include <18f452.h>
#include "left.c"
#include "sound11.c"
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT
#use delay (clock=10000000)
#define LED PIN_A1
#define MEM_SELECT PIN_C1 //checked
#define MEM_HOLD PIN_D1 //checked
#define WR_PROTECT PIN_D0 //checked
#define WREN 0x06 //checked
#define WRSR 0x01 //checked
#define RDSR 0x05 //checked
#define READ 0x03 //checked
#define PP 0x02 //checked
#define BE 0xC7 //checked
#define DREQ PIN_D7 //checked
#define BSYNC PIN_D6 //checked
#define xCS PIN_D5 //checked
#define RESET PIN_C0 //checked
void wren (void); //first problem here
void main(){
unsigned long int Sound_Pointer;
unsigned long int Sound_Pointer2;
int data, value, i, k, m, j;
........
} |
I call the function by this line "wren();"
Code: |
void wren (void){
int status;
output_low(MEM_SELECT); //*******SELECTED*******
spi_write(WREN);
output_high(MEM_SELECT); //********DESELECTED********
status=0;
while(status!=2){
output_low(MEM_SELECT);
spi_write(RDSR);
status=spi_read(0);
output_high(MEM_SELECT);
}
} |
Any help appreciated |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 11, 2007 12:20 am |
|
|
Don't define a constant with the same name as a function. |
|
|
uni_student
Joined: 01 Aug 2007 Posts: 38 Location: AUckland, NEW ZEALAND
|
|
Posted: Thu Oct 11, 2007 12:38 am |
|
|
Cheers!!! Fixed now |
|
|
mattsouthgate
Joined: 28 Nov 2005 Posts: 1
|
Helpful |
Posted: Tue Aug 04, 2009 4:18 am |
|
|
I'm an old hand at this but it's the simplest problems like this without help compiler error messages that are the infuriating to find. Thanks for the help. |
|
|
|