Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C program (XC8) will not build..function declaration?

Status
Not open for further replies.
T

treez

Guest
Hello,
Do you know why this c program will not build.
Its in MPLAB.X.
The compiler is complaining about the set_ana_dig_ports() function....it says its a redeclared variable., says theres conflicting declarations

Here is the code...

// * File: 3CH TEST.c

//;Code for 3 channel led driver on the updated 550587 PCB
//;WE ARE TRUNCATING THE ADC REGISTER SO JUST USE UPPER 8 BITS
//
//;DEFINE INPUTS FROM DIPSWITCH
//;Note that the new board has pullups on the dipswitch,
//;whereas 550587 PCB had pull downs, thus logic is reversed.
//; XXX DIPSWITCH POLARITY:- XXX
//;DIP 1...ON = EXTERNAL CONNECTOR CONTROL
//;DIP 2...ON = LOGIC HIGH (note 'ON' gives a low input)
//;DIP 3...ON = LOGIC HIGH
//;DIP 4...OFF = 10V is for max current
//;DIP 5...OFF = 80degC, ON = 90degC
//;DIP 6... UNUSED
//;DIP 7... UNUSED
//;DIP 8...ON = NO FAN FITTED, OFF = FAN FITTED
//
//; XXX EXTERNAL CONTROL CONNECTOR POLARITY:- XXX
//;CLEAR = ACTIVE HIGH
//;RESET = ACTIVE HIGH
//;CH1...HIGH = ON, LOW = OFF
//;CH2...HIGH = ON, LOW = OFF
//;CH3...HIGH = ON, LOW = OFF
//
//;List of input ports:
//; ************** DIPSWITCH INPUTS:
//;DIP1 = RB0
//;DIP2 = RB1
//;DIP3 = RB2
//;DIP4 = RB3
//;DIP5 = RB4
//;DIP6 = RB5
//;DIP7 = RC5
//;DIP8 = RE6
//
//;************* External connector INPUTS:
//;clear = RC1
//;ch3 on/off = RC7
//;RESET = RD5
//;CH1 on/off = RD6
//;ch2 on/off = RD7
//
//;Other inputs (DIGITAL I/O
//;Fan tacho = RG2
//;mclr = RG5
//
//;Inputs that are ADC inputs:
//;RA2 = AN2
//;RA3 = AN3
//;RA5 = AN4 ADCON0=0x10
//;RF1 = AN6
//;RF2 = AN7
//;RF3 = AN8
//;RF4 = AN9
//;RF5 = AN10 ADCON0=0x28
//;RF6 = AN11 ADCON0=0x2C
//;RF7 = AN5 ADCON0=0x1C
//
//;**********ADC INPUTS:
//;AN0 = NC
//;AN1 = NC
//;AN2 = VREF- (0V)
//;AN3 = VREF+ (3V)
//;AN4 = Therm ch1
//;AN5 = I_CH1
//;AN6 = 0-10V control input
//;AN7 = PCB thermistor
//;AN8 = I_ch2
//;AN9 = I_ch3
//;AN10 = Therm-ch2
//;AN11 = Therm-ch3
//
//;OOOOOOOOOOO LIST OF OUTPUTS:
//;Trip = RA4
//;Indicator LED = RC2
//;MCP4013_CS = RC3
//;MCP4013_UD = RC4
//;Shutdown-Ch2 = RE0
//;Shutdown-Ch1 = RE1
//;Fancon PWM = RE2
//;Shutdown-Ch3 = RG0
//
//;NCNCNCNCNCNCNCNCNC LIST OF NON CONNECTED PINS:
//;RA0
//;RA1
//;RA6
//;RA7
//; RB6 = PGC
//; RB7 = PGD
//;RC0
//;RC6
//; RD0
//; RD1
//; RD2
//; RD3
//; RD4
//;RE3
//;RE4
//;RE5
//;RE7
//; RG1
//; RG3
//; RG4/*
#include <xc.h>



void set_ana_dig_ports(void);
void disable_interrupts(void);
void disable_pullups(void);
void disable_opendrain(void);
void disable_comparators(void);
void setup_adc(void);
void setup_ports(void);
void NC_pins_low(void); //make all NC pins low.
//CONFIGS

/*DEFINE OUTPUTS*/
#define ch1bit LATE,LATE1
#define ch2bit LATE,LATE0
#define ch3bit LATG,LATG0
#define ind_ledbit LATC,LATC2
#define fanconbit LATE,LATE2
#define tripbit LATA,LATA4
#define mcp4013_csbit LATC,LATC3
#define mcp4013_udbit LATC,LATC4

