Forum: Mikrocontroller und Digitale Elektronik Problem mit Timer


von walter01 (Gast)


Lesenswert?

Hallo!!

Bin gerade dabei mich mit den Pic30f auseinander zusetzen und will den 
Timer1 des uC verwenden.
Ich verwende den pic 30F4013 sowie das dsPICDEM 2 Development Board, 
programmiere im MPLAB und benutze den pic30-gcc Compiler.

Nun ist mein Problem das der Timer nicht zu Zählen beginnt das heißt das 
Register TMR bleibt immer auf 0x0000 und das Interrupt Flag wird nicht 
gesetzt.
1
#include <p30fxxxx.h>    
2
#include "system.h"      
3
                    
4
_FOSC(CSW_FSCM_OFF & XT_PLL8);  //Run this project using an external crystal 
5
                                //routed via the PLL in 8x multiplier mode 
6
                                //For the 7.3728 MHz crystal we will derive a 
7
                                //throughput of 7.3728e+6*8/4 = 14.74 MIPS(Fcy) 
8
                                //,~67nanoseconds instruction cycle time(Tcy). 
9
_FWDT(WDT_OFF);                 //Turn off the Watch-Dog Timer. 
10
_FBORPOR(MCLR_EN & PWRT_OFF);   //Enable MCLR reset pin and turn off the 
11
                                //power-up timers. 
12
_FGS(CODE_PROT_OFF);            //Disable Code Protection 
13
int main (void) 
14
{ 
15
 T1CON = 0x0020;         //Timer1 set up to count on instruction cycle 
16
                                //edge with 1:64 prescaler applied initially. 
17
        PR1 = 0x00FF;           //Period Register, PR1, set to maximum count 
18
        IFS0bits.T1IF = 0;      //Clear the Timer1 Interrupt Flag 
19
        IEC0bits.T1IE = 1;      //Enable Timer1 Interrupt Service Routine 
20
    
21
      
22
 while(1) 
23
{                         
24
        T1CONbits.TON=1;    
25
26
        if(IFS0bits.T1IF==1)        
27
      {        
28
              T1CONbits.TON=0;                
29
   Tu irgendwas                
30
    }                
31
             TMR1=0x0000; 
32
   IFS0bits.T1IF =0; 
33
         } 
34
return 0;               //Code never reaches here! 
35
}

Ist hier irgendwo ein Fehler in der Timer Konfiguration?
Wäre sehr dankbar wenn mir jemand weiter helfen könnte.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.