voila j'ai mis en place le bootloader de Microchip MCHPFSUSB v2.2
tout ce passe bien je teste un hex pour clignote une led ok , mais quand j'essaye un code avec des interrupteur ça marche pas
dans mon code j'ai highVector=0x008
mais mon bootloader déclare déja ces valeurs
#define REMAPPED_HIGH_INTERRUPT_VECTOR _ADDRESS 0x1008
enfin voila je ne suis pas un pro et je me demande comment regle ce problemme
le code de base est pour un 18f4550 et je l'est adapte pour le 2550
je met ici mon code
merci encore pour vos aidesCode:#include <delays.h> // fonctions de délais /* PIC18 cycle-count delay routines. * * Functions: * Delay1TCY() * Delay10TCY() // 17Cxx only * Delay10TCYx() * Delay100TCYx() * Delay1KTCYx() * Delay10KTCYx() */ #include <timers.h> /* fonctions pour les timers */ #include <p18f2550.h>// déclarations pour le PIC18F252 #pragma config PLLDIV = 5 // (20 MHz crystal on PICDEM FS USB board) #pragma config CPUDIV = OSC1_PLL2 #pragma config USBDIV = 2 // Clock source from 96MHz PLL/2 #pragma config FOSC = HSPLL_HS #pragma config FCMEN = OFF #pragma config IESO = OFF #pragma config PWRT = ON #pragma config BOR = ON #pragma config BORV = 3 #pragma config VREGEN = ON //USB Voltage Regulator #pragma config WDT = OFF #pragma config WDTPS = 32768 #pragma config MCLRE = ON #pragma config LPT1OSC = OFF #pragma config PBADEN = OFF // #pragma config CCP2MX = ON #pragma config STVREN = ON #pragma config LVP = OFF // #pragma config ICPRT = OFF // Dedicated In-Circuit Debug/Programming #pragma config XINST = OFF // Extended Instruction Set #pragma config CP0 = OFF #pragma config CP1 = OFF // #pragma config CP2 = OFF // #pragma config CP3 = OFF #pragma config CPB = OFF // #pragma config CPD = OFF #pragma config WRT0 = OFF #pragma config WRT1 = OFF // #pragma config WRT2 = OFF // #pragma config WRT3 = OFF #pragma config WRTB = OFF // Boot Block Write Protection #pragma config WRTC = OFF // #pragma config WRTD = OFF #pragma config EBTR0 = OFF #pragma config EBTR1 = OFF // #pragma config EBTR2 = OFF // #pragma config EBTR3 = OFF #pragma config EBTRB = OFF #define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER //Uncomment this to make the output HEX of this project work with the HID Bootloader /** P R I V A T E P R O T O T Y P E S ***************************************/ static void InitializeSystem(void); void ProcessIO(void); void USBDeviceTasks(void); void YourHighPriorityISRCode(); void YourLowPriorityISRCode(); void BlinkUSBStatus(void); void UserInit(void); void InitializeUSART(void); void putcUSART(char c); unsigned char getcUSART (); /** VECTOR REMAPPING ***********************************************/ #if defined(__18CXX) //On PIC18 devices, addresses 0x00, 0x08, and 0x18 are used for //the reset, high priority interrupt, and low priority interrupt //vectors. However, the current Microchip USB bootloader //examples are intended to occupy addresses 0x00-0x7FF or //0x00-0xFFF depending on which bootloader is used. Therefore, //the bootloader code remaps these vectors to new locations //as indicated below. This remapping is only necessary if you //wish to program the hex file generated from this project with //the USB bootloader. If no bootloader is used, edit the //usb_config.h file and comment out the following defines: //#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER //#define PROGRAMMABLE_WITH_USB_LEGACY_CUSTOM_CLASS_BOOTLOADER #if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER) #define REMAPPED_RESET_VECTOR_ADDRESS 0x1000 #define REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS 0x1008 #define REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS 0x1018 #elif defined(PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER) #define REMAPPED_RESET_VECTOR_ADDRESS 0x800 #define REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS 0x808 #define REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS 0x818 #else #define REMAPPED_RESET_VECTOR_ADDRESS 0x00 #define REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS 0x08 #define REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS 0x18 #endif #if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)||defined(PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER) extern void _startup (void); // See c018i.c in your C18 compiler dir #pragma code REMAPPED_RESET_VECTOR = REMAPPED_RESET_VECTOR_ADDRESS void _reset (void) { _asm goto _startup _endasm } #endif #pragma code REMAPPED_HIGH_INTERRUPT_VECTOR = REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS void Remapped_High_ISR (void) { _asm goto YourHighPriorityISRCode _endasm } #pragma code REMAPPED_LOW_INTERRUPT_VECTOR = REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS void Remapped_Low_ISR (void) { _asm goto YourLowPriorityISRCode _endasm } #if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)||defined(PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER) //Note: If this project is built while one of the bootloaders has //been defined, but then the output hex file is not programmed with //the bootloader, addresses 0x08 and 0x18 would end up programmed with 0xFFFF. //As a result, if an actual interrupt was enabled and occured, the PC would jump //to 0x08 (or 0x18) and would begin executing "0xFFFF" (unprogrammed space). This //executes as nop instructions, but the PC would eventually reach the REMAPPED_RESET_VECTOR_ADDRESS //(0x1000 or 0x800, depending upon bootloader), and would execute the "goto _startup". This //would effective reset the application. //To fix this situation, we should always deliberately place a //"goto REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS" at address 0x08, and a //"goto REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS" at address 0x18. When the output //hex file of this project is programmed with the bootloader, these sections do not //get bootloaded (as they overlap the bootloader space). If the output hex file is not //programmed using the bootloader, then the below goto instructions do get programmed, //and the hex file still works like normal. The below section is only required to fix this //scenario. #pragma code HIGH_INTERRUPT_VECTOR = 0x08 void High_ISR (void) { _asm goto REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS _endasm } #pragma code LOW_INTERRUPT_VECTOR = 0x18 void Low_ISR (void) { _asm goto REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS _endasm } #endif //end of "#if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)||defined(PROGRAMMABLE_WITH_USB_LEGACY_CUSTOM_CLASS_BOOTLOADER)" #pragma code //These are your actual interrupt handling routines. #pragma interrupt YourHighPriorityISRCode void YourHighPriorityISRCode() { //Check which interrupt flag caused the interrupt. //Service the interrupt //Clear the interrupt flag //Etc. } //This return will be a "retfie fast", since this is in a #pragma interrupt section #pragma interruptlow YourLowPriorityISRCode void YourLowPriorityISRCode() { //Check which interrupt flag caused the interrupt. //Service the interrupt //Clear the interrupt flag //Etc. } //This return will be a "retfie", since this is in a #pragma interruptlow section #endif //of "#if defined(__18CXX)" #define IO_SERVO PORTAbits.RA0 #define IO_SERVO_TRIS TRISAbits.TRISA0 #define PULSE_ON 1 #define PULSE_OFF 0 /* fonction interruption */ void MyInterrupt(void); //#pragma code highVector=0x008 REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS #pragma code highVector=REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS void atInterrupthigh(void) { _asm GOTO MyInterrupt _endasm } #pragma code // retour à la zone de code // ************************ // **** Interruptions **** // ************************ #pragma interrupt MyInterrupt void MyInterrupt(void) { unsigned char sauv1; unsigned char sauv2; sauv1 = PRODL; sauv2 = PRODH; /* timer qui se charge de l'impulsion */ if (PIR1bits.TMR1IF) { // on ne remet pas ce bit à 0, il sera réarmé par le timer3 //PIR1bits.TMR1IF = 0; // on remet le pin à 0, le pulse est terminé IO_SERVO = PULSE_OFF; } /* timer qui se charge du temps inter-pulse */ if (PIR2bits.TMR3IF) { // on réarme le timer PIR2bits.TMR3IF = 0; // déclenchement du timer dans 20ms WriteTimer3(15535); /* on commence l'impulsion de 1ms */ // on met le pin à 1 IO_SERVO = PULSE_ON; // on écrit 55535 dans le timer1 pour qu'il se déclenche dans 1ms WriteTimer1(55535); // et on réarme le timer1 PIR1bits.TMR1IF = 0; } PRODL = sauv1; PRODH = sauv2; } /* fonction principale */ void main (void) { // on crée le timer1 OpenTimer1(TIMER_INT_ON & T1_8BIT_RW & T1_SOURCE_INT & T1_PS_1_1 & T1_OSC1EN_OFF & T1_SYNC_EXT_OFF); // puis le timer3 avec un prescaler de 4 OpenTimer3(TIMER_INT_ON & T3_8BIT_RW & T3_SOURCE_INT & T3_PS_1_4 & T3_SYNC_EXT_ON & T1_SOURCE_CCP); // on va compter 4 * 50000 cycles = 20ms avant de lever l'interruption WriteTimer3(15535); // On active toutes les interruptions INTCONbits.GIE = 1; INTCONbits.PEIE = 1; // on configure le pin 0 du port A en sortie IO_SERVO_TRIS = 0; // et on démarre la boucle infinie while (1) { }
-----