Simulare l'alba e il tramonto
Moderatore:
Paolino
0
voti
ti ringrazio.. Io ho sostemato ancora meglio il PIC diminuendo a pochissime micro piste
1
voti
Allora, ecco qui una bozza:
Per verificare questo codice dovrai avviare un progetto con MPLABX IDE e farlo compilare con XC8. A questo punto, una volta compilato e trasferito, su RB1 c'è un'onda quadra con periodo 1s. Lo devi verificare con il tester.
Prova.
Ciao.
Paolo.
P.S. Poi ci facciamo un articolo, ok?
- Codice: Seleziona tutto
#include <xc.h>
/* Configuration bits */
#pragma config OSC = INTIO1, LVP = OFF, MCLRE = ON, WDT = OFF, IESO = OFF, PWRT = ON
/* Macros */
#define ON 1
#define OFF 0
#define TRUE 1
#define FALSE 0
#define GATE LATBbits.LATB1
/* Global variables */
int TrimmerValue;
/* Function prototypes */
void InitPic(void);
int ReadTrimmer (void);
void interrupt ISR (void)
{
if (TMR1IF == ON)
{
TMR1H = 0x7F;
GATE ^=1;
TMR1IF = 0;
}
}
void main (void)
{
InitPic ();
while(1)
{
}
}
void InitPic(void)
{
/* OSCILLATOR: internal oscillator at 8 MHz */
OSCCON = 0xF0;
/* PORT I/O configuration */
TRISA = 0xFF;
TRISB = 0xFD;
/* A/D converter configuration */
ADCON1 = 0xFE;
ADCON0bits.ADON = ON;
/* Interrupts */
RCONbits.IPEN = ON;
INTCONbits.INT0IE = ON;
PIE1bits.TMR1IE = ON;
INTCONbits.GIEH = 1;
}
Per verificare questo codice dovrai avviare un progetto con MPLABX IDE e farlo compilare con XC8. A questo punto, una volta compilato e trasferito, su RB1 c'è un'onda quadra con periodo 1s. Lo devi verificare con il tester.
Prova.
Ciao.
Paolo.
P.S. Poi ci facciamo un articolo, ok?
"Houston, Tranquillity Base here. The Eagle has landed." - Neil A.Armstrong
-------------------------------------------------------------
PIC Experience - http://www.picexperience.it
-------------------------------------------------------------
PIC Experience - http://www.picexperience.it
-

Paolino
32,6k 8 12 13 - G.Master EY

- Messaggi: 4226
- Iscritto il: 20 gen 2006, 11:42
- Località: Vigevano (PV)
1
voti
Correggi la InitPic così:
Ciao.
Paolo.
- Codice: Seleziona tutto
void InitPic(void)
{
/* OSCILLATOR: internal oscillator at 8 MHz */
OSCCON = 0xF0;
/* PORT I/O configuration */
TRISA = 0xFF;
TRISB = 0xFD;
/* A/D converter configuration */
ADCON1 = 0xFE;
ADCON0bits.ADON = ON;
/* TIMER 1 setup */
T1CON = 0x0F;
TMR1H = 0x80;
TMR1L = 0x00;
/* Interrupts */
RCONbits.IPEN = ON;
INTCONbits.INT0IE = ON;
PIE1bits.TMR1IE = ON;
INTCONbits.GIEH = ON;
}
Ciao.
Paolo.
"Houston, Tranquillity Base here. The Eagle has landed." - Neil A.Armstrong
-------------------------------------------------------------
PIC Experience - http://www.picexperience.it
-------------------------------------------------------------
PIC Experience - http://www.picexperience.it
-

Paolino
32,6k 8 12 13 - G.Master EY

