ETC HOW

APPLICATION NOTE
M16C/62 Group
How to check the Flash Version on M16C/62
1.0 Abstract
The following article introduces and shows an example of how to check the internal Flash Version on M16C/62
group device.
2.0 Introduction
The Flash devices of the M16C/62 group have various types of Flash inside. Depending on the exact
typenumber of the microcontroller, different Flash technologies and processes are used. The M16C/62A series
has for example DINOR Flash technology inside, whereas the M16C/62P series utilizes HND Flash
technology. If more than one series is used in a product and the program needs to be updated in the field, it is
required to detect the correct type in order to apply the correct Flash programming algorithm in CPU
programming mode.
Here a method is presented how to do this for any M16C series by a “Flash identification register”.
REB05B0002-0102Z
May 2003
Page 1 of 5
M16C/62 Group
How to check the Flash Version on M16C/62
3.0 Contents
3.1 The Flash identification register
The Flash identification register is a register not mentioned in the datasheet.
At M16C/62P series (0.2HND Flash technology) it is located at 01B4h.
At M16C/62A and M16C/62M series (0.5 DINOR Flash technology) it is located at 03B4h.
At M16C/62N series (0.35 HND Flash technology) it is also located at 03B4h.
A special procedure is needed to read out the correct value from this register.
Structure of the Flash identification register:
Flash identification register
Symbol
FIDR
Address
01B4H (M16C/62P series)
03B4h (M16C/62A, M16C62M, M16C/62N)
Bit
Symbol
Bit Name
FIDR0
Flash identification value
FIDR1
Function
Flash value output
DINOR:
0.35 HND:
0.2 HND:
b0 b1
1 1 (Note 1)
0 0
1 0
Nothing is assigned to these bits. In an attempt to write to these bits, please write
“0”. The value, if read, is indeterminate.
Read/Write
R
W
0
X
0
X
0
X
Note 1: This value is kept on the internal data bus latch. If external memory area or
SFR area is accessed during the readout procedure, the data may be changed.
Note 2: Although this register cannot be written, a special writing step is needed in order
to read out the correct value
3.2 Readout procedure
The readout procedure is shown in figure 1. This procedure is valid for any M16C/62 series, regardless of the
address of the Flash identification register. Before reading out the value of the Flash identification register
FIDR, ‘FFh’ must be written to it.
Please note, that the FIDR value is kept into the internal data bus latch. Therefore, if external memory
or SFR area is accessed between writing ‘FFh’ and reading out the value, the value that is read out,
may be changed.
Hence it is required to stop any access of external memory or SFR area between step 1 and step 2 and
between step 4 and step 5. Furthermore the interrupts and the DMA must be disabled.
REB05B0002-0102Z
May 2003
Page 2 of 5
M16C/62 Group
How to check the Flash Version on M16C/62
step 1
Write ‘FFh’ to the address 01B4h
step 2
read out value
step 3
value of 2 LSBs
equals 10b?
Yes
M16C/62P Series
(0.2 HND Flash)
No
step 4
step 5
step 6
Write ‘FFh’ to the address 03B4h
read out value
value of 2 LSBs
equals ‘00b’?
Yes
M16C/62N Series
(0.35 HND Flash)
No
M16C/62A Series or M16C/62M Series
(0.5 DINOR Flash)
Figure 1: Flow diagram how to check M16C/62 Flash versions
4.0 Reference
Renesas Technology Corporation Semiconductor Home Page
http://www.renesas.com/
Contact for Renesas Technical Support
E-mail: [email protected]
Data Sheet
M16C/62A Group
M16C/62M Group
M16C/62N Group
M16C/62P Group
(Use the latest version on the home page: http://www.renesas.com/)
User’s Manual
M16C/62A Group
(Use the latest version on the home page: http://www.renesas.com/)
REB05B0002-0102Z
May 2003
Page 3 of 5
M16C/62 Group
How to check the Flash Version on M16C/62
5.0 Programming Code
This example program is a function written in generic C. So it should work with any C compiler. According to
the return code the functions for Flash programming in CPU programming mode should be selected. These
functions can be derived for example from the appropriate bootloader programs.
#define FIDR_ADDR_1
#define FIDR_ADDR_2
(*(unsigned int *)0x1B4)
(*(unsigned int *)0x3B4)
// FIDR on M16C/62P series
// FIDR on M16C/62A,M,N series
#define FLASH_TYPE_M16C62N
#define FLASH_TYPE_M16C62P
#define FLASH_TYPE_M16C62A_M
0x00
0x02
0x03
// value of FIDR for M16C/62N
// value of FIDR for M16C/62P
// value of FIDR for M16C/62A or M16C/62M
#define DUMMY_VALUE
0xFF
// value to write to Flash Identification register
#define FIDR_BITMASK
0x03
// Only 2 LSBs count
unsigned char CheckFlashVersion (void)
{
unsigned char FlashType;
// return value
FIDR_ADDR_1 = DUMMY_VALUE;
FlashType = FIDR_ADDR_1;
FlashType &= FIDR_BITMASK;
// write FF to 01B4h
// read out value
// mask out all other bits
if (FlashType == FLASH_TYPE_M16C62P)
{
return (FlashType);
// It is M16C/62P
}
else
{
FIDR_ADDR_2 = DUMMY_VALUE;
// write FF to 03B4h
FlashType = FIDR_ADDR_2;
// read out value
FlashType &= FIDR_BITMASK;
// mask out all other bits
}
if(FlashType == FLASH_TYPE_M16C62N)
{
return(FlashType); // It is M16C/62N
}
else
{
return(FLASH_TYPE_M16C62A_M); // It is M16C/62A or M16C/62M
}
}
REB05B0002-0102Z
May 2003
Page 4 of 5
Keep safety first in your circuit designs!
• Renesas Technology Corporation puts the maximum effort into making semiconductor products
better and more reliable, but there is always the possibility that trouble may occur with them.
Trouble with semiconductors may lead to personal injury, fire or property damage.
Remember to give due consideration to safety when making your circuit designs, with appropriate
measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of nonflammable material
or (iii) prevention against any malfunction or mishap.
Notes regarding these materials
• These materials are intended as a reference to assist our customers in the selection of the Renesas
•
•
•
•
•
•
•
Technology Corporation product best suited to the customer's application; they do notconvey any
license under any intellectual property rights, or any other rights, belonging to Renesas Technology
Corporation or a third party.
Renesas Technology Corporation assumes no responsibility for any damage, or infringement of any
third-party's rights, originating in the use of any product data, diagrams, charts, programs,
algorithms, or circuit application examples contained in these materials.
All information contained in these materials, including product data, diagrams, charts, programs and
algorithms represents information on products at the time of publication of these materials, and are
subject to change by Renesas Technology Corporation without notice due to product improvements
or other reasons. It is therefore recommended that customers contact Renesas Technology
Corporation or an authorized Renesas Technology Corporation product distributor for the latest
product information before purchasing a product listed herein.
The information described here may contain technical inaccuracies or typographical errors.
Renesas Technology Corporation assumes no responsibility for any damage, liability, or other loss
rising from these inaccuracies or errors.
Please also pay attention to information published by Renesas Technology Corporation by various
means, including the Renesas Technology Corporation Semiconductor home page
(http://www.renesas.com).
When using any or all of the information contained in these materials, including product data,
diagrams, charts, programs, and algorithms, please be sure to evaluate all information as a total
system before making a final decision on the applicability of the information and products. Renesas
Technology Corporation assumes no responsibility for any damage, liability or other loss resulting
from the information contained herein.
Renesas Technology Corporation semiconductors are not designed or manufactured for use in a
device or system that is used under circumstances in which human life is potentially at stake.
Please contact Renesas Technology Corporation or an authorized Renesas Technology
Corporation product distributor when considering the use of a product contained herein for any
specific purposes, such as apparatus or systems for transportation, vehicular, medical, aerospace,
nuclear, or undersea repeater use.
The prior written approval of Renesas Technology Corporation is necessary to reprint or reproduce
in whole or in part these materials.
If these products or technologies are subject to the Japanese export control restrictions, they must
be exported under a license from the Japanese government and cannot be imported into a country
other than the approved destination.
Any diversion or reexport contrary to the export control laws and regulations of Japan and/or the
country of destination is prohibited.
Please contact Renesas Technology Corporation for further details on these materials or the
products contained therein.