PIC 18F4620 Interrupt

OP #3104635
Lesenswert?

Morgen,

ich habe ein kleines Problem mit meiner ISR. Leider wird sie nicht 
aufgerufen und ich weiß nicht so recht warum. Wäre nett wenn einer mal 
drüberschauen könnte :)

Compile: xc8

Danke euch!
1
//-------
2
//Includes
3
//-------
4

5
#include <stdio.h>
6
#include <stdlib.h>
7
#include <xc.h>
8

9
//------
10
//Configs
11
//-----
12

13
#pragma config OSC = INTIO7   //internal HS OSC
14
#pragma config PWRT = ON  //Powerup Timer
15
#pragma config PBADEN = OFF
16
#pragma config WDT = OFF  //Watchdog Timer
17
#pragma config LVP = OFF  //Low Voltage ICSP
18

19

20
//------_
21
//Defines
22
//-------
23

24
#define _XTAL_FREQ 32000000  //32MHz CPU
25
#define  Timer0    INTCONbits.TMR0IF //Timer0 Interrupt
26
#define  Timer0IE    INTCONbits.TMR0IE //Timer0 Interrupt Enable Bit
27

28
//--------
29
//Prototypes
30
//--------
31

32
void init(void);
33
void interrupt ISR();
34
double time();
35

36
//--------
37
//Globale
38
//--------
39

40
double time_ms=0;
41

42

43

44
int main(void)
45
{
46

47
    init();
48
    while(1)
49
    {
50
       if(time_ms>=5000)  LATB=1;
51
    }
52
}
53

54

55

56
void init(void)
57
{
58
        OSCCON = 0b01111100;     // 8 MHz, primary Oscillator
59
  OSCTUNE =0b01000000;  // PLL aktiviert, Takt 32 MHz
60
        TRISB=0;        //Port B alle Outputs
61
        T0CON=0b11000100;   //TMR0On, 8bit, Internal Clock sorce,prescaler active value =1:32
62
        TMR0L=5;            //250 mal zählen bis überlauf, (8*10^6)/32/250=1000 mal timer 0 if pro sekunde
63
        INTCONbits.T0IE=1; // Enable Interrupt
64
        INTCON2bits.TMR0IP=1; //HIGH PRIORITY Interrupt
65
        
66
}
67
void  interrupt ISR()
68
{
69
    if (Timer0&&Timer0IE)
70
    {  
71
    time_ms++;
72
    TMR0L=5;
73
    Timer0=0;
74
    }
75

76
}
77

78
double time()
79
{
80
    return time_ms;
81
}

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren