Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Configuration Bit Settings not workin mplab-x

Help
2012-11-05
2013-03-12
  • alexrlopez86
    alexrlopez86
    2012-11-05

    code:
    #include <pic16f873.h>
    #include <delay.c>
    code char at __CONFIG CONFIG = FOSC_HS & WDTE_ON & PWRTE_OFF & CP_OFF & BOREN_ON & LVP_ON & CPD_OFF & WRT_ON

    void main(void) {

    PORTA = 0;
    PORTB = 0;
    TRISB = 0;

    while(1) {
    unsigned char i;

    for(i = 0; i < 0xff; i++) {
    PORTB = i ;
    delay_ms(1000);//PORTB = check();
    PORTB = 0 ;
    delay_ms(1000);//PORTB = check();
    }
    }
    }

    error:

    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    make: se ingresa al directorio «/home/alex/MPLABXProjects/alex.X»
    make  -f nbproject/Makefile-default.mk dist/default/production/alex.X.production.hex
    make: se ingresa al directorio «/home/alex/MPLABXProjects/alex.X»
    mkdir -p build/default/production/_ext/1226298417
    rm -f  build/default/production/_ext/1226298417/ejerext2.o
    "/usr/local/bin/sdcc" -debug-ralloc -use-non-free -pstack-model=small -c -mpic14 -p16f877 ../../sdcc\ ejercicios/ejerext2.c  -obuild/default/production/_ext/1226298417/ejerext2.o
    make: se sale del directorio «/home/alex/MPLABXProjects/alex.X»
    make: se sale del directorio «/home/alex/MPLABXProjects/alex.X»
    at 1: warning 117: unknown compiler option '-debug-ralloc' ignored
    at 1: warning 117: unknown compiler option '-pstack-model=small' ignored
    ../../sdcc ejercicios/ejerext2.c:3: syntax error: token -> 'char' ; column 9
    make: ***  Error 1
    make: ***  Error 2
    make: ***  Error 2

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

    and tried to change this

    code char at __CONFIG CONFIG = FOSC_HS & WDTE_ON & PWRTE_OFF & CP_OFF & BOREN_ON & LVP_ON & CPD_OFF & WRT_ON

    by

    unsigned int at (0x2007) __CONFIG = _WDT_OFF & _CP_OFF & _XT_OSC;

    keeps crashing

     
  • Raphael Neider
    Raphael Neider
    2012-11-05

    Well, it doesn't crash exactly … Anyways, please try

    __code char __at (__CONFIG) cfg0 = FOSC_HS & WDTE_ON & PWRTE_OFF & CP_OFF & BOREN_ON & LVP_ON & CPD_OFF & WRT_ON;
    

    Changes:
    1. "code => __code" (two leading underscores)
    2. "at X => __at(X)" (two leading underscores, function-like syntax)
    3. symbol renamed to guaranteed non-clashing name
    4. semicolon added

    Not sure, but if config words are more than 8 bits, you might want to change "char" into "short" or something. I think the data type is actually ignored here, but might be worth a try anyway.

    Hope that helps
    Raphael

     
  • alexrlopez86
    alexrlopez86
    2012-11-05

    code:

    #include <pic16f873.h>
    #include <delay.c>

    __code char __at (__CONFIG) cfg0 = FOSC_HS & WDTE_ON & PWRTE_OFF & CP_OFF & BOREN_ON & LVP_ON & CPD_OFF & WRT_ON;

    void main(void) {

    PORTA = 0;
    PORTB = 0;
    TRISB = 0;

    while(1) {
    unsigned char i;

    for(i = 0; i < 0xff; i++) {
    PORTB = i ;
    delay_ms(1000);//PORTB = check();
    PORTB = 0 ;
    delay_ms(1000);//PORTB = check();
    }
    }
    }

    error generated:

    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    at 1: warning 117: unknown compiler option '-debug-ralloc' ignored
    at 1: warning 117: unknown compiler option '-pstack-model=small' ignored
    make: se ingresa al directorio «/home/alex/MPLABXProjects/alex.X»
    ../../sdcc ejercicios/ejerext2.c:5: error 20: Undefined identifier '__CONFIG'
    ../../sdcc ejercicios/ejerext2.c:5: error 2: Initializer element is not constant

    make: ***  Error 1
    make: ***  Error 2
    make: ***  Error 2
    make  -f nbproject/Makefile-default.mk dist/default/production/alex.X.production.hex
    make: se ingresa al directorio «/home/alex/MPLABXProjects/alex.X»
    mkdir -p build/default/production/_ext/1226298417
    rm -f  build/default/production/_ext/1226298417/ejerext2.o
    "/usr/local/bin/sdcc" -debug-ralloc -use-non-free -pstack-model=small -c -mpic14 -p16f877 ../../sdcc\ ejercicios/ejerext2.c  -obuild/default/production/_ext/1226298417/ejerext2.o
    make: se sale del directorio «/home/alex/MPLABXProjects/alex.X»
    make: se sale del directorio «/home/alex/MPLABXProjects/alex.X»

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

     
  • Raphael Neider
    Raphael Neider
    2012-11-05

    Well, as you found out, __CONFIG is not defined. Either
    #define __CONFIG 0x2007
    (prior to defining the config bits) or replace "__at(__CONFIG)" directly with "__at(0x2007)" as you did in your first post - this is assuming that 0x2007 is the address of the config bits on the target device.

    Have fun
    Raphael

     
  • alexrlopez86
    alexrlopez86
    2012-11-05

    code:
    #include <pic16f873.h>
    #include <delay.c>
    **#define __CONFIG 0x2007

    __code char __at (__CONFIG) cfg0 = FOSC_HS & WDTE_ON & PWRTE_OFF & CP_OFF & BOREN_ON & LVP_ON & CPD_OFF & WRT_ON;**

    void main(void) {

    PORTA = 0;
    PORTB = 0;
    TRISB = 0;

    while(1) {
    unsigned char i;

    for(i = 0; i < 0xff; i++) {
    PORTB = i ;
    delay_ms(1000);//PORTB = check();
    PORTB = 0 ;
    delay_ms(1000);//PORTB = check();
    }
    }
    }

    error generated:
    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    make: se ingresa al directorio «/home/alex/MPLABXProjects/alex.X»
    make  -f nbproject/Makefile-default.mk dist/default/production/alex.X.production.hex
    at 1: warning 117: unknown compiler option '-debug-ralloc' ignored
    at 1: warning 117: unknown compiler option '-pstack-model=small' ignored

    ../../sdcc ejercicios/ejerext2.c:6: syntax error: token -> ';' ; column 25
    make: se ingresa al directorio «/home/alex/MPLABXProjects/alex.X»
    mkdir -p build/default/production/_ext/1226298417
    make: ***  Error 1
    rm -f  build/default/production/_ext/1226298417/ejerext2.o
    "/usr/local/bin/sdcc" -debug-ralloc -use-non-free -pstack-model=small -c -mpic14 -p16f877 ../../sdcc\ ejercicios/ejerext2.c  -obuild/default/production/_ext/1226298417/ejerext2.o
    make: ***  Error 2
    make: se sale del directorio «/home/alex/MPLABXProjects/alex.X»
    make: ***  Error 2
    make: se sale del directorio «/home/alex/MPLABXProjects/alex.X»

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

     
  • alexrlopez86
    alexrlopez86
    2012-11-05

    copy my mistake wrong thing
    error generated:

    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    make: se ingresa al directorio «/home/alex/MPLABXProjects/alex.X»
    make  -f nbproject/Makefile-default.mk dist/default/production/alex.X.production.hex
    at 1: warning 117: unknown compiler option '-debug-ralloc' ignored
    at 1: warning 117: unknown compiler option '-pstack-model=small' ignored
    ../../sdcc ejercicios/ejerext2.c:6: error 20: Undefined identifier 'FOSC_HS'
    ../../sdcc ejercicios/ejerext2.c:6: error 20: Undefined identifier 'WDTE_ON'
    ../../sdcc ejercicios/ejerext2.c:6: error 20: Undefined identifier 'PWRTE_OFF'
    ../../sdcc ejercicios/ejerext2.c:6: error 20: Undefined identifier 'CP_OFF'
    ../../sdcc ejercicios/ejerext2.c:6: error 20: Undefined identifier 'BOREN_ON'
    ../../sdcc ejercicios/ejerext2.c:6: error 20: Undefined identifier 'LVP_ON'
    ../../sdcc ejercicios/ejerext2.c:6: error 20: Undefined identifier 'CPD_OFF'
    make: se ingresa al directorio «/home/alex/MPLABXProjects/alex.X»
    mkdir -p build/default/production/_ext/1226298417
    rm -f  build/default/production/_ext/1226298417/ejerext2.o
    "/usr/local/bin/sdcc" -debug-ralloc -use-non-free -pstack-model=small -c -mpic14 -p16f877 ../../sdcc\ ejercicios/ejerext2.c  -obuild/default/production/_ext/1226298417/ejerext2.o
    make: se sale del directorio «/home/alex/MPLABXProjects/alex.X»
    make: se sale del directorio «/home/alex/MPLABXProjects/alex.X»
    ../../sdcc ejercicios/ejerext2.c:6: error 20: Undefined identifier 'WRT_ON'
    ../../sdcc ejercicios/ejerext2.c:6: error 2: Initializer element is not constant
    make: ***  Error 1
    make: ***  Error 2
    make: ***  Error 2

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

     
  • alexrlopez86
    alexrlopez86
    2012-11-05

    bad actually in proteus well 20mhz
    running code:
    #include <pic16f873.h>
    #include <delay.c>
    #define __CONFIG 0x2007

    __code short __at (__CONFIG) cfg0 = _HS_OSC & _WDT_OFF & _PWRTE_OFF & _CP_OFF & _LVP_ON & _CPD_OFF;

    void main(void) {

    PORTA = 0;
    PORTB = 0;
    TRISB = 0;

    while(1) {
    unsigned char i;

    for(i = 0; i < 0xff; i++) {
    PORTB = i ;
    delay_ms(1000);//PORTB = check();
    PORTB = 0 ;
    delay_ms(1000);//PORTB = check();
    }
    }
    }