/* TURN LEDS ON AND OFF*/
#define ON1 LATE,LATE1 = 1; /*Turn on chan1*/
#define OFF1 LATE,LATE1 = 0; /*Turn off chan1*/
#define ON2 LATE,LATE0 = 1; /*Turn on chan2*/
#define OFF2 LATE,LATE0 = 0; /*Turn off chan2*/
#define ON3 LATG,LATG0 = 1; /*Turn on chan2*/
#define OFF3 LATG,LATG0 = 0; /*Turn off chan2*/
#define FANON LATE,LATE2 = 1; /*Turn fan on*/
#define FANOFF LATE,LATE2 = 0; /*Turn fan off*/

/*DEFINE INPUTS FROM DIPSWITCH*/
/*Note that the new board has pullups on the dipswitch,*/
/*whereas 550587 PCB had pull downs, thus logic is reversed.*/
unsigned int dipbit1;
unsigned int dipbit2;
unsigned int dipbit3;
unsigned int dipbit4;
unsigned int dipbit5;
unsigned int dipbit8;
unsigned int dip8; //bit0=dip1...
unsigned int dip8_init;
unsigned int ext5; //bit0=reset,bit1=ch1...etc, to bit4=clear
//external connector pins
unsigned int extbit3; //reset
unsigned int extbit4; //ch1
unsigned int extbit5; //ch2
unsigned int extbit6; //ch3
unsigned int extbit9; //an in
unsigned int extbit10; //clear
unsigned int extbit11; //TRIP OUT
unsigned int temp1;
unsigned int temp2;
unsigned int temp3;
unsigned int tempb;
unsigned int ana8; //holds ADRESH
unsigned int max_led_temp;
unsigned int max_pcb_temp;
unsigned int board_90c; //max board temp value
unsigned int board_80c;
unsigned int led_90c;
unsigned int led_80c; //max led temp value
unsigned int ledthermopen; //trip value when thermistor open
unsigned int pcbthermopen;
unsigned int current; //represents 0A, 1.76A, 2.64A, 3.52A //bit0=0,bit1=1a76...etc
unsigned int iset_mcp4013; //numer of down pulses needed to get current.


void main(void) {
disable_interrupts();
disable_pullups();
disable_opendrain();
disable_comparators();
setup_adc();
setup_ports();
NC_pins_low(); //make all NC pins low.
OFF1;
OFF2;
OFF3;
while(1){;}
return;
}

set_ana_dig_ports(){
ANCON0 = 0xFC;
ANCON1 = 0x0F;
ANCON2 = 0x00;
}
disable_interrupts(){
INTCON=0x00;
INTCON2=0x80;
INTCON3 = 0x00;
PIE1 = 0x00;
PIE2 = 0x00;
PIE3 = 0x00;
PIE4 = 0x00;
PIE5 = 0x00;
PIE6 = 0x00;
}
disable_pullups(){
PADCFG1 = 0;
}
disable_opendrain(){
ODCON1 = 0;
ODCON2 = 0;
ODCON3 = 0;
}
disable_comparators(){
CM1CON = 0;
CM2CON = 0;
CM3CON = 0;
}
setup_adc(){
ADCON0 = 0;
ADCON1 = 0x10; //VREF
ADCON2 = 0x3E; // Left jus/Tacq
}
setup_ports(){
TRISA = 0x2C;
TRISB = 0x3F;
TRISC = 0xA2;
TRISD = 0xD0;
TRISE = 0x40;
TRISF = 0xFE;
TRISG = 0x24;
}
NC_pins_low(){
//Make all NC pins low (they are already made to outputs)
//They are outputs for noise immunity reasons.
LATA,LATA0 = 0;
LATA,LATA1 = 0;
LATA,LATA6 = 0;
LATA,LATA7 = 0;

LATB,LATB6 = 0; //PGC
LATB,LATB7 = 0; //PGD

LATC,LATC0 = 0;
LATC,LATC6 = 0;

LATD,LATD0 = 0;
LATD,LATD1 = 0;
LATD,LATD2 = 0;
LATD,LATD3 = 0;
LATD,LATD4 = 0;

LATE,LATE3 = 0;
LATE,LATE4 = 0;
LATE,LATE5 = 0;
LATE,LATE7 = 0;

LATG,LATG1 = 0;
LATG,LATG3 = 0;
LATG,LATG4 = 0;
}
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,151
Helped
14,387
Reputation
29,038
Reaction score
13,141
Trophy points
1,393
Location
Bochum, Germany
Activity points
283,286
Function declarations are expected to have a return type.
You'll want to write
Code:
void set_ana_dig_ports(void){
   ANCON0 = 0xFC;
   ANCON1 = 0x0F;
   ANCON2 = 0x00;
}
and so on.

The function parameters must be also identical to the previous declared prototype, otherwise the compiler assumes two different (overloaded) function versions.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top