See also "Common Items FAQ : Cautions Regarding Bit Manipulation"
Programming
Contents
FAQ-ID = v85prog- nnnn
v85prog -0001
|
Signed extension of MOVEA instruction
|
| Q1 |
In order to jump to the address that is the sum of 0x718002 word data and 0x718000,
I expected r25 to become 0x718000 after MOVEA instruction execution,
but it actually becomes 0x708000.
|
| A1 |
This is because it is calculated as a 16-bit immediate value sign-extended to 32 bits.
That is, when 0x8000 is sign-extended with MOVEA,
it becomes 0xFFFF8000 because the MSB is 1.
It is then added, resulting in 0x708000.
To avoid this effect (that is, the higher 16 bits are subtracted by one),
make the preset higher value 0x0072 instead of 0x0071.
|
v85prog -0101
|
What should be done (commonly) first after reset and start [common to V850]
|
| Q1 |
I want to use the V850 to develop a program for the first time, but I don't understand the processing that must be performed first,
in addition to the processing that must be executed by the program.
|
| A1 |
Before actually executing your program, these things must be completed.
(1) Common initial settings that are essential for the device
(2) Initial settings of the internal peripheral I/O in accordance with your usage
The setting of (1) includes
- Setting internal peripheral access time by using the VSWC register
- Setting of operating clock (PLL mode or direct mode, and division ratio)
- Setting related to the standby mode
- Setting of the watchdog timer
The setting related to (2) includes
- Initial setting as a port
- Initial settings of alternate-function ports related to the internal peripheral I/O to be used
(For the specifics, refer to the description in the manual concerning the setting for using the alternate function of ports.)
- Initial settings of the internal peripheral I/O to be used.
|
| |
| Q2 |
When a microcontroller is started, execution starts from the reset handler.
I don't understand how this is connected to execution of the main program that is described.
|
| A2 |
Processing of the part from the reset handler to the main program is performed by a "start-up file".
Specifically, a branch instruction to the start-up routine is generated in the reset handler, therefore, the start-up routine is executed first.
This routine sets and defines variables.
When initial settings of the variables have been completed, the main function of the program you created is called by a subroutine call instruction, and the main program is thus executed.
Usually, processing that is executed first after the microcontroller is started (part (1) of A1) is described before a subroutine call of the main function.
|
 |
|
(2006/04)
|
 |
|
|