Continue to Site

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.

HI-TECH PICC18 Configuration fuses problems

Status
Not open for further replies.

Stefanovic

Newbie level 6
Joined
Jun 11, 2012
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
France
Activity points
1,358
Hello everybody, i'm new here and i hope we'll have a long relationship :)
here is my problem, i tried to configure a PIC18F4550 fuses but i can't
Code:
#include <htc.h>
#define SELECT LATC6


// PIC18F4550 Configuration Bit Settings


__CONFIG(PLLDIV_1 & CPUDIV_OSC1_PLL2 & USBDIV_1);
__CONFIG(FOSC_EC_EC & FCMEN_OFF & IESO_OFF);
__CONFIG(PWRT_OFF & BOR_ON & BORV_3 & VREGEN_OFF);
__CONFIG(WDT_ON & WDTPS_32768);
__CONFIG(CCP2MX_ON & PBADEN_ON & LPT1OSC_OFF & MCLRE_ON);
__CONFIG(STVREN_ON & LVP_ON & ICPRT_OFF & XINST_OFF);
__CONFIG(CP0_OFF & CP1_OFF & CP2_OFF & CP3_OFF);
__CONFIG(CPB_OFF & CPD_OFF);
__CONFIG(WRT0_OFF & WRT1_OFF & WRT2_OFF & WRT3_OFF);
__CONFIG(WRTC_OFF & WRTB_OFF & WRTD_OFF);
__CONFIG(EBTR0_OFF & EBTR1_OFF & EBTR2_OFF & EBTR3_OFF);
__CONFIG(EBTRB_OFF);


int i =0;
bit FLAG=0;
unsigned char conv_val=0x00;


