Device configuration

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

Re: Device configuration

Postby Dimebag » Sun Jul 27, 2014 1:48 pm

Again, my failure to understand Rick,
Sorry if I am a pain. I just don't get it yet.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Sun Jul 27, 2014 1:49 pm

I am pretty confident that you ARE using XC8.
Now, please stop just saying "it's not working", and actually describe what you have done, and what happened that makes you think it's not working.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Device configuration

Postby Dimebag » Sun Jul 27, 2014 2:03 pm

__delay_ms() said it is Not Recognised.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Sun Jul 27, 2014 2:05 pm

Where is it saying "not recognised" ?
In the editor, in the build log when you compile, or somewhere else?

Please show your ENTIRE source code, and the output from the compiler.
Last edited by ric on Mon Jul 28, 2014 1:21 am, edited 1 time in total.
Reason: expanded the questions
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Device configuration

Postby Dimebag » Mon Jul 28, 2014 2:03 pm

Ok I dump files.
Code: Select all
#include <xc.h>

#define __delay_ms();
#define  _XTAL_FREQ = 20000000;
//Configurations and Fuses
#pragma config  OSC = HS, OSCS = OFF,PWRT = ON,BOR = OFF
#pragma config  BORV = 45,WDT = OFF,WDTPS = 1,CCP2MUX = OFF
#pragma config  STVR = OFF,LVP = OFF,DEBUG = OFF
#pragma config  CP0 = OFF,CP1 = OFF,CP2 = OFF,CP3 = OFF,CPB = OFF,CPD = OFF
#pragma config WRT0 = OFF,WRT1 = OFF,WRT2 = OFF,WRT3 = OFF,WRTB = OFF,WRTC = OFF,WRTD = OFF
#pragma config EBTR0 = OFF,EBTR1 = OFF,EBTR2 = OFF,EBTR3 = OFF,EBTRB = OFF

//PORTB pins.
int delayselect[9] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
//Timer values.
char offset[20] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
    0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};

//char temp = 1;
int temp = 0;
int inside = 0;
int outside = 0;
int scanPin = 600;
int DelayA = 580;
int DelayB = 32;

void Initialization(void) {
    LATA = 0x00;
    LATB = 0X00;
    LATC = 0X00;
    LATD = 0X00;
    LATE = 0X00;

    TRISA = 0x00;
    TRISB = 0x00;
    TRISC = 0x00;
    TRISD = 0x00;
    TRISE = 0x00;

    PORTA = 0x00;
    PORTB = 0x00;
    PORTC = 0x00;
    PORTD = 0x00;
    PORTE = 0x00;
}

void delay1ms(void) {
    //1ms
    int ms1_time = 109; //1.659ms
    //int ms_time = 2;

    for (inside = 0; inside < ms1_time; inside++) {
        //       for (outside = 0; outside < temp; outside++) {
        //      }
    }
}

void delayA(void) {
    //18ms
    for (inside = 0; inside < DelayA; inside++) {
        for (outside = 0; outside < temp; outside++) {
        }
    }
}

void delayB(void) {
    //2us
    for (inside = 0; inside < DelayB; inside++) {
        for (outside = 0; outside < temp; outside++) {
        }
    }
}

void delay1second(void) {

    int DelaySec = 9174; //9174
    //999.994ms
    int Delay1Sec = 6; //6

    for (inside = 0; inside < DelaySec; inside++) {
        for (outside = 0; outside < Delay1Sec; outside++) {
        }
    }
}

void main(void) {

    Initialization(); //Set all device pins.

    while (1) {

        __delay_ms(1000); // delay1second();
        PORTD = 0x01; // array[0];
        __delay_ms(1000); //delay1second();
        PORTD = 0x00;
    }
}

 