- Messaggi: 4226
- Iscritto il: 20 gen 2006, 11:42
- Località: Vigevano (PV)
0
voti
Ciao paolino pure usando il programma da te indicato una volta creato il nuovo progetto, e durante la compilazione escono una serie di errori come mai:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/MPLABXProjects/alba-tramonto.X'
make -f nbproject/Makefile-default.mk dist/default/production/alba-tramonto.X.production.hex
make[2]: Entering directory `C:/MPLABXProjects/alba-tramonto.X'
"C:\Program Files\Microchip\xc8\v1.12\bin\xc8.exe" --pass1 --chip=18F1320 -Q -G --asmlist --double=24 --float=24 --emi=wordwrite --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -obuild/default/production/_ext/43898991/alba-tramonto.p1 ../../alba-tramonto.c
../../alba-tramonto.c:4: error: undefined identifier "OSCCON"
../../alba-tramonto.c:7: error: undefined identifier "TRISA"
../../alba-tramonto.c:8: error: undefined identifier "TRISB"
../../alba-tramonto.c:11: error: undefined identifier "ADCON1"
../../alba-tramonto.c:12: error: undefined identifier "ADCON0bits"
../../alba-tramonto.c:12: error: struct/union required
../../alba-tramonto.c:12: error: undefined identifier "ON"
../../alba-tramonto.c:15: error: undefined identifier "T1CON"
../../alba-tramonto.c:16: error: undefined identifier "TMR1H"
../../alba-tramonto.c:17: error: undefined identifier "TMR1L"
../../alba-tramonto.c:20: error: undefined identifier "RCONbits"
../../alba-tramonto.c:20: error: struct/union required
../../alba-tramonto.c:21: error: undefined identifier "INTCONbits"
../../alba-tramonto.c:21: error: struct/union required
../../alba-tramonto.c:22: error: undefined identifier "PIE1bits"
../../alba-tramonto.c:22: error: struct/union required
../../alba-tramonto.c:24: error: struct/union required
make[2]: Leaving directory `C:/MPLABXProjects/alba-tramonto.X'
(908) exit status = 1
make[2]: *** [build/default/production/_ext/43898991/alba-tramonto.p1] Error 1
make[1]: Leaving directory `C:/MPLABXProjects/alba-tramonto.X'
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 3s)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/MPLABXProjects/alba-tramonto.X'
make -f nbproject/Makefile-default.mk dist/default/production/alba-tramonto.X.production.hex
make[2]: Entering directory `C:/MPLABXProjects/alba-tramonto.X'
"C:\Program Files\Microchip\xc8\v1.12\bin\xc8.exe" --pass1 --chip=18F1320 -Q -G --asmlist --double=24 --float=24 --emi=wordwrite --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -obuild/default/production/_ext/43898991/alba-tramonto.p1 ../../alba-tramonto.c
../../alba-tramonto.c:4: error: undefined identifier "OSCCON"
../../alba-tramonto.c:7: error: undefined identifier "TRISA"
../../alba-tramonto.c:8: error: undefined identifier "TRISB"
../../alba-tramonto.c:11: error: undefined identifier "ADCON1"
../../alba-tramonto.c:12: error: undefined identifier "ADCON0bits"
../../alba-tramonto.c:12: error: struct/union required
../../alba-tramonto.c:12: error: undefined identifier "ON"
../../alba-tramonto.c:15: error: undefined identifier "T1CON"
../../alba-tramonto.c:16: error: undefined identifier "TMR1H"
../../alba-tramonto.c:17: error: undefined identifier "TMR1L"
../../alba-tramonto.c:20: error: undefined identifier "RCONbits"
../../alba-tramonto.c:20: error: struct/union required
../../alba-tramonto.c:21: error: undefined identifier "INTCONbits"
../../alba-tramonto.c:21: error: struct/union required
../../alba-tramonto.c:22: error: undefined identifier "PIE1bits"
../../alba-tramonto.c:22: error: struct/union required
../../alba-tramonto.c:24: error: struct/union required
make[2]: Leaving directory `C:/MPLABXProjects/alba-tramonto.X'
(908) exit status = 1
make[2]: *** [build/default/production/_ext/43898991/alba-tramonto.p1] Error 1
make[1]: Leaving directory `C:/MPLABXProjects/alba-tramonto.X'
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 3s)
0
voti
paolino mi poi spiegare precisamente come fare a generare il file correttamente e poi caricarlo sul PIC??
0
voti
Paolino mi poi spiegare precisamente come fare a generare il file correttamente e poi caricarlo sul PIC??" "Cortesemente, puoi indicarmi dove sta l'errore e come fare per generare correttamente il file .hex?"
1
voti
Ma hai specificato che il progetto è per PIC18F1320?
"Houston, Tranquillity Base here. The Eagle has landed." - Neil A.Armstrong
-------------------------------------------------------------
PIC Experience - http://www.picexperience.it
-------------------------------------------------------------
PIC Experience - http://www.picexperience.it
-

Paolino
32,6k 8 12 13 - G.Master EY

- Messaggi: 4226
- Iscritto il: 20 gen 2006, 11:42
- Località: Vigevano (PV)
1
voti
Sembra che ti manchi qualche parte nel codice...
Il codice sorgente lo devi copiare TUTTO dal questo post
Poi, la funzione InitPic() la modifichi come descritto qui
Ciao.
Paolo.
Il codice sorgente lo devi copiare TUTTO dal questo post
Poi, la funzione InitPic() la modifichi come descritto qui
Ciao.
Paolo.
"Houston, Tranquillity Base here. The Eagle has landed." - Neil A.Armstrong
-------------------------------------------------------------
PIC Experience - http://www.picexperience.it
-------------------------------------------------------------
PIC Experience - http://www.picexperience.it
-

Paolino
32,6k 8 12 13 - G.Master EY

