Option bytes (78K0/Kx2, 78K0S/Kx1+)
Contents
FAQ-ID = opb- nnnn
opb -0001
|
Option bytes settings (common for 78K0/Kx2, 78K0S/Kx1+)
|
| Q1 |
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;
|
| A1 |
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
END
For further description of how to use option bytes and protect bytes, see the target device's manual.
|
 |
|
(2007/11)
|
 |
|
opb -0002
|
Option bytes (78K0/Kx2, 78K0S/Kx1+)
|
[Preface]
All series of microcontrollers (MCUs) share the same basic functions (instruction set, architecture, etc.), but some of their on-chip functions differ according to the package (pin number), and even different models that use the same package can have different amounts of on-chip memory (flash memory, RAM, etc.). In conventional microcontrollers, detailed functions (such as port pull-up resistance and POC voltage) have been specified as mask options when writing programs to ROM. However, since PROM devices and flash memory devices do not have mask program writing processes, they cannot have mask options.
As for most port pull-up resistances, these can be set by software, but there are still functions such as POC voltage that cannot be set by software.
Coffee Break
When a port's pull-up resistance can be set by software, it greatly increases freedom in using pull-up resistance. In particular, products that feature on-chip flash memory can be modified after they are shipped. On the other hand, they are not valid as soon as the power is turned ON, as are mask options. Resistance does not become valid until the software that sets the pull-up resistance is executed.
Since the POC voltage specifies the supply voltage used to enable execution of software, it is in principle impossible to set it by software. It is therefore important to make the distinction between what can and cannot be set by software.
[Support by flash devices]
Products such as the 78K0/Kx1 microcontrollers that include mask devices and flash memory devices, offer a separate lineup of products that support mask options. See the description of the 78K0/Kx1 under the flash devices section of this FAQ.
In such cases, when the product needs only to have certain mask options it is important to select precisely to obtain the desired functions. In particular, the devices that serve the desired objective may change due to revisions in related specifications, in which case different devices must be selected.
A new support approach called "option byte" is used in all-flash 8-bit microcontrollers such as the 78K0/Kx2 and the 78K0S/Kx1+. The available options and the specification format differ among different devices.
[Option byte]
The option byte is assigned to a specified address in the microcontroller's on-chip flash memory (the address that is used is the start address for the ordinary program memory, which starts at 80H).
When the microcontroller is started, such as by power-on or reset, first the option byte setting is referenced, and the setting is reflected in the microcontroller's functions. Next, the application program starts from the address indicated by the reset vector at address 0.
|
|
| |
| Q1 |
When using the 78F0533, should ordinary programs be coded in the reserved space from 0x0080 to 0x0085?
|
| A1 |
Even when a program has been coded in this space, the device interprets any address there as an option byte specification. Operation will not be normal if the setting in that space differs from the originally intended function.
In the 78K0/Kx2 or 78K0S/Kx1+ microcontroller, the operations at startup are as follows.
<1> Settings in option byte area are referenced.
The option functions corresponding to the settings in the option byte area are selected. This operation is always executed automatically as a hardware function, and is never disabled or revised.
<2> The program that starts at the address specified as the reset vector is executed. Afterward, the user-specified programs are executed, so once the address of a program that has been assigned to the option byte area is specified, the program is executed.
Coffee Break
The 78K0/Kx2 and 78K0S/Kx1+ microcontrollers are included as microcontroller architectures in the 78K0 and 78K0S Series. This architecture itself does not include the option byte, and the 78K0/Kx2 and 78K0S/Kx1+ microcontrollers are the first to feature an option byte.
Since the option byte is not supported as part of the architecture, when a program is specified in the option byte area, the option byte is interpreted as an opcode, thus attempting to execute instructions.
Note also that the option byte is not yet supported by the RA or CC.
A simple way to support option bytes is to prepare a separate file that only specifies the option byte and to include this file in the build (as an assembled or compiled and linked file). For detailed description of how this is done, see the FAQ section describing option byte settings (common for the 78K0/Kx2 and 78K0S/Kx1+ microcontrollers). This method enables the option byte to be working into programs without having to pay particular attention to it.
|
|
 |
|
(2007/11)
|
 |
|
|