메인 콘텐츠로 건너뛰기
Knowledgebase
Home
Renesas Korea

Using M3S-T2-Tiny sample driver program, TIMER_CNT value is wrong.

Latest Updated:08/29/2008

Question:

I'm using the M3S-T2-Tiny sample driver program but the TIMER_CNT constant value is incorrect.

Answer:

You can correct the corresponding eth_drv.c and ppp_drv.c locations as follows.

Before corrections:
--------------------------------------------------------------------------------
#define _TCP_UNIT_TIME 10
#define MPU_CLOCK 20000000 /* Hz */
#define TIMER_CNT ((_TCP_UNIT_TIME*1000/1000)*(long)MPU_CLOCK/(2048*1000))
--------------------------------------------------------------------------------

After Corrections:
--------------------------------------------------------------------------------
#define _TCP_UNIT_TIME 10L
#define MPU_CLOCK 20000000L /* Hz */
#define TIMER_CNT ((_TCP_UNIT_TIME*1000L/1000L)*MPU_CLOCK/(2048L*1000L))
--------------------------------------------------------------------------------

Before the above corrections are made, the code is compiler-dependant.

When the value exceeds the int-type value range during calculation of the constant expression, the calculation process is compiler-dependant, and in NC30 V.5.40 Release 00 and previous versions, the correct result is achieved. But in NC30 V.5.42 Release 00 and later versions and in H8 compilers, the results of the calculations provide an incorrect value.

By adding "L" to the end of the constant, as in the corrected code, the type of constant is clearly indicated and the correct value is calculated.
Suitable Products
M3S-T2-Tiny