- Messaggi: 4226
- Iscritto il: 20 gen 2006, 11:42
- Località: Vigevano (PV)
0
voti
Paolino sto da oggi pomeriggio che mi sto scervellando ma escono sempre dei errori:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/alba-tramonto.X'
make -f nbproject/Makefile-default.mk dist/default/production/alba-tramonto.X.production.hex
make[2]: Entering directory `C:/alba-tramonto.X'
"C:\Program Files\Microchip\xc8\v1.12\bin\xc8.exe" --pass1 --chip=18F1320 -Q -G --asmlist --double=24 --float=24 --emi=wordwrite --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -obuild/default/production/nbproject/alba-tramonto.p1 nbproject/alba-tramonto.c
(908) exit status = 1
nbproject/alba-tramonto.c:43: error: attempt to reprogram configuration setting "PWRT" with OFF (is ON)
nbproject/alba-tramonto.c:61: error: conflicting declarations for variable "ISR" (nbproject/alba-tramonto.c:61)
make[2]: Leaving directory `C:/alba-tramonto.X'
make[1]: Leaving directory `C:/alba-tramonto.X'
make[2]: *** [build/default/production/nbproject/alba-tramonto.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
Gli dici che hai provato anche MPLAB 8.x con XC8 e hai quest'altro errore:
Build C:\alba-tramonto for device 18F1320
Using driver C:\Program Files\Microchip\xc8\v1.12\bin\xc8.exe
Make: The target "C:\alba-tramonto.p1" is out of date.
Executing: "C:\Program Files\Microchip\xc8\v1.12\bin\xc8.exe" --pass1 C:\alba-tramonto.c -q --chip=18F1320 -P --runtime=default --opt=default -N-1 -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [1389] C:\alba-tramonto.c; 43.1 attempt to reprogram configuration setting "PWRT" with OFF (is ON)
Error [1098] C:\alba-tramonto.c; 61.1 conflicting declarations for variable "ISR" (C:\alba-tramonto.c:61)
(908) exit status = 1
********** Build failed! **********
Mica posso uilizzare MPLAB 8.x che è più semplice e lo conosco un po'???
Scusami se ti sto creando solo disturbo Paolino
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/alba-tramonto.X'
make -f nbproject/Makefile-default.mk dist/default/production/alba-tramonto.X.production.hex
make[2]: Entering directory `C:/alba-tramonto.X'
"C:\Program Files\Microchip\xc8\v1.12\bin\xc8.exe" --pass1 --chip=18F1320 -Q -G --asmlist --double=24 --float=24 --emi=wordwrite --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -obuild/default/production/nbproject/alba-tramonto.p1 nbproject/alba-tramonto.c
(908) exit status = 1
nbproject/alba-tramonto.c:43: error: attempt to reprogram configuration setting "PWRT" with OFF (is ON)
nbproject/alba-tramonto.c:61: error: conflicting declarations for variable "ISR" (nbproject/alba-tramonto.c:61)
make[2]: Leaving directory `C:/alba-tramonto.X'
make[1]: Leaving directory `C:/alba-tramonto.X'
make[2]: *** [build/default/production/nbproject/alba-tramonto.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
Gli dici che hai provato anche MPLAB 8.x con XC8 e hai quest'altro errore:
Build C:\alba-tramonto for device 18F1320
Using driver C:\Program Files\Microchip\xc8\v1.12\bin\xc8.exe
Make: The target "C:\alba-tramonto.p1" is out of date.
Executing: "C:\Program Files\Microchip\xc8\v1.12\bin\xc8.exe" --pass1 C:\alba-tramonto.c -q --chip=18F1320 -P --runtime=default --opt=default -N-1 -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [1389] C:\alba-tramonto.c; 43.1 attempt to reprogram configuration setting "PWRT" with OFF (is ON)
Error [1098] C:\alba-tramonto.c; 61.1 conflicting declarations for variable "ISR" (C:\alba-tramonto.c:61)
(908) exit status = 1
********** Build failed! **********
Mica posso uilizzare MPLAB 8.x che è più semplice e lo conosco un po'???
Scusami se ti sto creando solo disturbo Paolino
Torna a Firmware e programmazione
Chi c’è in linea
Visitano il forum: Nessuno e 6 ospiti

Elettrotecnica e non solo (admin)
Un gatto tra gli elettroni (IsidoroKZ)
Esperienza e simulazioni (g.schgor)
Moleskine di un idraulico (RenzoDF)
Il Blog di ElectroYou (webmaster)
Idee microcontrollate (TardoFreak)
PICcoli grandi PICMicro (Paolino)
Il blog elettrico di carloc (carloc)
DirtEYblooog (dirtydeeds)
Di tutto... un po' (jordan20)
AK47 (lillo)
Esperienze elettroniche (marco438)
Telecomunicazioni musicali (clavicordo)
Automazione ed Elettronica (gustavo)
Direttive per la sicurezza (ErnestoCappelletti)
EYnfo dall'Alaska (mir)
Apriamo il quadro! (attilio)
H7-25 (asdf)
Passione Elettrica (massimob)
Elettroni a spasso (guidob)
Bloguerra (guerra)
