M32 C83 Mitsubishi Microcontroller

Gast #45398
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;
}
Gast #45403
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 //

Antwort schreiben

Eine eigene Frage? Dieser Thread ist über 23 Jahre alt. Stell sie in einem eigenen Thread – dort lesen mehr Leute mit, und sie wird öfter und schneller beantwortet.

Neuen Thread starten

Eine Lösung, Ergänzung oder Rückmeldung zu diesem Thread? Dann antworte hier.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.