Skip to main content
Renesas Electronics America - Knowledgebase

How to read the entire ROM area in the CA78K0R compiler?

Latest Updated:11/21/2014


I am using the CA78K0R compiler for RL78 and 78K0R products. Please show me how to read the entire ROM area.


In microcontrollers of these types, since the ROM area includes mirrored areas and non-mirrored areas, the far attribute must be used in access to locations in the ROM area. Additionally, the CA78K0R C compiler has the specification that only the two lower-order bytes are changed in addition and subtraction for the far pointer. Therefore, access to an address in ROM requires definition with the unsigned long type and access by casting to the far pointer.

#define TOPADDR 0x00000
#define ENDADDR 0x20000
unsigned char sumdata;
void chksum(void)
	unsigned long addr = TOPADDR;
	unsigned char sum = 0x00;
		sum += *(__far const unsigned char *)addr;
	}while(addr !=ENDADDR);
	sumdata = sum;
Suitable Products
C Compiler Package for RL78 and 78K Families
Compiler for RL78 Family and 78K0R [CA78K0R]
Compiler for 78K0R [CC78K0R]