Bonjour,
je programme un petit PIC12F615 en C avec l'outil MPLAB X IDE et un PicKit 3.
J'arrive à programmer le produit une fois sans problème.
Quand je change le code et que j'essaie de le reprogrammer, j'obtiens l'erreur suivante:
Si je déssoude le microcontrolleur et que je ressoude un nouveau, pas de soucis, il peut être de nouveau programmé.Code:***************************************************** Connecting to MPLAB PICkit 3... Currently loaded firmware on PICkit 3 Firmware Suite Version.....01.39.15 Firmware type..............Midrange Target voltage detected Target device PIC12F617 found. Device ID Revision = 0 The following memory area(s) will be programmed: program memory: start address = 0x0, end address = 0x53 configuration memory Device Erased... Programming... program memory Address: 10 Expected Value: 1f7 Received Value: 1f5 Failed to program device
Mon code est pourtant très simple, est-ce que j'ai raté quelquechose?
MerciCode:/******************************************************************************/ /* Files to Include */ /******************************************************************************/ #if defined(__XC) #include <xc.h> /* XC8 General Include File */ #elif defined(HI_TECH_C) #include <htc.h> /* HiTech General Include File */ #endif #include <stdint.h> /* For uint8_t definition */ #include <stdbool.h> /* For true/false definition */ // === DEFINES =================================================================================== // #define _XTAL_FREQ 8000000 // CONFIG #pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSCIO oscillator: I/O function on GP4/OSC2/CLKOUT pin, I/O function on GP5/OSC1/CLKIN) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config MCLRE = ON // MCLR Pin Function Select bit #pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled) #pragma config IOSCFS = 8MHZ // Internal Oscillator Frequency Select (8 MHz) #pragma config BOREN = ON // Brown-out Reset Selection bits (BOR enabled) /******************************************************************************/ /* User Global Variable Declaration */ /******************************************************************************/ int on_off = 0; // === PROTOTYPES ================================================================================ // void interrupt interrupt_isr(void); /******************************************************************************/ /* Main Program */ /******************************************************************************/ void main(void) { TRISIO = 0b00001100; // 0: Output; 1: Input ANSEL = 0x00; // Only digital function GPIObits.GP0 = 0; GPIObits.GP1 = 0; GPIObits.GP4 = 0; GPIObits.GP5 = 0; // Wait few ms during power stabilisation __delay_ms(10); OPTION_REGbits.INTEDG = 1;//Interrupt on GP2 rising edge INTCONbits.INTE = 1; INTCONbits.GIE = 1; while(1) { /* TODO <INSERT USER APPLICATION CODE HERE> */ } } void interrupt interrupt_isr(void) { // For HW debug GPIObits.GP5=1; __delay_us(2); GPIObits.GP5=0; // Push button if(INTCONbits.INTF){ if(on_off==0){ // On allume le buzzer GPIObits.GP1 = 1; __delay_us(5); GPIObits.GP4= 1; on_off = 1; }else{ GPIObits.GP1 = 0; GPIObits.GP4 = 0; on_off = 0; } INTCONbits.INTF = 0;// Flag must be cleared by SW } }
-----