Output:
Code: Select all
CLEAN SUCCESSFUL (total time: 977ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/MPLABXProjects/Blinker.X'
make  -f nbproject/Makefile-default.mk dist/default/production/Blinker.X.production.hex
make[2]: Entering directory 'D:/MPLABXProjects/Blinker.X'
"C:\Program Files\Microchip\xc8\v1.32\bin\xc8.exe" --pass1  --chip=18F452 -Q -G  --double=24 --float=24 --emi=wordwrite --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s"    -obuild/default/production/BlinkLED.p1  BlinkLED.c
BlinkLED.c:3: warning: (111) redefining preprocessor macro "__delay_ms" (C:\Program Files\Microchip\xc8\v1.32\include\pic18.h: 154)
BlinkLED.c:92: warning: (171) wrong number of preprocessor macro arguments for "__delay_ms" (1 instead of 0)
BlinkLED.c:94: warning: (171) wrong number of preprocessor macro arguments for "__delay_ms" (1 instead of 0)
"C:\Program Files\Microchip\xc8\v1.32\bin\xc8.exe"  --chip=18F452 -G -mdist/default/production/Blinker.X.production.map  --double=24 --float=24 --emi=wordwrite --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s"     -odist/default/production/Blinker.X.production.elf  build/default/production/BlinkLED.p1     
Microchip MPLAB XC8 C Compiler (Free Mode) V1.32
Part Support Version: 1.32 (A)
Copyright (C) 2014 Microchip Technology Inc.
License type: Node Configuration

:: advisory: (1233) Employing 18F452 errata work-arounds:
:: advisory: (1234)  * Address 4000h boundary
:: advisory: (1234)  * Faulty table reads at -40 degrees C
:: advisory: (1234)  * GOTO instruction at reset vector must be preceded by NOP
:: advisory: (1234)  * Peripherals can misbehave if BSR = 15
:: advisory: (1234)  * DAW instruction may improperly clear CARRY bit
:: advisory: (1234)  * Specifically disable interrupt sources during tblwt instruction
:: advisory: (1234)  * Writes to flash must target opposite side of 4000h boundary
:: warning: (1273) Omniscient Code Generation not available in Free mode

Memory Summary:
    Program space        used    BAh (   186) of  8000h bytes   (  0.6%)
    Data space           used    32h (    50) of   600h bytes   (  3.3%)
    Configuration bits   used     7h (     7) of     7h words   (100.0%)
    EEPROM space         used     0h (     0) of   100h bytes   (  0.0%)
    ID Location space    used     8h (     8) of     8h bytes   (100.0%)
    Data stack space     used     0h (     0) of   580h bytes   (  0.0%)

Running this compiler in PRO mode, with Omniscient Code Generation enabled,
often produces code which is 60% smaller and at least 400% faster than in
Free mode. The MPLAB XC8 PRO compiler output for this code could be
75 bytes smaller and run 4 times faster.
See http://www.microchip.com for more information.

make[2]: Leaving directory 'D:/MPLABXProjects/Blinker.X'
make[1]: Leaving directory 'D:/MPLABXProjects/Blinker.X'

BUILD SUCCESSFUL (total time: 8s)
Loading code from D:/MPLABXProjects/Blinker.X/dist/default/production/Blinker.X.production.hex...
Loading completed
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Dimebag » Mon Jul 28, 2014 2:08 pm

I am not sure it provides extra information, I just dumped it. Rick after your input to the thread, I am now researching more a about variables. I forgot PORTd is the PORTx, TRISx, pin set.
Last edited by Dimebag on Mon Jul 28, 2014 2:13 pm, edited 1 time in total.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Mon Jul 28, 2014 2:13 pm

You still have the
#define __delay_ms();
line that I asked you to remove.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Device configuration

Postby Dimebag » Mon Jul 28, 2014 2:20 pm

I get this
Code: Select all
BlinkLED.c:92: warning: (171) wrong number of preprocessor macro arguments for "__delay_ms" (1 instead of 0)
BlinkLED.c:94: warning: (171) wrong number of preprocessor macro arguments for "__delay_ms" (1 instead of 0)


Everytime I use macro __delay_ms() I get warnings, but no information on it. I am getting frustrated with this macro.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Mon Jul 28, 2014 2:30 pm

You got those errors because you hadn't removed the line I keep telling you to remove.
Your line replaced the compiler provided macro with your own empty one, causing those errors.

I also just noticed a second error in your source.
Code: Select all
#define  _XTAL_FREQ = 20000000;

should be
Code: Select all
#define  _XTAL_FREQ 20000000

Don't use "=" in a "#define" statement, and never put a ";" on the end.


Try this complete version:
Code: Select all
#include <xc.h>

#define  _XTAL_FREQ 20000000

//Configurations and Fuses
#pragma config  OSC = HS, OSCS = OFF,PWRT = ON,BOR = OFF
#pragma config  BORV = 45,WDT = OFF,WDTPS = 1,CCP2MUX = OFF
#pragma config  STVR = OFF,LVP = OFF,DEBUG = OFF
#pragma config  CP0 = OFF,CP1 = OFF,CP2 = OFF,CP3 = OFF,CPB = OFF,CPD = OFF
#pragma config WRT0 = OFF,WRT1 = OFF,WRT2 = OFF,WRT3 = OFF,WRTB = OFF,WRTC = OFF,WRTD = OFF
#pragma config EBTR0 = OFF,EBTR1 = OFF,EBTR2 = OFF,EBTR3 = OFF,EBTRB = OFF

//PORTB pins.
int delayselect[9] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
//Timer values.
char offset[20] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
    0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};

//char temp = 1;
int temp = 0;
int inside = 0;
int outside = 0;
int scanPin = 600;
int DelayA = 580;
int DelayB = 32;

void Initialization(void) {
    LATA = 0x00;
    LATB = 0X00;
    LATC = 0X00;
    LATD = 0X00;
    LATE = 0X00;

    TRISA = 0x00;
    TRISB = 0x00;
    TRISC = 0x00;
    TRISD = 0x00;
    TRISE = 0x00;
}

void main(void) {

    Initialization(); //Set all device pins.

    while (1) {
        __delay_ms(1000); // delay1second();
        LATD = 0x01; // array[0];
        __delay_ms(1000); //delay1second();
        LATD = 0x00;
    }
}

 
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Device configuration

Postby ric » Mon Jul 28, 2014 2:42 pm

Also note, both of these mistakes were pointed out to you by user2009 nearly a week ago
viewtopic.php?p=676#p676
but you told him to piss off because he suggested you read a basic C textbook...
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

PreviousNext

Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 11 guests

cron