SSブログ

Found an incorrect implementation of MTIM module on MC9RS08KA8 simulator [CodeWarrior]このエントリーを含むはてなブックマーク#

This is a report regarding an incorrect implementation of MTIM modules found on the MC9RS08KA8 Full Chip Simulation.

Relation between Modulus and Modulo Register

The MTIM module is a simple timer to make a periodic events and/or interrupts. There is an 8-bit register named MTIM Modulo Register (MTIMMOD) to specify the PERIOD of the events. The MTIM compares an 8-bit counter (MTIMCNT) value and the MTIMMOD value, and cause an overflow event if a prescaled clock input comes when the MTIMCNT value matches to the MTIMMOD value. As the result, the event PERIOD equal to (MTIMMOD + 1) multiplied by the prescaled clock period.

Confirmed Event Period by Full Chip Simulation

A function is written to make a delay specified by a parameter in 100usec unit.

void wait_100us(byte n) {
  MTIM2SC  = 0x30;      // Stop & Reset MTIM
  MTIM2CLK = 0x01;      // Prescale BUSCLK*2
  MTIM2MOD = 249;       // 100usec
  MTIM2SC  = 0x00;      // Start MTIM
  while (n-- > 0) {
    while (!MTIM2SC_TOF) ;  // Wait for the flag
    MTIM2SC_TOF = 0;    // Clear the flag
  }
}

The MTIM events occurs in every 100usec when the BUSCLK is adjusted to 5MHz. Prior to a programming to the MCU, the MTIM event period is confirmed by the full chip simulation. When a breakpoint is set to the statement "MTIM2SC_TOF = 0;" the simulation stops at following cycles.

CPU CyclesDifference
745-
1243498
1741498
2239498
2737498
3235498
3733498

It is expected that all difference between two cycle counts is 500. But, all of the difference value are 498. It is very strange.

MTIMCNT expires when (MTIMMOD - 1)

It was also confirmed that the MTIMCNT counter value returns to 0 from (MTIMMOD - 1) by increasing the prescaled clock period. This is an incorrect implementation against the MTIM module's "Functional Description" in the MC9RS08KA8 datasheet.

There are two MTIM modules MTIM1 and MTIM2 in the MC9RS08KA8. It was confirmed that both MTIM modules seems to have incorrect implementation.

2009-03-25 : Appended

It was notified by the Service Request that this problem was recognized as a bug with a bug tracking number MTWX34191.

Reference

HCS08 Unleashed: Designer's Guide to the HCS08 Microcontrollers

HCS08 Unleashed: Designer's Guide to the HCS08 Microcontrollers

  • 作者: Fabio Pereira
  • 出版社/メーカー: Booksurge Llc
  • 発売日: 2007/11/13
  • メディア: ペーパーバック

nice!(0)  コメント(0)  トラックバック(0)  このエントリーを含むはてなブックマーク#

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 0

トラックバックの受付は締め切りました