Hallo zusammen, ich teste gerade mein Evaluation Board ( Mitsubishi CPU M30833). Diese wird extern mit 30Mhz betrieben. Um eine Led am Port p5 zum Blinken zu bringen habe ich eine Timerfunktion benutzt. Leider funktioniert es noch nicht so richtig. Die LED brennt ständig. Ich vermute, daß die Timerfunktion nicht funzt. Könnt Ihr mir einen Tip geben , woran es liegen könnte. Gruß Dietmar /* Evaluation Board mit M30833FJFP */ /*********************************************************************** ***/ #include <stdio.h> /*********************************************************************** *** * Special Function Registers ************************************************************************ **/ #pragma ADDRESS p5 3e9H /* Port P0 register */ #pragma ADDRESS pd5 3ebH /* Port P0 direction register */ #pragma ADDRESS tabsr 340H /* Count start flag */ #pragma ADDRESS udf 344H /* Up-down flag */ #pragma ADDRESS ta0 346H /* Timer A0 register */ #pragma ADDRESS ta0mr 356H /* Timer A0 mode register */ #pragma ADDRESS ta0ic 6cH /* Timer A0 interrupt control register */ unsigned char p5, pd5; unsigned char tabsr, udf, ta0mr, ta0ic; unsigned int ta0; /******************************************** * proto-type declaration ********************************************/ void ta0int(); #pragma INTERRUPT ta0int void main(void); void indicate(void); /*********************************************************************** *** * Function : main() * program section ************************************************************************ **/ void main() { p5 = 0xFF; pd5 = 0xff; udf = 0x01; // Timer increment ta0mr = 0x00; // 0000 0000 also durch 1 // 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 // 11: fc32 ta0 = 0xffff; // Set up Timer A0 Reload Register ta0ic = 0x07; // ---- XXXX hier interruptlevel 7 // |||| // |||+-- 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 tabsr = 0x01; // Timer start flag bit asm( "\tFSET I"); while(1); } /*********************************************************************** *** * Function : ta0int() * program section ************************************************************************ **/ void ta0int() { p5 ^= 0x00; //p5 = 0x00; indicate(); } /*********************************************************************** *** * Function : indicate() * program section ************************************************************************ **/ void indicate() { return; }
Was soll denn da blinken? p5 ^= 0x00; mit 0x00 xor'n ändert doch nichts. Eine 1 zum Bitkippen muß da schon drin sein. MooseC
Danke für Hinweis. Hab Fehler jetzt selber gefunden ( nach langem Grübeln ). Und zwar liegt das Problem in der Initialisierung der Timervariablen. Der M32C83 hat nicht mehr die f32 Clocksource. D.h mit einem Teilungsfaktor von 8 und entsprechender Änderung des TA0 Registers funktioniert es. Hier ein kleiner Ausschnitt. Werde kompletten Code ins Forum Codesammlung stellen. Gruß Dietmar 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 //
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.