[PIC] Interuption Timer2 instable ?!
Répondre à la discussion
Affichage des résultats 1 à 14 sur 14

[PIC] Interuption Timer2 instable ?!



  1. #1
    Seb.26

    [PIC] Interuption Timer2 instable ?!


    ------

    Bonjour à tous,

    J'ai un montage avec un PIC 18F2550, qui tourne sur son oscillateur interne (8MHz), sur ce montage, j'ai une pin de debug (que j'inverse sur chaque IT d'un Timer par exemple).

    Dans mon programme, j'ai configuré le Timer0 pour avoir une IT toutes les 1mS ... ça marche impec

    J'ai aussi utilisé le Timer2 pour avoir une IT toutes les 100uS.

    Tout cela fonctionnait impec :
    - j'ai testé mon Timer0 via ma pin de debug : OK
    - j'ai testé mon Timer2 via la même pin : OK

    Ensuite, j'ai tout mis ensemble : le Timer0 dans l'interruption basses et Timer2 dans l’interruption hautes ... et là, c'est le drame

    Mon Timer2 est devenu très instable !!!
    ( je visualise mon timer2 via ma pin de debug ... )

    La période du Timer2 va de 95uS à 125uS !!!
    Nom : Timer2.png
Affichages : 64
Taille : 12,9 Ko

    NB : il n'y a qu'une seule interruption haute : Timer2 (tout le reste est dans l'IT basse)

    NB' : j'ai testé la priorités des vecteurs IT : j'ai mis un while(1) dans l'IT basse pour voir si l'IT haute claquait bien : RAS !

    NB'' : Évidement, j'ai verifié que ma pin de DEBUG n'est pas modifiée ailleurs que dans l'IT du Timer2 ...

    Comme ça à l'instinct, je me dis que c'est un souci dans mes IT, genre la sauvegarde de contexte qui influe sur la latence de mon IT (latence 0 si on est déjà dans l'IT basse) ... et en même temps, 30uS c'est beaucoup, non ?

    Indice : quand je "bloque" dans mon IT basse en mettant un while(1) dedans, mon IT haute reste instable ... ?!
    ... et pourtant, si je désactive Timer0, Timer2 redevient parfaitement stable !!!

    Si vous avez un avis là dessus, une idée (même pas forcement une géniale), je suis preneur ...

    Merci d'avance

    @+

    -----
    << L'histoire nous apprend que l'on apprend rien de l'histoire. >>

  2. #2
    Seb.26

    Re : [PIC] Interuption Timer2 instable ?!

    Voici mon programme de test en C :

    Code:
    #include <pic18fregs.h>
    #define uChar unsigned char
    #define DBUG			(PORTBbits.RB5)
    
    // CONFIGURATION BITS
    static __code uChar __at 0x300000 CONFIG_0 = 0xFF;
    static __code uChar __at 0x300001 CONFIG_1 = 0x08;
    static __code uChar __at 0x300002 CONFIG_2 = 0x18;
    static __code uChar __at 0x300003 CONFIG_3 = 0x1E;
    static __code uChar __at 0x300005 CONFIG_5 = 0x01;
    static __code uChar __at 0x300006 CONFIG_6 = 0x81;
    static __code uChar __at 0x300008 CONFIG_8 = 0x0F;
    static __code uChar __at 0x300009 CONFIG_9 = 0xC0;
    static __code uChar __at 0x30000A CONFIG_A = 0x0F;
    static __code uChar __at 0x30000B CONFIG_B = 0xE0;
    static __code uChar __at 0x30000C CONFIG_C = 0x0F;
    static __code uChar __at 0x30000D CONFIG_D = 0x40;
    
    //
    // Main program :
    //
    
    void main()
    {
    	//
    	// Hardware init
    
    	// Set clock
    	OSCCON = 0b01110010;
    	OSCTUNE = 0b01000000;
    
    	// Disable ADC
    	ADCON0bits.ADON = 0;
    	ADCON1 = 0b00001111;
    
    	// Disable CCP
    	CCP1CON = 0x00;
    	CCP2CON = 0x00;
    
    	// Disable USB
    	UCONbits.USBEN = 0;
    	UCFGbits.UTRDIS = 1;
    
    	// PORTA
    	TRISA = 0b00000000;
    	PORTA = 0x00;
    
    	// PORTB
    	INTCON2bits.RBPU = 1; // No pull-up
    	TRISB = 0b00000000;
    	PORTB = 0x00;
    
    	// PORTC
    	TRISC = 0b10110110;
    	PORTC = 0x00;
    
    	// Set UART
    	TXSTA = 0b00100100;
    	RCSTA = 0b10010000;
    
    	BAUDCON = 0b00001010;
    
    	// 9600bps
    	//SPBRGH = 0x03;
    	//SPBRG = 0x40;
    
    	// 57600bps
    	SPBRGH = 0x00;
    	SPBRG = 0x8A;
    
    	// Init Timer0
    	T0CON = 0b10001000;
    
    	// Init Timer2 
    	T2CON = 0b00000100;
    	PR2 = 200;
    	
    	// Init interupts
    	INTCON = 0x00;
    	INTCON3 = 0x00;
    	//
    	PIR1 = 0x00;
    	PIR2 = 0x00;
    	//
    	PIE1 = 0x00;
    	PIE2 = 0x00;
    	//
    	IPR1 = 0x00;
    	IPR2 = 0x00;
    
    	RCONbits.IPEN = 1;
    
    	INTCONbits.TMR0IE = 1;
    
    	PIE1bits.TMR2IE = 1;
    	IPR1bits.TMR2IP = 1;
    
    	//
    	// Main endless loop
    	//
    
    	// Launch all interupts
    	INTCONbits.GIEH = 1;
    	INTCONbits.GIEL = 1;
    
    	while(1)
    	{
    	}
    }
    
    //
    // Interupt services
    //
    
    // Low priority
    void ISR_low(void) __interrupt 2
    {
    	// Timer0 interrupt (1ms)
    	if( INTCONbits.TMR0IE && INTCONbits.TMR0IF )
    	{
    		INTCONbits.TMR0IF = 0;
    		//
    		TMR0H = 0xF8;
    		TMR0L = 0x52;
    	}
    }
    
    // High priority
    void ISR_high(void) __interrupt 1
    {
    	if( PIE1bits.TMR2IE && PIR1bits.TMR2IF )
    	{
    		PIR1bits.TMR2IF = 0;
    		//
    		DBUG = !DBUG;
    	}
    }
    << L'histoire nous apprend que l'on apprend rien de l'histoire. >>

  3. #3
    Seb.26

    Re : [PIC] Interuption Timer2 instable ?!

    Et pour ceux qui préfèrent l'ASM :

    Code:
    ;--------------------------------------------------------
    ; File Created by SDCC : free open source ANSI-C Compiler
    ; Version 3.0.0 #6037 (Oct 31 2010) (MINGW32)
    ; This file was generated Wed Jun 22 13:05:05 2011
    ;--------------------------------------------------------
    ; PIC16 port for the Microchip 16-bit core micros
    ;--------------------------------------------------------
    	list	p=18f2550
    	__config 0x300000, 0xff
    	__config 0x300001, 0x08
    	__config 0x300002, 0x18
    	__config 0x300003, 0x1e
    	__config 0x300005, 0x01
    	__config 0x300006, 0x81
    	__config 0x300008, 0x0f
    	__config 0x300009, 0xc0
    	__config 0x30000a, 0x0f
    	__config 0x30000b, 0xe0
    	__config 0x30000c, 0x0f
    	__config 0x30000d, 0x40
    
    	radix dec
    
    ;--------------------------------------------------------
    ; public variables in this module
    ;--------------------------------------------------------
    	global _main
    	global _ISR_low
    	global _ISR_high
    
    ;--------------------------------------------------------
    ; extern variables in this module
    ;--------------------------------------------------------
    	extern _SPPDATAbits
    	extern _SPPCFGbits
    	extern _SPPEPSbits
    	extern _SPPCONbits
    	extern _UFRMLbits
    	extern _UFRMHbits
    	extern _UIRbits
    	extern _UIEbits
    	extern _UEIRbits
    	extern _UEIEbits
    	extern _USTATbits
    	extern _UCONbits
    	extern _UADDRbits
    	extern _UCFGbits
    	extern _UEP0bits
    	extern _UEP1bits
    	extern _UEP2bits
    	extern _UEP3bits
    	extern _UEP4bits
    	extern _UEP5bits
    	extern _UEP6bits
    	extern _UEP7bits
    	extern _UEP8bits
    	extern _UEP9bits
    	extern _UEP10bits
    	extern _UEP11bits
    	extern _UEP12bits
    	extern _UEP13bits
    	extern _UEP14bits
    	extern _UEP15bits
    	extern _PORTAbits
    	extern _PORTBbits
    	extern _PORTCbits
    	extern _PORTDbits
    	extern _PORTEbits
    	extern _LATAbits
    	extern _LATBbits
    	extern _LATCbits
    	extern _LATDbits
    	extern _LATEbits
    	extern _TRISAbits
    	extern _TRISBbits
    	extern _TRISCbits
    	extern _TRISDbits
    	extern _TRISEbits
    	extern _OSCTUNEbits
    	extern _PIE1bits
    	extern _PIR1bits
    	extern _IPR1bits
    	extern _PIE2bits
    	extern _PIR2bits
    	extern _IPR2bits
    	extern _EECON1bits
    	extern _RCSTAbits
    	extern _TXSTAbits
    	extern _T3CONbits
    	extern _CMCONbits
    	extern _CVRCONbits
    	extern _ECCP1ASbits
    	extern _ECCP1DELbits
    	extern _BAUDCONbits
    	extern _CCP2CONbits
    	extern _CCP1CONbits
    	extern _ADCON2bits
    	extern _ADCON1bits
    	extern _ADCON0bits
    	extern _SSPCON2bits
    	extern _SSPCON1bits
    	extern _SSPSTATbits
    	extern _T2CONbits
    	extern _T1CONbits
    	extern _RCONbits
    	extern _WDTCONbits
    	extern _HLVDCONbits
    	extern _OSCCONbits
    	extern _T0CONbits
    	extern _STATUSbits
    	extern _FSR2Hbits
    	extern _BSRbits
    	extern _FSR1Hbits
    	extern _FSR0Hbits
    	extern _INTCON3bits
    	extern _INTCON2bits
    	extern _INTCONbits
    	extern _TBLPTRUbits
    	extern _PCLATHbits
    	extern _PCLATUbits
    	extern _STKPTRbits
    	extern _TOSUbits
    	extern _SPPDATA
    	extern _SPPCFG
    	extern _SPPEPS
    	extern _SPPCON
    	extern _UFRML
    	extern _UFRMH
    	extern _UIR
    	extern _UIE
    	extern _UEIR
    	extern _UEIE
    	extern _USTAT
    	extern _UCON
    	extern _UADDR
    	extern _UCFG
    	extern _UEP0
    	extern _UEP1
    	extern _UEP2
    	extern _UEP3
    	extern _UEP4
    	extern _UEP5
    	extern _UEP6
    	extern _UEP7
    	extern _UEP8
    	extern _UEP9
    	extern _UEP10
    	extern _UEP11
    	extern _UEP12
    	extern _UEP13
    	extern _UEP14
    	extern _UEP15
    	extern _PORTA
    	extern _PORTB
    	extern _PORTC
    	extern _PORTD
    	extern _PORTE
    	extern _LATA
    	extern _LATB
    	extern _LATC
    	extern _LATD
    	extern _LATE
    	extern _TRISA
    	extern _TRISB
    	extern _TRISC
    	extern _TRISD
    	extern _TRISE
    	extern _OSCTUNE
    	extern _PIE1
    	extern _PIR1
    	extern _IPR1
    	extern _PIE2
    	extern _PIR2
    	extern _IPR2
    	extern _EECON1
    	extern _EECON2
    	extern _EEDATA
    	extern _EEADR
    	extern _RCSTA
    	extern _TXSTA
    	extern _TXREG
    	extern _RCREG
    	extern _SPBRG
    	extern _SPBRGH
    	extern _T3CON
    	extern _TMR3L
    	extern _TMR3H
    	extern _CMCON
    	extern _CVRCON
    	extern _ECCP1AS
    	extern _ECCP1DEL
    	extern _BAUDCON
    	extern _CCP2CON
    	extern _CCPR2L
    	extern _CCPR2H
    	extern _CCP1CON
    	extern _CCPR1L
    	extern _CCPR1H
    	extern _ADCON2
    	extern _ADCON1
    	extern _ADCON0
    	extern _ADRESL
    	extern _ADRESH
    	extern _SSPCON2
    	extern _SSPCON1
    	extern _SSPSTAT
    	extern _SSPADD
    	extern _SSPBUF
    	extern _T2CON
    	extern _PR2
    	extern _TMR2
    	extern _T1CON
    	extern _TMR1L
    	extern _TMR1H
    	extern _RCON
    	extern _WDTCON
    	extern _HLVDCON
    	extern _OSCCON
    	extern _T0CON
    	extern _TMR0L
    	extern _TMR0H
    	extern _STATUS
    	extern _FSR2L
    	extern _FSR2H
    	extern _PLUSW2
    	extern _PREINC2
    	extern _POSTDEC2
    	extern _POSTINC2
    	extern _INDF2
    	extern _BSR
    	extern _FSR1L
    	extern _FSR1H
    	extern _PLUSW1
    	extern _PREINC1
    	extern _POSTDEC1
    	extern _POSTINC1
    	extern _INDF1
    	extern _WREG
    	extern _FSR0L
    	extern _FSR0H
    	extern _PLUSW0
    	extern _PREINC0
    	extern _POSTDEC0
    	extern _POSTINC0
    	extern _INDF0
    	extern _INTCON3
    	extern _INTCON2
    	extern _INTCON
    	extern _PRODL
    	extern _PRODH
    	extern _TABLAT
    	extern _TBLPTRL
    	extern _TBLPTRH
    	extern _TBLPTRU
    	extern _PCL
    	extern _PCLATH
    	extern _PCLATU
    	extern _STKPTR
    	extern _TOSL
    	extern _TOSH
    	extern _TOSU
    ;--------------------------------------------------------
    ;	Equates to used internal registers
    ;--------------------------------------------------------
    STATUS	equ	0xfd8
    PCLATH	equ	0xffa
    PCLATU	equ	0xffb
    WREG	equ	0xfe8
    BSR	equ	0xfe0
    FSR0L	equ	0xfe9
    FSR0H	equ	0xfea
    FSR1L	equ	0xfe1
    FSR2L	equ	0xfd9
    POSTDEC1	equ	0xfe5
    PREINC1	equ	0xfe4
    PRODL	equ	0xff3
    PRODH	equ	0xff4
    
    
    ; Internal registers
    .registers	udata_ovr	0x0000
    r0x00	res	1
    
    ;--------------------------------------------------------
    ; interrupt vector 
    ;--------------------------------------------------------
    
    ;--------------------------------------------------------
    ; global & static initialisations
    ;--------------------------------------------------------
    ; ; Starting pCode block for absolute section
    ; ;-----------------------------------------
    S__Main_ivec_0x2_ISR_low	code	0X000018
    ivec_0x2_ISR_low:
    	GOTO	_ISR_low
    
    ; ; Starting pCode block for absolute section
    ; ;-----------------------------------------
    S__Main_ivec_0x1_ISR_high	code	0X000008
    ivec_0x1_ISR_high:
    	GOTO	_ISR_high
    
    ; I code from now on!
    ; ; Starting pCode block
    S__Main__main	code
    _main:
    ;	.line	48; _Main.c	OSCCON = 0b01110010;
    	MOVLW	0x72
    	MOVWF	_OSCCON
    ;	.line	49; _Main.c	OSCTUNE = 0b01000000;
    	MOVLW	0x40
    	MOVWF	_OSCTUNE
    ;	.line	52; _Main.c	ADCON0bits.ADON = 0;
    	BCF	_ADCON0bits, 0
    ;	.line	53; _Main.c	ADCON1 = 0b00001111;
    	MOVLW	0x0f
    	MOVWF	_ADCON1
    ;	.line	56; _Main.c	CCP1CON = 0x00;
    	CLRF	_CCP1CON
    ;	.line	57; _Main.c	CCP2CON = 0x00;
    	CLRF	_CCP2CON
    ;	.line	60; _Main.c	UCONbits.USBEN = 0;
    	BCF	_UCONbits, 3
    ;	.line	61; _Main.c	UCFGbits.UTRDIS = 1;
    	BSF	_UCFGbits, 3
    ;	.line	64; _Main.c	TRISA = 0b00000000;
    	CLRF	_TRISA
    ;	.line	65; _Main.c	PORTA = 0x00;
    	CLRF	_PORTA
    ;	.line	68; _Main.c	INTCON2bits.RBPU = 1; // No pull-up
    	BSF	_INTCON2bits, 7
    ;	.line	69; _Main.c	TRISB = 0b00000000;
    	CLRF	_TRISB
    ;	.line	70; _Main.c	PORTB = 0x00;
    	CLRF	_PORTB
    ;	.line	73; _Main.c	TRISC = 0b10110110;
    	MOVLW	0xb6
    	MOVWF	_TRISC
    ;	.line	74; _Main.c	PORTC = 0x00;
    	CLRF	_PORTC
    ;	.line	77; _Main.c	TXSTA = 0b00100100;
    	MOVLW	0x24
    	MOVWF	_TXSTA
    ;	.line	78; _Main.c	RCSTA = 0b10010000;
    	MOVLW	0x90
    	MOVWF	_RCSTA
    ;	.line	80; _Main.c	BAUDCON = 0b00001010;
    	MOVLW	0x0a
    	MOVWF	_BAUDCON
    ;	.line	87; _Main.c	SPBRGH = 0x00;
    	CLRF	_SPBRGH
    ;	.line	88; _Main.c	SPBRG = 0x8A;
    	MOVLW	0x8a
    	MOVWF	_SPBRG
    ;	.line	91; _Main.c	T0CON = 0b10001000;
    	MOVLW	0x88
    	MOVWF	_T0CON
    ;	.line	94; _Main.c	T2CON = 0b00000100;
    	MOVLW	0x04
    	MOVWF	_T2CON
    ;	.line	95; _Main.c	PR2 = 200;
    	MOVLW	0xc8
    	MOVWF	_PR2
    ;	.line	98; _Main.c	INTCON = 0x00;
    	CLRF	_INTCON
    ;	.line	99; _Main.c	INTCON3 = 0x00;
    	CLRF	_INTCON3
    ;	.line	101; _Main.c	PIR1 = 0x00;
    	CLRF	_PIR1
    ;	.line	102; _Main.c	PIR2 = 0x00;
    	CLRF	_PIR2
    ;	.line	104; _Main.c	PIE1 = 0x00;
    	CLRF	_PIE1
    ;	.line	105; _Main.c	PIE2 = 0x00;
    	CLRF	_PIE2
    ;	.line	107; _Main.c	IPR1 = 0x00;
    	CLRF	_IPR1
    ;	.line	108; _Main.c	IPR2 = 0x00;
    	CLRF	_IPR2
    ;	.line	110; _Main.c	RCONbits.IPEN = 1;
    	BSF	_RCONbits, 7
    ;	.line	114; _Main.c	INTCONbits.TMR0IE = 1;
    	BSF	_INTCONbits, 5
    ;	.line	116; _Main.c	PIE1bits.TMR2IE = 1;
    	BSF	_PIE1bits, 1
    ;	.line	117; _Main.c	IPR1bits.TMR2IP = 1;
    	BSF	_IPR1bits, 1
    ;	.line	133; _Main.c	INTCONbits.GIEH = 1;
    	BSF	_INTCONbits, 7
    ;	.line	134; _Main.c	INTCONbits.GIEL = 1;
    	BSF	_INTCONbits, 6
    _00106_DS_:
    ;	.line	136; _Main.c	while(1)
    	BRA	_00106_DS_
    	RETURN	
    
    ; ; Starting pCode block
    S__Main__ISR_high	code
    _ISR_high:
    ;	.line	230; _Main.c	void ISR_high(void) __interrupt 1
    	MOVFF	WREG, POSTDEC1
    	MOVFF	STATUS, POSTDEC1
    	MOVFF	BSR, POSTDEC1
    	MOVFF	PRODL, POSTDEC1
    	MOVFF	PRODH, POSTDEC1
    	MOVFF	FSR0L, POSTDEC1
    	MOVFF	FSR0H, POSTDEC1
    	MOVFF	PCLATH, POSTDEC1
    	MOVFF	PCLATU, POSTDEC1
    	MOVFF	FSR2L, POSTDEC1
    	MOVFF	FSR1L, FSR2L
    	MOVFF	r0x00, POSTDEC1
    ;	.line	232; _Main.c	if( PIE1bits.TMR2IE && PIR1bits.TMR2IF )
    	BTFSS	_PIE1bits, 1
    	BRA	_00124_DS_
    	BTFSS	_PIR1bits, 1
    	BRA	_00124_DS_
    ;	.line	234; _Main.c	PIR1bits.TMR2IF = 0;
    	BCF	_PIR1bits, 1
    ;	.line	236; _Main.c	DBUG = !DBUG;
    	CLRF	r0x00
    	BTFSC	_PORTBbits, 5
    	INCF	r0x00, F
    	MOVF	r0x00, W
    	BSF	STATUS, 0
    	TSTFSZ	WREG
    	BCF	STATUS, 0
    	CLRF	r0x00
    	RLCF	r0x00, F
    	MOVF	r0x00, W
    	ANDLW	0x01
    	SWAPF	WREG, W
    	RLNCF	WREG, W
    	MOVWF	PRODH
    	MOVF	_PORTBbits, W
    	ANDLW	0xdf
    	IORWF	PRODH, W
    	MOVWF	_PORTBbits
    _00124_DS_:
    	MOVFF	PREINC1, r0x00
    	MOVFF	PREINC1, FSR2L
    	MOVFF	PREINC1, PCLATU
    	MOVFF	PREINC1, PCLATH
    	MOVFF	PREINC1, FSR0H
    	MOVFF	PREINC1, FSR0L
    	MOVFF	PREINC1, PRODH
    	MOVFF	PREINC1, PRODL
    	MOVFF	PREINC1, BSR
    	MOVFF	PREINC1, STATUS
    	MOVFF	PREINC1, WREG
    	RETFIE	
    
    ; ; Starting pCode block
    S__Main__ISR_low	code
    _ISR_low:
    ;	.line	170; _Main.c	void ISR_low(void) __interrupt 2
    	MOVFF	WREG, POSTDEC1
    	MOVFF	STATUS, POSTDEC1
    	MOVFF	BSR, POSTDEC1
    	MOVFF	PRODL, POSTDEC1
    	MOVFF	PRODH, POSTDEC1
    	MOVFF	FSR0L, POSTDEC1
    	MOVFF	FSR0H, POSTDEC1
    	MOVFF	PCLATH, POSTDEC1
    	MOVFF	PCLATU, POSTDEC1
    	MOVFF	FSR2L, POSTDEC1
    	MOVFF	FSR1L, FSR2L
    ;	.line	218; _Main.c	if( INTCONbits.TMR0IE && INTCONbits.TMR0IF )
    	BTFSS	_INTCONbits, 5
    	BRA	_00116_DS_
    	BTFSS	_INTCONbits, 2
    	BRA	_00116_DS_
    ;	.line	220; _Main.c	INTCONbits.TMR0IF = 0;
    	BCF	_INTCONbits, 2
    ;	.line	222; _Main.c	TMR0H = 0xF8;
    	MOVLW	0xf8
    	MOVWF	_TMR0H
    ;	.line	223; _Main.c	TMR0L = 0x52;
    	MOVLW	0x52
    	MOVWF	_TMR0L
    _00116_DS_:
    	MOVFF	PREINC1, FSR2L
    	MOVFF	PREINC1, PCLATU
    	MOVFF	PREINC1, PCLATH
    	MOVFF	PREINC1, FSR0H
    	MOVFF	PREINC1, FSR0L
    	MOVFF	PREINC1, PRODH
    	MOVFF	PREINC1, PRODL
    	MOVFF	PREINC1, BSR
    	MOVFF	PREINC1, STATUS
    	MOVFF	PREINC1, WREG
    	RETFIE	
    
    
    
    ; Statistics:
    ; code size:	  348 (0x015c) bytes ( 0.27%)
    ;           	  174 (0x00ae) words
    ; udata size:	    0 (0x0000) bytes ( 0.00%)
    ; access size:	    1 (0x0001) bytes
    
    
    	end
    << L'histoire nous apprend que l'on apprend rien de l'histoire. >>

  4. #4
    RISC

    Re : [PIC] Interuption Timer2 instable ?!

    Salut,

    Je pense que ton problème est du à la mauvaise priorité du TIMER2.

    Tu as programmé : IPR1 = 0 (basse priorité pour tout les bits...)

    Il faudrait programmer : IPR1bits.TMR2IP = 1;

    a+

  5. A voir en vidéo sur Futura
  6. #5
    simon.

    Re : [PIC] Interuption Timer2 instable ?!

    Salut,

    Problème rigolo effectivement.
    Commence donc par corriger ceci:

    #define DBUG (LATBbits.LATB5)

  7. #6
    simon.

    Re : [PIC] Interuption Timer2 instable ?!

    Citation Envoyé par RISC Voir le message
    Salut,

    Je pense que ton problème est du à la mauvaise priorité du TIMER2.

    Tu as programmé : IPR1 = 0 (basse priorité pour tout les bits...)

    Il faudrait programmer : IPR1bits.TMR2IP = 1;

    a+
    Il l'a fait. Et si c'était le problème sa patte de debug de bougerait pas du tout, le handler ne serait jamais executé.

  8. #7
    Seb.26

    Re : [PIC] Interuption Timer2 instable ?!

    Citation Envoyé par RISC Voir le message
    Tu as programmé : IPR1 = 0 (basse priorité pour tout les bits...)
    Il faudrait programmer : IPR1bits.TMR2IP = 1;
    C'est en effet déjà fait (un peu plus bas) ... j'ai pris l'habitude de l'écrire pour mémo ...

    Commence donc par corriger ceci:
    #define DBUG (LATBbits.LATB5)
    Je doute que ça change quoi que ce soit au timing ...
    << L'histoire nous apprend que l'on apprend rien de l'histoire. >>

  9. #8
    Seb.26

    Re : [PIC] Interuption Timer2 instable ?!

    Nouvel indice :

    Le bug du Timer2 n'arrive pas au hasard !

    Il est à 100% sur la 4èm ou 5è interruption suivant le dernier bug :
    Nom : Timer2_suite.png
Affichages : 52
Taille : 18,1 Ko

    Étrange ... mon Timer0 étant calé sur 1ms et Timer2 sur 100uS, je m'attendais plutôt à du 1 sur 10 ... ?! ...
    (je vais revérifier mon timer0 )
    Dernière modification par Seb.26 ; 22/06/2011 à 14h42.
    << L'histoire nous apprend que l'on apprend rien de l'histoire. >>

  10. #9
    simon.

    Re : [PIC] Interuption Timer2 instable ?!

    T'as bien désactivé le watchdog ?
    Super pratique les registres de config en hexa...

  11. #10
    simon.

    Re : [PIC] Interuption Timer2 instable ?!

    Ce qui est marrant c'est que si ta période est de 95us avec PR2=200, les 125us que tu mesures correspondraient quasiment à PR2=255...

    Essaie voir de réduire la période du timer (genre de moitié), pour voir comment les périodes "déféctueuses" sont modifiées (ou pas?)

  12. #11
    simon.

    Re : [PIC] Interuption Timer2 instable ?!

    Ce qui serait pas mal serait une deuxième patte de debug pour tracer l'autre timer en même temps.

  13. #12
    simon.

    Re : [PIC] Interuption Timer2 instable ?!

    Citation Envoyé par Seb.26 Voir le message

    Étrange ... mon Timer0 étant calé sur 1ms et Timer2 sur 100uS, je m'attendais plutôt à du 1 sur 10 ... ?! ...
    Oui enfin sauf que si tu as mesuré 5 créneaux ça correspond effectivement à 10 fois la période du timer2, donc ça colle. (un coup en haut, un coup en bas)

  14. #13
    Seb.26

    Re : [PIC] Interuption Timer2 instable ?!

    Citation Envoyé par simon. Voir le message
    T'as bien désactivé le watchdog ?
    Super pratique les registres de config en hexa...
    Simple copier-coller du Wizard de MPLAB ...

    Ce qui est marrant c'est que si ta période est de 95us avec PR2=200, les 125us que tu mesures correspondraient quasiment à PR2=255...
    Essaie voir de réduire la période du timer (genre de moitié), pour voir comment les périodes "déféctueuses" sont modifiées (ou pas?)
    Hum ... bonne remarque !
    Je teste de suite avec 100 pour PR2

    Citation Envoyé par simon. Voir le message
    Oui enfin sauf que si tu as mesuré 5 créneaux ça correspond effectivement à 10 fois la période du timer2, donc ça colle. (un coup en haut, un coup en bas)
    Non ... c'est bien 5, pas 10 .... voir pièce jointe ...
    << L'histoire nous apprend que l'on apprend rien de l'histoire. >>

  15. #14
    Seb.26

    Re : [PIC] Interuption Timer2 instable ?!

    [suite et fin]

    ça fonctionne maintenant !

    C'était le Timer0 qui faisait boucler mon uCPU car au boot INTCON2 le définit en IT haute priorité ...

    Le reste n'était que poudre au yeux ...

    Merci de votre aide.
    << L'histoire nous apprend que l'on apprend rien de l'histoire. >>

Discussions similaires

  1. Jusqu'où l'équilibre instable est-il instable ?
    Par invite050a6472 dans le forum Physique
    Réponses: 10
    Dernier message: 01/04/2014, 00h53
  2. PIC 16F87xA, Timer2 et interruption
    Par Forhorse dans le forum Électronique
    Réponses: 1
    Dernier message: 12/01/2011, 19h49
  3. interuption pic 18f
    Par nirvo dans le forum Électronique
    Réponses: 9
    Dernier message: 23/08/2010, 08h09
  4. interuption pic 18f
    Par nirvo dans le forum Électronique
    Réponses: 6
    Dernier message: 01/07/2010, 20h22
  5. Timer2 PIC16F
    Par olivier_elec dans le forum Électronique
    Réponses: 7
    Dernier message: 19/05/2010, 22h41
Découvrez nos comparatifs produits sur l'informatique et les technologies.