Hallo zusammen, hatte mit o.g. Microcontroller Probleme bei der Timerprogrammierung. Hatte die im Forum Allgemein beschrieben. Nun Habe ich Fehler gefunden ( M32C83 unterstützt nicht mehr die Clockdivision durch 32 ,siehe TA0MR Register ) Es funzt mit TA0MR = 0x40 Hier kompletter Code: ( falls jemand mal sowas braucht ) /*********************************************************************** ***/ /*********************************************************************** ***/ /* */ /* Name: timer.c */ /* Part of: */ /* Description: Main-modul */ /* Date : 29.08.2003 */ /* Author: */ /* Change: (Date) (Author) (Description) */ /* 31.8.2003 Dietmar test timer function */ /* Evaluation Board mit M30833FJFP */ /*********************************************************************** ***/ #include <stdio.h> #define public #include "sfr_3083.h" #undef public #define public extern #include "int_3083.h" #undef public #define enableInterrupts() asm( "fset I" ) #define disableInterrupts() asm( "fclr I" ) #define ledan 5 // wert * 10msec #define ledaus 5 // wert *10msec #pragma INTERRUPT timer_a0_interrupt /******************************************** * proto-type declaration ********************************************/ void timer_a0_interrupt(); void main(void); void initTimerA0(void); long t; int z; volatile unsigned int timer10msec = 0; void initTimerA0(void) { TA0MR = 0x40; // 0100 0000 also durch 8 // XX0X XX00 // |||| |||+- must always be 0 in timer mode // |||| ||+-- must always be 0 in timer mode // |||| |+--- 0: pulse is not output at pin TA0out // |||| | 1: pulse is output at pin TA0out // |||| | TA0out is automatically output // |||| +---- 0: gate function: timer counts only // |||| when TA0in is held "L" // |||| 1: gate function: timer counts only // |||| when TA0in is held "H" // |||+------ 0: gate function not available // ||| 1: gate function available // ||+------- must always be 0 in timer mode // |+-------- count source select bits: // +--------- count source select bits: // 00: f1 // 01: f8 // 10: f32 // funktioniert bei M32 nicht mehr // 11: fc32 // TA0IC = 0x07; // ---- XXXX 7 höchster level // |||| // |||+-- Interupt priority level select bit // ||+--- Interupt priority level select bit // |+---- Interupt priority level select bit // | 000: Level 0 (interrupt disabled) // | 001: Level 1 // | 010: Level 2 // | 011: Level 3 // | 100: Level 4 // | 101: Level 5 // | 110: Level 6 // | 111: Level 7 // +----- Interupt request bit // 0: Interrupt not requested // 1: Interrupt requested TA0 = 0x9276; // Set up Timer A0 Reload Register for 10msec interval interrupt UDF = 0x00; // Timer count down TABSR = 0x01; // Timer start flag bit ( 8bit Register; ta0s = 1 start counting ) } void timer_a0_interrupt(void) { if(timer10msec != 0) {timer10msec--;} } void delay(unsigned short t) // Zweck Zeitverzögerung um time*10msec { timer10msec=t; while (timer10msec != 0) {} // Solange noch nicht heruntergezählt ist, warten } /*********************************************************************** *** * Function : main() * program section ************************************************************************ **/ void main (void) { // PMO, PM1, CM0, CM1 and MCD register setting is done in ncrt0.a30 PD5 = 0xFF; /* Port P5 output */ while (1) // endless while loop start { P5 = 0xFF; disableInterrupts(); initTimerA0(); enableInterrupts(); // enable all interrupts delay(ledan); P5 = 0x00; delay(ledaus); // your code here asm("NOP"); } } /*********************************** E O F ********************************/
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
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.