Again, my failure to understand Rick,
Sorry if I am a pain. I just don't get it yet.
#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;
}
}
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
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)
#define _XTAL_FREQ = 20000000;
#define _XTAL_FREQ 20000000
#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;
}
}
Users browsing this forum: No registered users and 1 guest