跳转到主内容
Knowledgebase
Home
Renesas Electronics China - Knowledgebase

How to read out the whole ROM area?

Latest Updated:05/18/2015

Question:

I am using the CC-RL compiler for RL78 devices. How can I read out the whole ROM area?

Answer:

You need access with the far attribute, since mirror areas and non-mirror areas are present in ROM from the MCU’s point of view. Declare the addresses to be accessed as unsigned long type; and access a far pointer after casting, since the CC-RL C compiler has a specification for only changing the 2 lower-order bytes as a result of addition to and subtraction from far pointers.

Example:
int data;
#define TOPADDR 0x00000
#define ENDADDR 0x20000
unsigned char sumdata;
void chksum(void)
{
	unsigned long addr = TOPADDR;
	unsigned char sum = 0x00;
	do{
	
	sum += *(__far const unsigned char *)addr;
		addr++;
	}while(addr !=ENDADDR);
	sumdata = sum;
} 		
Suitable Products
e² studio
CS+ (formerly CubeSuite+)
C Compiler Package for RL78 Family