Bonjour,
j'ai écris un programme avec un timer et interruption, j'arrive pas à le compiler, normalement il doit permettre de déclencher le porta par le LATA. Rien de se passe en simulation.
Merci de m'aider
Voici le programme :
#include <p18cxxx.h>
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 4000000 /*4MHz*/
//#pragma config SOSCSEL = DIG /* Digital (SCLKI) mode*/
#pragma config FOSC = XT
#pragma config PLLCFG = ON
#pragma config PWRTEN = OFF
#pragma config WDTEN = OFF
/****************************** */
void Int_Hight(void);
/****************************** */
/****************************** *******************/
#pragma code HighVector=0x08
void HighVector(void)
{
_asm goto Int_Hight _endasm
}
/*ooooooooooooooooooooooooooooo oooooo*/
#pragma code LowVector=0x18
void LowVector(void)
{
_asm goto Int_Hight _endasm
}
#pragma code
/****************************** *******************/
#pragma interruptlow Int_Hight
void Int_Hight(void){
unsigned char i;
TRISA = 0x00;
if(INTCONbits.TMR0IF){ /*==1*/
INTCONbits.TMR0IF=0; /*: Clr Overflow Interrupt Flag bit*/
TMR0L=0xFE;
i=LATA;
i^=i|0x01;
LATA=i;
}
}
void main (void){
TRISA=0b11111110; /* Bit 0 out*/
/**********************TIMER 0 INIT************************** *****************/
T0CONbits.TMR0ON=1; /*: Timer0 On/Off Control bit
1 = Enables Timer0*/
T0CONbits.T08BIT=1; /*: Timer0 8-Bit/16-Bit Control bit
1 = Timer0 is configured as an 8-bit timer/counter
0 = Timer0 is configured as a 16-bit timer/counter*/
T0CONbits.T0CS=0; /*Timer0 Clock Source Select bit
1 = Transition on T0CKI pin input edge
0 = Interna clock (FOSC/4)*/
T0CONbits.PSA=0; /* Timer0 Prescaler Assignment bit
1 = Timer0 prescaler is not assigned; Timer0 clock input bypasses the prescaler
0 = Timer0 prescaler is assigned; Timer0 clock input comes from the prescaler output*/
T0CONbits.T0PS=0x1; /*<2:0>: Timer0 Prescaler Select bits
111 = 1:256 Prescale value
110 = 1:128 Prescale value
101 = 1:64 Prescale value
100 = 1:32 Prescale value
011 = 1:16 Prescale value
010 = 1:8 Prescale value
001 = 1:4 Prescale value
000 = 1:2 Prescale value*/
/****************************** ****************************** *******************/
INTCON2bits.TMR0IP=1; /*TMR0 Overflow Interrupt Priority bit
1 = High priority
0 = Low priority*/
INTCONbits.TMR0IF=0; /*: TMR0 Overflow Interrupt Flag bit
1 = TMR0 register has overflowed (must be cleared in software)
0 = TMR0 register did not overflow*/
INTCONbits.TMR0IE=1; /*: TMR0 Overflow Interrupt Enable bit
1 = Enables the TMR0 overflow interrupt
0 = Disables the TMR0 overflow interrupt*/
RCONbits.IPEN = 1; /*When IPEN = 1:
1 = Enables all high-priority interrupts
0 = Disables all interrupts*/
INTCONbits.GIE=1; /*Global Interrupt Enable bit
When IPEN = 0:
1 = Enables all unmasked interrupts
0 = Disables all interrupts*/
TMR0L=0xFE; /*Timer0 Register Low Byte*/
while(1){
/****************************** ********/
}
}
-----