void init_spi (void) {


//----config port spi-----
    ADCON1=0x07;    //portb<4:0> as digital input
    LATC=0x00;      //clear portb & c
    LATB=0x00;
    TRISB=0x01;     //RB0(SDI) input, RB1 (SCK) output
    TRISC=0x00;   //RC7(SDO) en sortie , RC6(CS) en sortie
     .
     .
     .
     .

And here is the logg


Code:
CLEAN SUCCESSFUL (total time: 50ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/Users/safwen/MPLABXProjects/PIC18_SPI_DAC.X'
make  -f nbproject/Makefile-default.mk dist/default/production/PIC18_SPI_DAC.X.production.hex
make[2]: Entering directory `C:/Users/safwen/MPLABXProjects/PIC18_SPI_DAC.X'
"C:\Program Files (x86)\HI-TECH Software\PICC-18\9.80\bin\picc18.exe" --pass1 SPI_DAC.c  -q --chip=18F4550 -P  --outdir=build/default/production -N31 --warn=0 --runtime=default,+clear,+init,-keep,-download,+stackwarn,-config,+clib,-plib --opt=default,+asm,-asmfile,-speed,+space,9 --cp=16 -Blarge --double=24  --mode=lite -g --asmlist "--errformat=%%f:%%l: error: %%s" "--msgformat=%%f:%%l: advisory: %%s" "--warnformat=%%f:%%l warning: %%s"  
SPI_DAC.c:19 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:19 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:19 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:20 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:20 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:20 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:21 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:21 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:21 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:22 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:22 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:22 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:23 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:23 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:23 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:24 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:24 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:24 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:25 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:25 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:25 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:26 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:26 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:26 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:27 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:27 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:27 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:28 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:28 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:28 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:29 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:29 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:29 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:30 warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)
__CONFIG:30 warning: wrong number of preprocessor macro arguments for "___mkstr" (0 instead of 1)
___mkstr:30 warning: wrong number of preprocessor macro arguments for "___mkstr1" (0 instead of 1)
SPI_DAC.c:19: error: closing quote expected
SPI_DAC.c:20: error: Unknown macro ();) used in __CONFIG()
SPI_DAC.c:20: error: ")" expected
SPI_DAC.c:20: error: ";" expected
SPI_DAC.c:20: error: closing quote expected
SPI_DAC.c:21: error: closing quote expected
SPI_DAC.c:22: error: closing quote expected
SPI_DAC.c:23: error: closing quote expected
SPI_DAC.c:24: error: closing quote expected
SPI_DAC.c:25: error: closing quote expected
SPI_DAC.c:26: error: closing quote expected
SPI_DAC.c:27: error: closing quote expected
make[2]: *** [build/default/production/SPI_DAC.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
SPI_DAC.c:28: error: closing quote expected
SPI_DAC.c:29: error: closing quote expected
SPI_DAC.c:30: error: closing quote expected
make[2]: Leaving directory `C:/Users/safwen/MPLABXProjects/PIC18_SPI_DAC.X'
make[1]: Leaving directory `C:/Users/safwen/MPLABXProjects/PIC18_SPI_DAC.X'

BUILD FAILED (exit value 2, total time: 555ms)


I really need your help
thank you.
 

The legacy __CONFIG(r, v) macros require two arguments, the register number followed by the bitmask:

Example:
Code:
__CONFIG([COLOR="#FF0000"]2[/COLOR], WDTPS256 & WDTDIS & PWRTEN & BOREN & BORV42);

Which is why you are receiving the following warning message:

warning: wrong number of preprocessor macro arguments for "__CONFIG" (1 instead of 2)

BigDog
 

Hello bigdogguru and thankx for your answer but, it still dont work :/
 

Post the revised version of your code, along with the new error/warning messages.

BigDog
 

Hello everybody, i found the solution and i hope this thread will help some others.
first of all, i'm using MPLAB X with HI- TECH PICC18 PRO and the configuration bits above was generated by MPLAB.
I've carefully read the help menu and found this :
Code:
#pragma config Usage
#pragma config <setting>=<named value>
For example: 
// System Clock Postscaler Selection bits: [Primary Oscillator Src: /2][96 MHz PLL Src: /3] // PLL Prescaler Selection bits: No prescale (4 MHz oscillator input drives PLL directly) // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1): USB clock source comes directly from the primary oscillator block with no postscale #pragma config CPUDIV = OSC2_PLL3, PLLDIV = 1, USBDIV = 1

so we have to use # pragma config , i remember that Microchip C18 compiler use this to generate its onfiguration code, so i changed the compiler, generated configuration code, get back to HI TECH and compile
it works !! :=)

Code:
/// PIC18F4550 Configuration Bit Settings



// CONFIG1L
#pragma config PLLDIV = 1       // PLL Prescaler Selection bits (No prescale (4 MHz oscillator input drives PLL directly))

#pragma config CPUDIV = OSC1_PLL2// System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2])

#pragma config USBDIV = 1       // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale)


// CONFIG1H
#pragma config FOSC = HSPLL_HS  // Oscillator Selection bits (HS oscillator, PLL enabled (HSPLL))

#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)

#pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)


// CONFIG2L
#pragma config PWRT = OFF       // Power-up Timer Enable bit (PWRT disabled)

#pragma config BOR = OFF        // Brown-out Reset Enable bits (Brown-out Reset disabled in hardware and software)

#pragma config BORV = 3         // Brown-out Reset Voltage bits (Minimum setting)

#pragma config VREGEN = OFF     // USB Voltage Regulator Enable bit (USB voltage regulator disabled)


// CONFIG2H
#pragma config WDT = OFF        // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))

#pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)


// CONFIG3H
#pragma config CCP2MX = ON      // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)

#pragma config PBADEN = OFF     // PORTB A/D Enable bit (PORTB<4:0> pins are configured as digital I/O on Reset)

#pragma config LPT1OSC = OFF    // Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)

#pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)


// CONFIG4L
#pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)

#pragma config LVP = ON         // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)

#pragma config ICPRT = OFF      // Dedicated In-Circuit Debug/Programming Port (ICPORT) Enable bit (ICPORT disabled)

#pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))


// CONFIG5L
#pragma config CP0 = OFF        // Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)

#pragma config CP1 = OFF        // Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)

#pragma config CP2 = OFF        // Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)

#pragma config CP3 = OFF        // Code Protection bit (Block 3 (006000-007FFFh) is not code-protected)


// CONFIG5H
#pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)

#pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)


// CONFIG6L
#pragma config WRT0 = OFF       // Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)

#pragma config WRT1 = OFF       // Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)

#pragma config WRT2 = OFF       // Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)

#pragma config WRT3 = OFF       // Write Protection bit (Block 3 (006000-007FFFh) is not write-protected)


// CONFIG6H
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)

#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)

#pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)


// CONFIG7L
#pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)

#pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)

#pragma config EBTR2 = OFF      // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)

#pragma config EBTR3 = OFF      // Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)


// CONFIG7H
#pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)
 

As I indicated in my previous reply, the __CONFIG(r, v) macros are LEGACY, however they still can be used if configured properly.

The #pragma config, is the newer format and preferred method.


BigDog
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top