Page 1
On April 1 , 2010, NEC Electronics Corporation merged with Renesas Technology Corporation, and Renesas Electronics Corporation took over all the business of both companies. Therefore, although the old company name remains in this document, it is a valid Renesas Electronics document. We appreciate your understanding.
Page 2
Renesas Electronics. Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an application categorized as “Specific”...
Page 3
Application Note Inverter Control by V850 Series 120° Excitation Method Control by Zero-Cross Detection V850E/IA1 V850E/IA2 V850E/IA3 V850E/IA4 V850E/MA3 Document No. U17209EJ1V0AN00 (1st edition) Date Published September 2004 N CP(K) 2004 Printed in Japan...
Page 5
NOTES FOR CMOS DEVICES VOLTAGE APPLICATION WAVEFORM AT INPUT PIN Waveform distortion due to input noise or a reflected wave may cause malfunction. If the input of the CMOS device stays in the area between V (MAX) and V (MIN) due to noise, etc., the device may malfunction.
Page 6
These commodities, technology or software, must be exported in accordance with the export administration regulations of the exporting country. Diversion contrary to the law of that country is prohibited. • The information in this document is current as of July, 2004. The information is subject to change without notice.
Page 7
Regional Information Some information contained in this document may vary from country to country. Before using any NEC Electronics product in your application, pIease contact the NEC Electronics office in your country to obtain a list of authorized representatives and distributors. They will verify: •...
Page 8
INTRODUCTION Target Readers This application note is intended for users who understand the functions of the V850E/IA1, V850E/IA2, V850E/IA3, V850E/IA4, and V850E/MA3, and who design application systems that use these microcontrollers. The applicable products are shown below. • V850E/IA1 µ Standard products: PD703116, 70F3116 µ...
V850E/IA3, V850E/IA4 Hardware User’s Manual U16543E V850E/MA3 Hardware User’s Manual U16397E V850E/IA1, V850E/IA2 AC Motor Inverter Control Using Vector U14868E Operation Application Note Inverter Control by V850 Series 120° Excitation Method Control by Zero- This manual Cross Detection Application Note Application Note U17209EJ1V0AN...
Page 10
Documents related to development tools (user’s manuals) Document Name Document No. IE-V850E-MC, IE-V850E-MC-A (In-Circuit Emulator for V850E/IA1, U14487E V850E/IA2) IE-V850E1-CD-NW (PCMCIA Card Type On-Chip Debug Emulator for U16647E V850E/IA3, V850E/IA4, V850E/MA3) IE-703116-MC-EM1 (In-Circuit Emulator Option Board for V850E/IA1) U14700E IE-703114-MC-EM1 (In-Circuit Emulator Option Board for V850E/IA2) U16533E CA850 Ver.
CHAPTER 1 CONTROL METHOD Outline of Brushless DC Motor Control A brushless DC (BLDC) motor consists of a stator, coil, and rotor. The rotor, which includes a permanent magnet, is rotated by the action of the magnetic field generated by the coil of the stator. The magnetic field is generated by exciting the coil wound around the stator in a specific sequence.
Page 15
CHAPTER 1 CONTROL METHOD Figure 1-1. Three-Phase DC Motor Voltage Waveform <1> <2> <3> <4> <5> <6> U phase U phase Driving voltage waveform V phase V phase W phase W phase U phase Induced voltage V phase waveform W phase Application Note U17209EJ1V0AN...
Page 16
CHAPTER 1 CONTROL METHOD Figure 1-2. Rotor Position Detection Principle Magnetic W-phase stator flux is located in the center of the N pole and S pole of a magnet rotor (a) Rotor position <1> … U-phase stator: S pole (b) Rotor position <2> … U-phase stator: S pole V-phase stator: N pole V-phase stator: Center point W-phase stator: Center point...
Page 17
CHAPTER 1 CONTROL METHOD Figure 1-3. Configuration of Three-Phase Brushless DC Motor PWM control Zero-cross point detection Application Note U17209EJ1V0AN...
Page 18
CHAPTER 1 CONTROL METHOD The 120° control method for a BLDC motor without a sensor is described below. To control a BLDC motor, the rotor position must be known. To control a BLDC motor without a sensor, the rotor position is estimated using induced voltage. The induced voltage is in phase with the driving voltage waveform and its waveform is close to a sine wave, as shown in Figure 1-1.
CHAPTER 2 HARDWARE CONFIGURATION This chapter describes the hardware configuration. Configuration The reference system’s main functions are described below. In this reference system, when the revolution specification switch is pressed after power application, the motor starts revolving in the direction specified. Figure 2-1.
Page 20
CHAPTER 2 HARDWARE CONFIGURATION (1) Volume for speed control Volume for increasing and decreasing the number of revolutions of the motor (2) Revolution specification SW CW, CCW, and STOP switches (3) LED display LED displaying the number of revolutions, operation time, etc. (4) WDT Watchdog timer (5) Driver IC...
CHAPTER 2 HARDWARE CONFIGURATION Circuit Diagram Figures 2-2 to 2-6 show diagrams of the sample reference system circuit. This sample reference system circuit diagram includes the V850E/IA1, V850E/IA2, V850E/IA3, V850E/IA4, or V850E/MA3, a reset circuit, oscillator, a pin handling microcontroller peripheral block, operation mode switch block, LED output block, watchdog timer circuit block, drive circuit block, motor controller, and motor revolution indicator.
CHAPTER 3 SOFTWARE CONFIGURATION Control Block Figure 3-1 shows a diagram of the software control block of the reference system. Figure 3-1. Diagram of Software Control Block of Reference System Control by microcontroller <6> conver- <7> sion Current monitor conver- sion <3>...
CHAPTER 3 SOFTWARE CONFIGURATION Peripheral I/O The following types of peripheral I/O functions are used in this reference system. Table 3-1. List of Peripheral I/O Functions Peripheral I/O Peripheral I/O Peripheral I/O Peripheral I/O Peripheral I/O Function Function Name Function Name Function Name Function Name Function Name...
Page 30
CHAPTER 3 SOFTWARE CONFIGURATION (1) Description of peripheral I/O functions (a) Inverter timer Inverter timers are used to output PWM waveforms. In this application circuit example, the settings are as shown below. • 20 kHz symmetrical triangular waveform mode • Dead time: 6 µ...
CHAPTER 3 SOFTWARE CONFIGURATION Software Processing Structure The software processing structure is shown below. Figure 3-2. Main Processing Structure Operation Operation Processing (STOP CW) (STOP CCW) revolution revolution during processing processing deceleration Detection time processing revolution operation revolution operation STOP processing Application Note U17209EJ1V0AN...
Page 32
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-3. Interrupt Processing Structure (a) Motor control processing (b) Control pin selection processing (c) Wait timer processing U, V, W change interrupt Control pin Wait timer Motor control selection µ s interval interrupt 10 ms interval interrupt processing processing processing...
CHAPTER 3 SOFTWARE CONFIGURATION Flowchart 3.4.1 Main processing Figure 3-4 shows the flowchart of the main processing. Application Note U17209EJ1V0AN...
Page 34
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-4. Main Processing START : Refer to 4.1.5, 4.2.5, 4.3.5, 4.4.5, 4.5.5 Main processing function. hinit : Refer to Figure 3-20 Hardware Initialization. (hardware initialization) ainit : Refer to Figure 3-21 Common Area Initialization. (used area initialization) Enable interrupts SW CW pressed? SW mode = CW...
Page 35
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-5. Case 0 (Processing During Stoppage) SW mode = CW? Disable interrupts Disable interrupts Initialize target speed and request Initialize target speed and request CCW initialization CCW initialization Enable interrupts Enable interrupts 禁 Processing number 1 Processing number 4 Application Note U17209EJ1V0AN...
Page 36
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-6. Case 1 (CW Acceleration Processing) Initialization of acceleration/deceleration counter 0 ends? Re-set acceleration/deceleration counter Target speed < Indication speed? Increase target speed Set speed monitor start timer to 5 seconds Target speed > Indication speed? Decrease target speed Set speed monitor start timer to 5 seconds Processing number 2...
Page 37
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-7. Case 2 (CW Constant-Speed Processing) Indication speed as target speed SW mode = CCW or STOP? Processing number 3 Figure 3-8. Case 3 (CW Stop Processing) Acceleration/deceleration counter = 0? Re-set acceleration/deceleration counter Target speed > Indication speed? Decrease target speed Set stop flag to on and processing Set speed monitor start time to 5 seconds...
Page 38
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-9. Case 4 (CCW Acceleration Processing) Initial operation ends with acceleration/deceleration counter = 0? Re-set acceleration/deceleration counter Target speed < Indication speed? Target speed > Indication speed? Increase target speed Set speed monitor start time to 5 seconds Decrease target speed Set speed monitor start time to 5 seconds Processing number 5...
Page 40
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-12. Detect Wait (1/2) Processing number 2 or 5? Speed monitor starts? Present speed < Error speed? Set error number ERR_NO3 Stop flag on PWM output off Application Note U17209EJ1V0AN...
Page 41
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-12. Detect Wait (2/2) Display average counter = 0? Set display average counter to 100 led_num (Present average speed indication) led_num (Control period indication) led_num (Interrupt processing time indication) led_num (Operation processing time indication) Error flag on? 7-segment display off 500 ms? Error number 1?
CHAPTER 3 SOFTWARE CONFIGURATION 3.4.2 Motor control processing Figure 3-13. Control Interrupt Processing (1/5) Motor_CONT : Refer to 4.1.7, 4.2.7, 4.3.7, 4.4.7, 4.5.7 Motor control interrupt processing function. fcalcu (speed calculation) Convert radian to rpm value Speed counter = 0? Re-set speed counter Calculate total speed value from present value of speed counter...
Page 43
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-13. Control Interrupt Processing (2/5) Stop flag on? All phases of PWM port off Operation start output Get display timer start value Clear PWM output prohibition Reset watchdog timer Initial flag on? Initial revolution processing Increment initial counter Same output pattern continues to be output Initial counter >...
Page 44
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-13. Control Interrupt Processing (3/5) U phase high side output on? U phase comparison value = 0 V phase high side output on? V and W phase comparison values = Initial value W phase comparison value = 0 V phase comparison value = 0 High side is valid by U and V phase comparison...
Page 45
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-13. Control Interrupt Processing (4/5) Normal revolution processing Speed difference = Target speed – Present speed Calculate PWM output value Speed integral value > MAX. value? Speed integral value < −MAX. value? Speed integral value = MAX. value Speed integral value Speed integral value = −MAX.
Page 46
CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-13. Control Interrupt Processing (5/5) Read present PWM output pattern U phase high side output on? U phase comparison value = 0 U phase high side output on? Set V and W phase comparison values V phase comparison value = 0 W phase comparison value = 0 Set U and W phase comparison...
CHAPTER 3 SOFTWARE CONFIGURATION 3.4.3 U zero-cross point interrupt processing Figure 3-14. U Zero-Cross Point Interrupt Processing : Refer to 4.1.8, 4.2.8, 4.3.8, 4.4.8, 4.5.8 Zero-cross interrupt processing function. int_p20 Initial flag off and stop flag off? Capture speed measuring timer value and restart Set reference position from other phase status Target revolution CCW? Extract output pattern from CCW table according...
CHAPTER 3 SOFTWARE CONFIGURATION 3.4.4 V zero-cross point interrupt processing Figure 3-15. V Zero-Cross Point Interrupt Processing : Refer to 4.1.8, 4.2.8, 4.3.8, 4.4.8, 4.5.8 Zero-cross interrupt processing function. int_p21 Initial flag off and stop flag off? Capture speed measuring timer value and restart Set reference position from other phase status Target revolution CCW? Extract output pattern from CCW table according...
CHAPTER 3 SOFTWARE CONFIGURATION 3.4.5 W zero-cross point interrupt processing Figure 3-16. W Zero-Cross Point Interrupt Processing : Refer to 4.1.8, 4.2.8, 4.3.8, 4.4.8, 4.5.8 Zero-cross interrupt processing function. int_p22 Initial flag off and stop flag off? Capture speed measuring timer value and restart Set reference position from other phase status Target revolution CCW? Extract output pattern from CCW table...
CHAPTER 3 SOFTWARE CONFIGURATION 3.4.7 A/D converter channel 0 interrupt processing Figure 3-18. A/D Converter Channel 0 Interrupt Processing : Refer to 4.1.10, 4.2.10, 4.3.10, 4.4.10, 4.5.10 A/D converter interrupt int_ad0 processing function. Read U phase current value | Current value | > MAX_I? U, V, W phase output off Set error flag Read V phase current value...
CHAPTER 3 SOFTWARE CONFIGURATION 3.4.9 Hardware initialization Figure 3-20. Hardware Initialization hinit : Refer to 4.1.11, 4.2.11, 4.3.11, 4.4.11, 4.5.11 Hardware initialization processing function. Initialization of port used 7-segment LED extinguished 10 ms timer setting Motor control timer setting Speed measuring timer setting Initialization of inverter timer All phases active A/D initialization...
CHAPTER 3 SOFTWARE CONFIGURATION 3.4.10 Common area initialization Figure 3-21. Common Area Initialization : Refer to 4.1.12, 4.2.12, 4.3.12, 4.4.12, 4.5.12 Common area ainit initialization processing function. • Error flag off • Initial flag off • Clear display counter • Stop flag on •...
CHAPTER 3 SOFTWARE CONFIGURATION 3.4.12 LED display Figure 3-23. LED Display : Refer to 4.1.6, 4.2.6, 4.3.6, 4.4.6, 4.5.6 LED display function. led_num Area 1? Revolution Display 4 digits of area 1 speed Area 2? Control Display 2 digits of area 2 period Area 3? Control P processing time...
CHAPTER 3 SOFTWARE CONFIGURATION Common Areas The following table shows the major common areas used by the reference system. Table 3-2. Common Area List Symbol Type Usage Set Value error_flag unsigned char Error flag 0: No error ERR_NO1: Overcurrent ERR_NO3: Speed difference error init_flag unsigned char Indicates initial revolution...
CHAPTER 3 SOFTWARE CONFIGURATION Tables (1) LED output pattern Contains display pattern data 0 to 9. unsigned short led_pat[10] = { 0xfc. 0x60, ~ }; (2) Initial CW output pattern Contains an output pattern for CW initial operation. unsigned short cw_data[6][2] = { { 0x09, 0x00 }, { 0x21, 0x00 }, ∼ }; Note Note The underlined values differ depending on the target microcontroller.
Page 58
CHAPTER 3 SOFTWARE CONFIGURATION (5) Normal CW revolution output pattern Contains an output pattern in accordance with the status of the zero-cross point during normal CW revolution. unsigned short run_cw_data[8][2] = { { 0x00, 0x00 }, { 0x21, 0x00 }, ∼ }; Note Note The underlined values differ depending on the target microcontroller.
CHAPTER 3 SOFTWARE CONFIGURATION Constant Definitions The following table shows the major constants used by the reference system. Symbol Usage Value π 3.141592 TH_U Radian value, jack-up constant 1000 2 × PAI × TH_U Radian value of one revolution OFFSET Original point OFFSET 1945 rpm →...
CHAPTER 4 PROGRAM LIST Program List (V850E/IA1) 4.1.1 Symbol definition /****************************************************************************** / Common area /****************************************************************************** / unsigned char ram_start ; unsigned char error_flag ; /* Error flag */ unsigned char init_flag ; /* Initial flag */ unsigned short cont_time ; /* Interrupt control time uSEC */ unsigned short cont_time1 ;...
CHAPTER 4 PROGRAM LIST extern signed short before_posi[21][2] ; /* Position buffer */ extern signed short total_sa ; /* Position total difference */ extern signed int sum_speed ; extern signed int speed_co ; extern signed int now_speed ; /* Present speed rms */ extern signed int object_speed ;...
Page 63
CHAPTER 4 PROGRAM LIST #define IQAMAX 200000 /* Maximum speed integral value */ #define MAX_I /* Maximum current value */ #define TS /* Motor control time interval uSEC */ #define ACCEL_TIME /* Acceleration/deceleration time */ /* constant 10 mSEC */ #define ACCEL_DATA /* Number of acceleration/deceleration */ /* incremental revolutions rpm */...
CHAPTER 4 PROGRAM LIST [r1] .section ".vect_ETC",text -4,sp st.w r1,[r3] #V_ETC,r1 [r1] .section ".vect_MOTOR",text -4,sp st.w r1,[r3] #V_MOTOR,r1 [r1] .section ".vect_AD0",text -4,sp st.w r1,[r3] #V_AD0,r1 [r1] .section ".vect_AD1",text -4,sp st.w r1,[r3] #V_AD1,r1 [r1] 4.1.4 Startup routine setting #============================================================================= # DESCRIPTIONS: This assembly program is a sample of start-up module for ca850.
Page 67
CHAPTER 4 PROGRAM LIST # sdata section gp -> -+-------------- + _ _ssbss # sbss section +-------------- + _ _stack _ _esbss _ _sbss | stack area # bss section | 0x400 bytes sp -> -+-------------- + _ _stack + STACKSIZE _ _ebss ep ->...
Page 68
CHAPTER 4 PROGRAM LIST #----------------------------------------------------------------------------- system stack #----------------------------------------------------------------------------- .set STACKSIZE, 0x400 .bss .lcomm _ _stack, STACKSIZE, 4 #----------------------------------------------------------------------------- start up pointers: tp - text pointer gp - global pointer sp - stack pointer ep - element pointer exit status is set to r10 #----------------------------------------------------------------------------- .text .align 4...
CHAPTER 4 PROGRAM LIST .L11: #_ _sbss, r13 -- clear bss section #_ _ebss, r12 r12, r13 .L14 .L15: st.w r0, [r13] 4, r13 r12, r13 .L15 .L14: jarl _main, lp -- call main function _ _exit: halt -- end of program _ _startend: #-------------------------- end of start up module ----------------------------# 4.1.5...
CHAPTER 4 PROGRAM LIST Program List (V850E/IA2) 4.2.1 Symbol definition /****************************************************************************** / Common area /****************************************************************************** / unsigned char ram_start ; unsigned char error_flag ; /* Error flag */ unsigned char init_flag ; /* Initial flag */ unsigned short cont_time ; /* Interrupt control time uSEC */ unsigned short cont_time1 ;...
CHAPTER 4 PROGRAM LIST extern signed int speed_co ; extern signed int now_speed ; /* Present speed rms */ extern signed int object_speed ; /* Target speed rms */ extern unsigned int d_speed ; /* Display speed rms */ extern unsigned char ram_end ;...
CHAPTER 4 PROGRAM LIST .section ".vect_ETC",text -4,sp st.w r1,[r3] #V_ETC,r1 [r1] .section ".vect_MOTOR",text -4,sp st.w r1,[r3] #V_MOTOR,r1 [r1] .section ".vect_AD0",text -4,sp st.w r1,[r3] #V_AD0,r1 [r1] .section ".vect_AD1",text -4,sp st.w r1,[r3] #V_AD1,r1 [r1] 4.2.4 Startup routine setting #============================================================================= # DESCRIPTIONS: This assembly program is a sample of start-up module for ca850. If you modified this program, you must assemble this file, and locate a given directory.
Page 93
CHAPTER 4 PROGRAM LIST gp -> -+-------------- + _ _ssbss # sbss section +-------------- + _ _stack _ _esbss _ _sbss | stack area # bss section | 0x400 bytes sp -> -+-------------- + _ _stack + STACKSIZE _ _ebss ep ->...
Page 94
CHAPTER 4 PROGRAM LIST #----------------------------------------------------------------------------- .set STACKSIZE, 0x400 .bss .lcomm _ _stack, STACKSIZE, 4 #----------------------------------------------------------------------------- start up pointers: tp - text pointer gp - global pointer sp - stack pointer ep - element pointer exit status is set to r10 #----------------------------------------------------------------------------- .text .align 4...
CHAPTER 4 PROGRAM LIST #_ _sbss, r13 -- clear bss section #_ _ebss, r12 r12, r13 .L14 .L15: st.w r0, [r13] 4, r13 r12, r13 .L15 .L14: jarl _main, lp -- call main function _ _exit: halt -- end of program _ _startend: #-------------------------- end of start up module ----------------------------# 4.2.5...
CHAPTER 4 PROGRAM LIST OUT_data( LED42, ~0xda ) ; } else { OUT_data( LED41, ~0x9e ) ; /* E3 display */ OUT_data( LED42, ~0xf2 ) ; timer_count = 50 ; while( timer_count ) ; 4.2.6 LED display function /****************************************************************************** / LED value display subroutine : Display area number (1 to 4) data : Display data (0 to 99)
Page 103
CHAPTER 4 PROGRAM LIST POER0 = 0x00 ; /* All phases off */ now_speed = 0; cont_time1 = 0; /****************************************************************************** / Calculation processing of speed, etc. /****************************************************************************** / void fcalcu( signed int *wrm, signed int *trm ) signed short es_trm, cur_time, delta, i ; signed int wwrm, wk, *p1, *p2;...
CHAPTER 4 PROGRAM LIST Program List (V850E/IA3) 4.3.1 Symbol definition /****************************************************************************** / Common area /****************************************************************************** / unsigned char ram_start ; unsigned char error_flag ; /* Error flag */ unsigned char init_flag ; /* Initial flag */ unsigned short cont_time ; /* Interrupt control time uSEC */ unsigned short cont_time1 ;...
CHAPTER 4 PROGRAM LIST .section ".vect_ETC",text -4,sp st.w r1,[sp] #V_ETC,r1 [r1] .section ".vect_MOTOR",text -4,sp st.w r1,[sp] #V_MOTOR,r1 [r1] .section ".vect_AD0",text -4,sp st.w r1,[sp] #V_AD0,r1 [r1] .section ".vect_AD1",text -4,sp st.w r1,[sp] #V_AD1,r1 [r1] 4.3.4 Startup routine setting #============================================================================= # DESCRIPTIONS: This assembly program is a sample of start-up module for ca850. If you modified this program, you must assemble this file, and locate a given directory.
Page 119
CHAPTER 4 PROGRAM LIST gp -> -+-------------- + _ _ssbss # sbss section +-------------- + _ _stack _ _esbss _ _sbss | stack area # bss section | 0x400 bytes sp -> -+-------------- + _ _stack + STACKSIZE _ _ebss ep ->...
Page 120
CHAPTER 4 PROGRAM LIST #----------------------------------------------------------------------------- .set STACKSIZE, 0x400 .bss .lcomm _ _stack, STACKSIZE, 4 #----------------------------------------------------------------------------- start up pointers: tp - text pointer gp - global pointer sp - stack pointer ep - element pointer exit status is set to r10 #----------------------------------------------------------------------------- .text .align 4...
CHAPTER 4 PROGRAM LIST .L12 .L11: #_ _sbss, r13 -- clear bss section #_ _ebss, r12 r12, r13 .L14 .L15: st.w r0, [r13] 4, r13 r12, r13 .L15 .L14: jarl _main, lp -- call main function _ _exit: halt -- end of program _ _startend: #-------------------------- end of start up module ----------------------------# 4.3.5...
CHAPTER 4 PROGRAM LIST 4.3.12 Common area initialization processing function /****************************************************************************** / Common area initialization /****************************************************************************** / void ainit( void ) /* Initialization of flags */ error_flag = 0 ; /* Clear error flag */ init_flag = OFF ; /* Initial flag off */ disp_co = 100 ;...
CHAPTER 4 PROGRAM LIST Program List (V850E/IA4) 4.4.1 Symbol definition /****************************************************************************** / Common area /****************************************************************************** / unsigned char ram_start ; unsigned char error_flag ; /* Error flag */ unsigned char init_flag ; /* Initial flag */ unsigned short cont_time ; /* Interrupt control time uSEC */ unsigned short cont_time1 ;...
CHAPTER 4 PROGRAM LIST .section ".vect_ETC",text -4,sp st.w r1,[sp] #V_ETC,r1 [r1] .section ".vect_MOTOR",text -4,sp st.w r1,[sp] #V_MOTOR,r1 [r1] .section ".vect_AD0",text -4,sp st.w r1,[sp] #V_AD0,r1 [r1] .section ".vect_AD1",text -4,sp st.w r1,[sp] #V_AD1,r1 [r1] 4.4.4 Startup routine setting #============================================================================= # DESCRIPTIONS: This assembly program is a sample of start-up module for ca850. If you modified this program, you must assemble this file, and locate a given directory.
Page 144
CHAPTER 4 PROGRAM LIST gp -> -+-------------- + _ _ssbss # sbss section +-------------- + _ _stack _ _esbss _ _sbss | stack area # bss section | 0x400 bytes sp -> -+-------------- + _ _stack + STACKSIZE _ _ebss ep ->...
Page 145
CHAPTER 4 PROGRAM LIST #----------------------------------------------------------------------------- .set STACKSIZE, 0x400 .bss .lcomm _ _stack, STACKSIZE, 4 #----------------------------------------------------------------------------- start up pointers: tp - text pointer gp - global pointer sp - stack pointer ep - element pointer exit status is set to r10 #----------------------------------------------------------------------------- .text .align 4...
CHAPTER 4 PROGRAM LIST .L12 .L11: #_ _sbss, r13 -- clear bss section #_ _ebss, r12 r12, r13 .L14 .L15: st.w r0, [r13] 4, r13 r12, r13 .L15 .L14: jarl _main, lp -- call main function _ _exit: halt -- end of program _ _startend: #-------------------------- end of start up module ----------------------------# 4.4.5...
CHAPTER 4 PROGRAM LIST 4.4.12 Common area initialization processing function /****************************************************************************** / Common area initialization /****************************************************************************** / void ainit( void ) /* Initialization of flags */ error_flag = 0 ; /* Clear error flag */ init_flag = OFF ; /* Initial flag off */ disp_co = 100 ;...
CHAPTER 4 PROGRAM LIST Program List (V850E/MA3) 4.5.1 Symbol definition /****************************************************************************** / Common area /****************************************************************************** / unsigned char ram_start ; unsigned char error_flag ; /* Error flag */ unsigned char init_flag ; /* Initial flag */ unsigned short cont_time ; /* Interrupt control time uSEC */ unsigned short cont_time1 ;...
CHAPTER 4 PROGRAM LIST #V_MOTOR,r1 [r1] .section ".vect_AD0",text -4,sp st.w r1,[r3] #V_AD0,r1 [r1] 4.5.4 Startup routine setting #============================================================================= # DESCRIPTIONS: This assembly program is a sample of start-up module for ca850. If you modified this program, you must assemble this file, and locate a given directory.
Page 169
CHAPTER 4 PROGRAM LIST # sidata section -+-------------- + #============================================================================= #----------------------------------------------------------------------------- special symbols #----------------------------------------------------------------------------- .extern _ _tp_TEXT, 4 .extern _ _gp_DATA, 4 .extern _ _ep_DATA, 4 .extern _ _ssbss, 4 .extern _ _esbss, 4 .extern _ _sbss, 4 .extern _ _ebss, 4 #----------------------------------------------------------------------------- C program main function #-----------------------------------------------------------------------------...
Page 170
CHAPTER 4 PROGRAM LIST .globl _ _start .globl _exit .globl _ _exit _ _start: 0x26,r10 st.b r10,VSWC[r0] -- Set peripheral I/O wait 0x07,r10 -- ×10 st.b r10,PRCMD[r0] st.b r10,CKC[r0] -- PLL xx multiplication #_ _tp_TEXT, tp -- set tp register #_ _gp_DATA, gp -- set gp register offset tp, gp...
CHAPTER 4 PROGRAM LIST #-------------------------- end of start up module ----------------------------# 4.5.5 Main processing function #include "Common.h" #include "Motor.h" #pragma ioreg /* Peripheral I/O register definition */ static int save_psw; /****************************************************************************** / 3-phase motor control program /****************************************************************************** / void main() unsigned char proc_no ;...
Page 172
CHAPTER 4 PROGRAM LIST init_flag = 2 ; /* CCW initial request */ start_init() ; /* Initialize revolution start */ _ _EI() ; proc_no = 1 ; /* Set next processing number */ } else if ( sw_mode == CCW ) { _ _DI() ;...
Page 173
CHAPTER 4 PROGRAM LIST object_speed -= accel_spd ; ( object_speed < SPEED_MINI ) object_speed = SPEED_MINI; timer_count = WATCH_START ;/* Set speed monitor start time to 5 SEC */ } else { stop_flag = ON ; /* Stop flag on */ proc_no = 0 ;...
CHAPTER 4 PROGRAM LIST 4.5.6 LED display function /****************************************************************************** / LED value display subroutine : Display area number (1 to 4) data : Display data (0 to 99) /****************************************************************************** / void led_num( int no, long data ) ( no == 1 ) { data = data % 10000;...
Need help?
Do you have a question about the V850 Series and is the answer not in the manual?
Questions and answers