Skip to main content
Renesas India - Knowledgebase

Can you expound the ways about the specify option bytes in C language?

Latest Updated:11/01/2007


What should I do when I am not able to specify option bytes in C language?
How to program the following to specify option bytes in C language?

#define  OPTION_BYTE (*(volatile unsigned char *)0x0080)  /* Option bytes */
void main(void) {
   OPTION_BYTE = 0xF9;


When coding a program in C language, it is not possible to include an option byte in the C language code. For an option byte, reset must be canceled and the option byte code must be referenced as hardware before executing the program. Accordingly, it is not something that can be replaced by a program.

An option byte must first be written to address 80H in flash memory. To do that, a code must be prepared as part of the program. The simplest way to do this is to prepare an assembly language file that contains a DB pseudo instruction which sets values only for the option byte definition, and then to set that file as a source.
For example, when using the 78K0S/Kx1+, a file coded as shown below can be prepared. User can name this file "opt.asm" and then go to PM+'s Project menu, select "Add source file", and add opt.asm as a source file. When creating a new project, the addition of source files can be specified as a default setting.

	@@OPTB	CSEG 	AT	0080H
	DB	11111001b		; Option byte
	DB	11111111b		; Protect byte

For further description of how to use option bytes and protect bytes, see the target device's manual.

Suitable Products