Bonsoir, merci, je le fais déjà avec # avec le clavier , mais je ne vois pas où trouver la barre d'outil
-----
Bonsoir, merci, je le fais déjà avec # avec le clavier , mais je ne vois pas où trouver la barre d'outil
bonsoir, merci
Poste ton schéma que je vois déjà comment tu as câblé tout ça.
Et si tu peux faire une photo de ton montage poste la.
OK bon appétit
Remet ton programme corrigé ainsi que le résultat de la compilation (tous les messages).
Et encadre bien ton code des balises comme l'a expliqué Vincent.
Je n'ai pas de shéma, le montage est tout simple sur une plaque d'essai.
Ce qui me surprend , c'est que la led restait allumée , j'ai enlever des # <> pour ne laisser que <xc.h> ey < pic12f683> et maintenant la led ne s'allume plus
le programme:
#include <xc.h>
#include <pic12f683.h>
// Définition de la fréquence du crystal pour la fonction __delay_ms(x);
#define _XTAL_FREQ 31000
#define led GP4
// CONFIG
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF // Brown Out Detect (BOR disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#pragma interrupt
_Bool test = 0;
//void interrupt ()
//{
// if ((INTCONbits.T0IF == 1) && (INTCONbits.T0IE == 1))
// {
// TMR0 = 255 - 10;
// led =! led;
// test = 1;
// INTCONbits.T0IF = 0;
// }
//}
void main ()
{
TRISIO = 0b00000100;
ANSEL = 0b00000000;
OSCCON = 0b00000111;
// interruptions
INTCON = 0b11110010;
IOC = 0b00000100;
// timer 0
OPTION_REGbits.T0CS = 0;
OPTION_REGbits.PSA = 0;
OPTION_REGbits.PS = 0b00000111; // par 128
while (1)
{
__delay_ms(1000);
led = 0;
__delay_ms(1000);
led = 1;
}
}
le message compilation:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/Users/SIKORA/Documents/MPLAB/inter1.X'
make -f nbproject/Makefile-default.mk dist/default/production/inter1.X.production.hex
make[2]: Entering directory 'D:/Users/SIKORA/Documents/MPLAB/inter1.X'
make[2]: 'dist/default/production/inter1.X.production.hex' is up to date.
make[2]: Leaving directory 'D:/Users/SIKORA/Documents/MPLAB/inter1.X'
make[1]: Leaving directory 'D:/Users/SIKORA/Documents/MPLAB/inter1.X'
BUILD SUCCESSFUL (total time: 359ms)
Loading code from D:/Users/SIKORA/Documents/MPLAB/inter1.X/dist/default/production/inter1.X.production.hex...
Loading completed
Connecting to programmer...
Programming target...
Programming completed
Running target...
Il faudrait regarder dans la doc du compilateur.
Peut être quelque chose comme ça:
Bizarre qu'il n'y ait aucun message d'erreur...Code:int main () { TRISIO = 0b00000100; ANSEL = 0b00000000; OSCCON = 0b00000111; // interruptions INTCON = 0b11110010; IOC = 0b00000100; // timer 0 OPTION_REGbits.T0CS = 0; OPTION_REGbits.PSA = 0; OPTION_REGbits.PS = 0b00000111; // par 128 while (1) { __delay_ms(1000); led = 0; __delay_ms(1000); led = 1; } return 0; }
Et poste ton schéma
programme corrigé avec int main , pareil la led éteinte!
le shéma i.e. le cablâge ?, il faut que je le fasse sur papier? et le scanner ,
pourtant des leds clignotante j'en ai déjà fait un paquet! je comprend vraiment pas
j'ai aussi changé le port de sortie mais c'est pareil
ce serait pas l'oscillateur ? je vais changer la fréquence
j'ai changé la fréquence ( 4Mhz) et le port , c'est pareil, led éteinte!
j'ai modifié INTCON = 0b00100000 et la led fonctionne ( avant : 0b11110010)
Merci, à demain j'espère et bonne nuit
Comme tu as dévalidé la routine d'interruption mieux vaut carrément supprimer la déclaration du registre INTCON, le timer0 n'a plus d'utilité pour le moment.
Si ta led clignote bien comme ça alors maintenant tu peux réintégrer les interruptions.
Il faut charger le registre OPTION_REG de cette façon pour une base de temps à 31000 Hz et pour avoir 1s de clignotement:
Code:OPTION_REG.T0CS = 0; OPTION_REG.T0SE = 0; OPTION_REG.PSA = 0; OPTION_REG.PS2 = 1; OPTION_REG.PS1 = 0; OPTION_REG.PS0 = 0; TMR0 = 16; // le timer0 doit contenir ce préchargement pour avoir 1s
Avec ton code précédent (prescaler à 256) timer0 se déclenchait avec une période de 8s environ, c'est peut être pour cela que tu ne voyais rien, tu n'attendais peut être pas suffisamment.
Bonjour,
J'ai réécris le programme avec tes corrections ( et en vidant le while), ça ne marche pas et j'aitoujours le message interrupt non appelé.
le programme:
#include <xc.h>
#include <pic12f683.h>
// Définition de la fréquence du crystal pour la fonction __delay_ms(x);
#define _XTAL_FREQ 31000
#define led GP4
// CONFIG
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF // Brown Out Detect (BOR disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#pragma interrupt
void interrupt () {
if ((INTCONbits.T0IF == 1) && (INTCONbits.T0IE == 1))
{
TMR0 = 16;
led =~ led;
INTCONbits.T0IF = 0;
}
}
void main() {
ANSEL = 0b00000000;
TRISIO = 0b00000000;
OSCCON = 0b00000111;
//interruptions
INTCON = 0b00100000;
// timer
OPTION_REGbits.T0CS = 0;
OPTION_REGbits.T0SE = 0;
OPTION_REGbits.PSA = 0;
OPTION_REGbits.PS2 = 1;
OPTION_REGbits.PS1 = 0;
OPTION_REGbits.PS0 = 0;
TMR0 = 16; // le timer0 doit contenir ce préchargement pour avoir 1s
while (1) {
}
}
le message de compil :
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
make -f nbproject/Makefile-default.mk dist/default/production/inter2.X.production.hex
make[2]: Entering directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\ xc8-cc.exe" -mcpu=12F683 -c -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/production/main.p1 main.c
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\ xc8-cc.exe" -mcpu=12F683 -Wl,-Map=dist/default/production/inter2.X.production.map -DXPRJ_default=default -Wl,--defsym=__MPLAB_BUILD=1 -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -Wl,--memorysummary,dist/default/production/memoryfile.xml -o dist/default/production/inter2.X.production.elf build/default/production/main.p1
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
main.c:30:: warning: (520) function "_interrupt" is never called
Memory Summary:
Program space used 15h ( 21) of 800h words ( 1.0%)
Data space used 2h ( 2) of 80h bytes ( 1.6%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
Data stack space used 0h ( 0) of 50h bytes ( 0.0%)
Configuration bits used 1h ( 1) of 1h word (100.0%)
ID Location space used 0h ( 0) of 4h bytes ( 0.0%)
make[2]: Leaving directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
make[1]: Leaving directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
BUILD SUCCESSFUL (total time: 19s)
Loading code from D:/Users/SIKORA/Documents/MPLAB/inter2.X/dist/default/production/inter2.X.production.hex...
Loading completed
Connecting to programmer...
Programming target...
Programming completed
Running target...
j'ai un petit souci avec ma chaudière (il fait froid dans le Nord).
Je continue nos échanges un peu plus tard
Ok,
essaye de déclarer la routine d'interruption ainsi:
@+Code:void interrupt my_isr(void)
j'ai réécris le programme avec tes corrections et "vidé" le while , ça ne marche pas, la led reste allumée au lieu de clignoter et le même message interupt non appelé.
Le programme:
#include <xc.h>
#include <pic12f683.h>
// Définition de la fréquence du crystal pour la fonction __delay_ms(x);
#define _XTAL_FREQ 31000
#define led GP4
// CONFIG
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF // Brown Out Detect (BOR disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#pragma interrupt
void interrupt () {
if ((INTCONbits.T0IF == 1) && (INTCONbits.T0IE == 1))
{
TMR0 = 16;
led =~ led;
INTCONbits.T0IF = 0;
}
}
void main() {
ANSEL = 0b00000000;
TRISIO = 0b00000000;
OSCCON = 0b00000111;
//interruptions
INTCON = 0b00100000;
// timer
OPTION_REGbits.T0CS = 0;
OPTION_REGbits.T0SE = 0;
OPTION_REGbits.PSA = 0;
OPTION_REGbits.PS2 = 1;
OPTION_REGbits.PS1 = 0;
OPTION_REGbits.PS0 = 0;
TMR0 = 16; // le timer0 doit contenir ce préchargement pour avoir 1s
while (1) {
}
}
le message de compil:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
make -f nbproject/Makefile-default.mk dist/default/production/inter2.X.production.hex
make[2]: Entering directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\ xc8-cc.exe" -mcpu=12F683 -c -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/production/main.p1 main.c
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\ xc8-cc.exe" -mcpu=12F683 -Wl,-Map=dist/default/production/inter2.X.production.map -DXPRJ_default=default -Wl,--defsym=__MPLAB_BUILD=1 -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -Wl,--memorysummary,dist/default/production/memoryfile.xml -o dist/default/production/inter2.X.production.elf build/default/production/main.p1
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
main.c:30:: warning: (520) function "_interrupt" is never called
Memory Summary:
Program space used 15h ( 21) of 800h words ( 1.0%)
Data space used 2h ( 2) of 80h bytes ( 1.6%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
Data stack space used 0h ( 0) of 50h bytes ( 0.0%)
Configuration bits used 1h ( 1) of 1h word (100.0%)
ID Location space used 0h ( 0) of 4h bytes ( 0.0%)
make[2]: Leaving directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
make[1]: Leaving directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
BUILD SUCCESSFUL (total time: 9s)
Loading code from D:/Users/SIKORA/Documents/MPLAB/inter2.X/dist/default/production/inter2.X.production.hex...
Loading completed
Connecting to programmer...
Programming target...
Programming completed
Running target...
Remplace ce que tu as écrit pour la routine d'interruption par:
Ca devrait supprimer ton warning et fonctionner.Code:void __interrupt () my_isr_routine (void) { if ((INTCONbits.T0IF == 1) && (INTCONbits.T0IE == 1)) { TMR0 = 16; led =~ led; INTCONbits.T0IF = 0; }
marche pas, message de compil:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
make -f nbproject/Makefile-default.mk dist/default/production/inter2.X.production.hex
make[2]: Entering directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\ xc8-cc.exe" -mcpu=12F683 -c -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/production/main.p1 main.c
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
main.c:30:6: error: variable has incomplete type 'void'
void interrupt my_isr (void) {
^
main.c:30:15: error: expected ';' after top level declarator
void interrupt my_isr (void) {
^
;
2 errors generated.
(908) exit status = 1
nbproject/Makefile-default.mk:107: recipe for target 'build/default/production/main.p1' failed
make[2]: Leaving directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [build/default/production/main.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
Tu n'as pas écrit la même chose que ce que je t'ai indiqué:
Code:void __interrupt () my_isr_routine (void) { }
Je n'ai plus de message d'erreur, mais la led ne clignote pas ( reste allumée)
le message de compil:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
make -f nbproject/Makefile-default.mk dist/default/production/inter2.X.production.hex
make[2]: Entering directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\ xc8-cc.exe" -mcpu=12F683 -c -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/production/main.p1 main.c
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\ xc8-cc.exe" -mcpu=12F683 -Wl,-Map=dist/default/production/inter2.X.production.map -DXPRJ_default=default -Wl,--defsym=__MPLAB_BUILD=1 -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -Wl,--memorysummary,dist/default/production/memoryfile.xml -o dist/default/production/inter2.X.production.elf build/default/production/main.p1
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
Memory Summary:
Program space used 2Eh ( 46) of 800h words ( 2.2%)
Data space used 4h ( 4) of 80h bytes ( 3.1%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
Data stack space used 0h ( 0) of 50h bytes ( 0.0%)
Configuration bits used 1h ( 1) of 1h word (100.0%)
ID Location space used 0h ( 0) of 4h bytes ( 0.0%)
make[2]: Leaving directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
make[1]: Leaving directory 'D:/Users/SIKORA/Documents/MPLAB/inter2.X'
BUILD SUCCESSFUL (total time: 8s)
Loading code from D:/Users/SIKORA/Documents/MPLAB/inter2.X/dist/default/production/inter2.X.production.hex...
Loading completed
Connecting to programmer...
Programming target...
Programming completed
Running target...
si exactement comme tu l'as indiqué:
#include <xc.h>
#include <pic12f683.h>
// Définition de la fréquence du crystal pour la fonction __delay_ms(x);
#define _XTAL_FREQ 31000
#define led GP4
// CONFIG
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF // Brown Out Detect (BOR disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#pragma interrupt
void __interrupt () my_isr_routine (void) {
if ((INTCONbits.T0IF == 1) && (INTCONbits.T0IE == 1))
{
TMR0 = 16;
led =~ led;
INTCONbits.T0IF = 0;
}
}
void main() {
ANSEL = 0b00000000;
TRISIO = 0b00000000;
OSCCON = 0b00000111;
//interruptions
INTCON = 0b00100000;
// timer
OPTION_REGbits.T0CS = 0;
OPTION_REGbits.T0SE = 0;
OPTION_REGbits.PSA = 0;
OPTION_REGbits.PS2 = 1;
OPTION_REGbits.PS1 = 0;
OPTION_REGbits.PS0 = 0;
// le timer0 doit contenir ce préchargement pour avoir 1s
while (1) {
}
}
Essaye ça.Code:#include <xc.h> #include <pic12f683.h> // Définition de la fréquence du crystal pour la fonction __delay_ms(x); #define _XTAL_FREQ 31000 #define led GP4 // CONFIG #pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD) #pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled) #pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled) #pragma config BOREN = OFF // Brown Out Detect (BOR disabled) #pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode is disabled) #pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled) #pragma interrupt void __interrupt () my_isr_routine (void) { if ((INTCONbits.T0IF == 1) && (INTCONbits.T0IE == 1)) { TMR0 = 16; led =~ led; INTCONbits.T0IF = 0; } } void main() { ANSEL = 0b00000000; TRISIO = 0b00000000; OSCCON = 0b00000111; // timer OPTION_REGbits.T0CS = 0; OPTION_REGbits.T0SE = 0; OPTION_REGbits.PSA = 0; OPTION_REGbits.PS2 = 1; OPTION_REGbits.PS1 = 0; OPTION_REGbits.PS0 = 0; TMR0 = 16; // le timer0 doit contenir ce préchargement pour avoir 1s //interruptions INTCON = 0b11100000; // ici on active les interruptions while (1) { } }
Eventuellement essaye de virer ça:
Je ne connais pas XC8, il faut voir dans la doc comment doit être déclarée proprement l'interruption.Code:#pragma interrupt
J'ai copié ton programme, viré #pragma interrupt et ............çA MARCHE!! la led clignote à 1Hz.
Un grand merci à toi.
Ceci étant as-tu une idée de ce qui clochait? à priori c'est le "my_isr_routine" qui a réglé le pb, c'est quoi cette expression?
En tout cas merci encore, je vai essayer de compléter par une interruption exterieure pour modifier la fréquence et "je te dis quoi" (comme on dit dans le Nord).
Je vois que tu as aussi modifié INTCON en activant global interrupt et les interrupt périphériques.