Renesas V850 Series Note
Renesas V850 Series Note

Renesas V850 Series Note

V850 series inverter control
Hide thumbs Also See for V850 Series:
Table of Contents

Advertisement

Quick Links

To our customers,
st
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.
Issued by: Renesas Electronics Corporation (http://www.renesas.com)
Send any inquiries to http://www.renesas.com/inquiry.
Old Company Name in Catalogs and Other Documents
Renesas Electronics website: http://www.renesas.com
st
April 1
, 2010
Renesas Electronics Corporation

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the V850 Series and is the answer not in the manual?

Questions and answers

Summary of Contents for Renesas V850 Series

  • 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 4 [MEMO] Application Note U17209EJ1V0AN...
  • 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 µ...
  • Page 9: Chapter 1 Control Method

    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.
  • Page 11: Table Of Contents

    CONTENTS CHAPTER 1 CONTROL METHOD......................12 Outline of Brushless DC Motor Control.................. 12 CHAPTER 2 HARDWARE CONFIGURATION ..................17 Configuration ..........................17 Circuit Diagram ......................... 19 CHAPTER 3 SOFTWARE CONFIGURATION..................31 Control Block ..........................31 Peripheral I/O..........................32 Software Processing Structure ....................34 Flowchart ...........................
  • Page 12 4.2.1 Symbol definition ......................... 89 4.2.2 Constant definition........................90 4.2.3 Interrupt handler setting....................... 93 4.2.4 Startup routine setting ......................... 95 4.2.5 Main processing function ......................98 4.2.6 LED display function........................102 4.2.7 Motor control interrupt processing function.................103 4.2.8 Zero-cross interrupt processing function ..................107 4.2.9 10 mSEC interval interrupt processing function................109 4.2.10...
  • Page 13 4.5.4 Startup routine setting ........................171 4.5.5 Main processing function......................174 4.5.6 LED display function........................178 4.5.7 Motor control interrupt processing function ................179 4.5.8 Zero-cross interrupt processing function ..................182 4.5.9 10 mSEC interval interrupt processing function .................184 4.5.10 A/D converter interrupt processing function ................185 4.5.11 Hardware initialization processing function ................185 4.5.12...
  • Page 14: Outline Of Brushless Dc Motor Control

    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.
  • Page 19: Configuration

    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...
  • Page 21: Circuit Diagram

    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.
  • Page 22 CHAPTER 2 HARDWARE CONFIGURATION [MEMO] Application Note U17209EJ1V0AN...
  • Page 23 CHAPTER 2 HARDWARE CONFIGURATION Figure 2-2. Circuit Diagram of V850E/IA1 VR1A 10KΩ Speed LM324 Velocity Cont. LC-2-G LC-2-G LC-2-G 2.2KΩ [MOT OUT] Mot_Stop Mot_UH Mot_UL Mot_VH Mot_VL CN 3P Mot_WH Mot_WL 0.01uF film +3.3V 10KΩ +12V 100KΩ HPS-3-AS +12V LM324 RESE 74ACT14 74ACT14...
  • Page 24 CHAPTER 2 HARDWARE CONFIGURATION Figure 2-3. Circuit Diagram of V850E/IA2 VR1A 10KΩ Speed LM324 Velocity Cont. LC-2-G LC-2-G LC-2-G 2.2KΩ [MOT OUT] Mot_UH Mot_UL Mot_VH Mot_VL CN 3P Mot_WH Mot_WL 0.01uF film 10KΩ +12V 100KΩ HPS-3-AS +12V LM324 RESET 74ACT14 74ACT14 22KΩ...
  • Page 25 CHAPTER 2 HARDWARE CONFIGURATION Figure 2-4. Circuit Diagram of V850E/IA3 VR1A 10KΩ Speed LM324 Velocity Cont. LC-2-G LC-2-G LC-2-G 2.2KΩ [MOT OUT] Mot_UH Mot_UL Mot_VH Mot_VL Mot_WH CN 3P VR1B Mot_WL 10K Ω 0.01uF film Comp. LM324 Ref. 100KΩ +12V HPS-3-AS +12V LM324...
  • Page 26 CHAPTER 2 HARDWARE CONFIGURATION Figure 2-5. Circuit Diagram of V850E/IA4 VR1A 10KΩ Speed LM324 Velocity Cont. LC-2-G LC-2-G LC-2-G 2.2KΩ [MOT OUT] Mot_UH Mot_UL VR1B Mot_VH 10KΩ Mot_VL Comp. LM324 Mot_WH CN 3P Ref. Mot_WL 0.01uF film 2.2KΩ +12V 100KΩ HPS-3-AS +12V LM324...
  • Page 27 CHAPTER 2 HARDWARE CONFIGURATION Figure 2-6. Circuit Diagram of V850E/MA3 +3.3V VR1A 10KΩ Speed LM324 Velocity Cont. LC-2-G LC-2-G LC-2-G 2.2KΩ [MOT OUT] Mot_UH Mot_UL +3.3V Mot_V Mot_VL Mot_WH CN 3P Mot_WL 0.01uF film 10KΩ +2.5V +12V 100KΩ HPS-3-AS +3.3V RESETB +12V LM324...
  • Page 28: Chapter 3 Software Configuration

    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>...
  • Page 29: Peripheral I/O

    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 µ...
  • Page 31: Software Processing Structure

    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...
  • Page 33: Flowchart

    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 39 CHAPTER 3 SOFTWARE CONFIGURATION Figure 3-10. Case 5 (CCW Constant-Speed Processing) Target speed = (– indication speed) SW mode = CW or STOP? Processing number 6 Figure 3-11. Case 6 (CCW Stop Processing) Acceleration/deceleration counter = 0? Re-set acceleration/deceleration counter Target speed <...
  • 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?
  • Page 42: Motor Control Processing

    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...
  • Page 47: U Zero-Cross Point Interrupt Processing

    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...
  • Page 48: Zero-Cross Point Interrupt Processing

    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...
  • Page 49: W Zero-Cross Point Interrupt Processing

    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...
  • Page 50: Msec Interval Interrupt Processing

    CHAPTER 3 SOFTWARE CONFIGURATION 3.4.6 10 mSEC interval interrupt processing Figure 3-17. 10 mSEC Interval Interrupt Processing int_ETC : Refer to 4.1.9, 4.2.9, 4.3.9, 4.4.9, 4.5.9 10 mSEC interval interrupt processing function. Wait counter = 0? Wait counter – 1 Acceleration/deceleration counter = 0? Acceleration/deceleration counter –...
  • Page 51: A/D Converter Channel 0 Interrupt Processing

    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...
  • Page 52: A/D Converter Channel 1 Interrupt Processing

    CHAPTER 3 SOFTWARE CONFIGURATION 3.4.8 A/D converter channel 1 interrupt processing Figure 3-19. A/D Converter Channel 1 Interrupt Processing : Refer to 4.1.10, 4.2.10, 4.3.10, 4.4.10 A/D converter int_ad1 interrupt processing function. Read volume value EXIT Application Note U17209EJ1V0AN...
  • Page 53: Hardware Initialization

    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...
  • Page 54: Common Area 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 •...
  • Page 55: Led Display

    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...
  • Page 56: Common Areas

    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...
  • Page 57: Tables

    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.
  • Page 59: Constant Definitions

    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 →...
  • Page 60: Chapter 4 Program List

    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 ;...
  • Page 61: Constant Definition

    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 62 CHAPTER 4 PROGRAM LIST #define LED21 #define LED22 #define LED31 #define LED32 #define LED41 #define LED42 #define DIPSW 0x10 #define SW 0x20 #define DA1 0x30 #define DA2 0x40 #define DA3 0x50 #define WRESET 0x60 #define MODE 0x70 /****************************************************************************** / Constant /****************************************************************************** / #define ON #define OFF...
  • 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 */...
  • Page 64: Interrupt Handler Setting

    CHAPTER 4 PROGRAM LIST {0x24,0x00},{0x18,0x00},{0x09,0x00}, {0x12,0x00},{0x00,0x00} }; const unsigned char run_ccw_data[8][2] = { {0x00,0x00},{0x09,0x00},{0x24,0x00}, {0x21,0x00}, {0x12,0x00},{0x18,0x00}, {0x06,0x00},{0x00,0x00} }; #pragma section const end 4.1.3 Interrupt handler setting /****************************************************************************** / Interrupt symbol table /****************************************************************************** / .extern _ _start .extern _int_MOTOR .extern _int_U .extern _int_V .extern _int_W .extern _int_AD0...
  • Page 65 CHAPTER 4 PROGRAM LIST _int_ETC -- Other timers V_MOTOR: ld.w [sp],r1 4,sp _int_MOTOR -- Speed control timer V_AD0: ld.w [sp],r1 4,sp _int_AD0 -- A/D converter CH0 V_AD1: ld.w [sp],r1 4,sp _int_AD1 -- A/D converter CH1 .extern V_RESET .extern V_U .extern V_V .extern V_W .extern V_ETC .extern V_MOTOR...
  • Page 66: Startup Routine Setting

    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...
  • Page 69: Main Processing Function

    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...
  • Page 70 CHAPTER 4 PROGRAM LIST ( sw == 1 ) { sw_mode = CW ; } else if ( sw == 2 ) { sw_mode = CCW ; } else if ( sw == 4 ) { sw_mode = STOP ; switch( proc_no ) { /* STOP processing */ case 0 :...
  • Page 71 CHAPTER 4 PROGRAM LIST ( (sw_mode == CCW) || (sw_mode == STOP) ) { proc_no = 3 ; /* Deceleration, set processing number */ break ; /* CW processing, constant-speed */ case 2 : object_speed = speed ; ( (sw_mode == CCW) || (sw_mode == STOP) ) { proc_no = 3 ;...
  • Page 72 CHAPTER 4 PROGRAM LIST object_speed = -speed ; ( (sw_mode == CW) || (sw_mode == STOP) ) { proc_no = 6 ; /* Deceleration, set processing number */ break ; /* CCW stop processing */ case 6 : ( accel_count == 0 ) { accel_count = ACCEL_VAL ;...
  • Page 73: Led Display Function

    CHAPTER 4 PROGRAM LIST OUT_data( LED42, ~0x60 ) ; } else if ( error_flag == ERR_NO2 ) { OUT_data( LED41, ~0x9e ) ; /* E2 display */ OUT_data( LED42, ~0xda ) ; } else { OUT_data( LED41, ~0x9e ) ; /* E3 display */ OUT_data( LED42, ~0xf2 ) ;...
  • Page 74: Motor Control Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST ( reg == WRESET ) { P4.3 = 0; data = 1; /* Dummy step */ P4.3 = 1; } else { PDL = data | ( reg << 8 ); PDL = reg | ( reg << 8 ) | 0x8000; /****************************************************************************** / External I/O input subroutine reg: Input register number...
  • Page 75 CHAPTER 4 PROGRAM LIST signed int o_vua, o_vva, o_vwa ; signed int o_vda, o_vqa ; /* */ /****************************************************************************** / Calculation processing of speed and rotor position /****************************************************************************** / fcalcu( &wrm, &trm ) ; sum_speed += ( wrm * TH_U / RPM_RADS ) ; /* Radian -> rpm */ ( --speed_co == 0 ) { speed_co = 100000 / TS ;...
  • Page 76 CHAPTER 4 PROGRAM LIST ( init_pat >= 6 ) { init_pat = 0 ; ( init_upco > 14 ) { init_flag = 0 ; } else { init_upco++ ; } else { /****************************************************************************** / Normal revolution processing /****************************************************************************** / o_wre = abs(object_speed) * RPM_RADS * P / TH_U ; /* rpm ->...
  • Page 77 CHAPTER 4 PROGRAM LIST cont_time1 = ( TM3 - s_time ) * 10 / 16; /* Convert to uSEC */ } else { POER0 = 0x00 ; /* All phases off now_speed = 0; cont_time1 = 0; /****************************************************************************** / Calculation processing of speed, etc. /****************************************************************************** / void fcalcu( signed int *wrm, signed int *trm )
  • Page 78: Zero-Cross Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST total_sa += wk ; /* Total difference in average buffer */ wwrm = ( total_sa * ( 1000000 / 20 / TH_U ) / TS ); *wrm = wwrm ; /* Speed radian/second */ 4.1.8 Zero-cross interrupt processing function /****************************************************************************** / U zero-cross point interrupt /****************************************************************************** /...
  • Page 79 CHAPTER 4 PROGRAM LIST /****************************************************************************** / V zero-cross point interrupt /****************************************************************************** / _ _interrupt void int_V(void) unsigned char wk ; ( ( ( init_flag == 0 ) && ( stop_flag == OFF) ) ) { sa_time = TM4 ; TMC4 = 0x61;...
  • Page 80: Msec Interval Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST ( ( ( init_flag == 0 ) && ( stop_flag == OFF) ) ) { sa_time = TM4 ; TMC4 = 0x61; TMC4 = 0x63; /* Restart timer */ ( ~P2 & 0x02 ) { /* Check V phase */ base_position = RAD*2/3/P ;...
  • Page 81: A/D Converter Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST /* Acceleration/deceleration timer processing */ ( accel_count != 0 ) { accel_count -= 1 ; /* */ ( disp_co != 0 ) { d_speed += abs( now_speed ) ; disp_co -= 1 ; 4.1.10 A/D converter interrupt processing function /****************************************************************************** / A/D converter interrupt processing for U-phase current and speed volume */ /****************************************************************************** /...
  • Page 82 CHAPTER 4 PROGRAM LIST short dummy ; /* Port mode register initialization */ PM4 = 0xf7 ; PMDL = 0x0000 ; OUT_data( LED11, 0xff ) ; /* LED OFF */ OUT_data( LED12, 0xff ) ; OUT_data( LED13, 0xff ) ; OUT_data( LED14, 0xff ) ;...
  • Page 83: Common Area Initialization Processing Function

    CHAPTER 4 PROGRAM LIST ADSCM00 = 0x0001 ; ADSCM10 = 0x0000 ; ADIC0 = 0x03 ; ADIC1 = 0x03 ; /* Set zero-cross signal interrupt pin */ FEM0 = 0x0c ; /* INTP20 both-edge interrupt */ CC2IC0 = 0x01 ; FEM1 = 0x0c ;...
  • Page 84: Link Directive File For V850E/Ia1

    CHAPTER 4 PROGRAM LIST init_upco = 0 ; 4.1.14 Link directive file for V850E/IA1 /****************************************************************************** / Link directive file for V850E/IA1 /****************************************************************************** / VECT_RESET: !LOAD ?RX V0x0000000 { .vect_RESET = $PROGBITS ?AX .vect_RESET; ID_NO: !LOAD ?RX V0x0000070 { .id_NO = $PROGBITS ?AX .id_NO; VECT_U: !LOAD ?RX V0x00001f0 { .vect_U = $PROGBITS ?AX .vect_U;...
  • Page 85 CHAPTER 4 PROGRAM LIST .data = $PROGBITS ?AW .sdata = $PROGBITS ?AWG ; .sbss = $NOBITS ?AWG ; .bss = $NOBITS _ _tp_TEXT @ %TP_SYMBOL; _ _gp_DATA @ %GP_SYMBOL &_ _tp_TEXT{DATA}; _ _ep_DATA @ %EP_SYMBOL; Application Note U17209EJ1V0AN...
  • Page 86: Program List (V850E/Ia2)

    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 ;...
  • Page 87: Constant Definition

    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 ;...
  • Page 88 CHAPTER 4 PROGRAM LIST #define LED32 #define LED41 #define LED42 #define DIPSW 0x10 #define SW 0x20 #define DA1 0x30 #define DA2 0x40 #define DA3 0x50 #define WRESET 0x60 #define MODE 0x70 /****************************************************************************** / Constant /****************************************************************************** / #define ON #define OFF #define CW /* CW operation mode */ #define CCW...
  • Page 89 CHAPTER 4 PROGRAM LIST #define ACCEL_TIME /* Acceleration/deceleration time */ /* constant 10 mSEC */ #define ACCEL_DATA /* Number of acceleration/deceleration */ /* incremental revolutions rpm */ #define WATCH_START /* Speed monitor start time 10 mSEC */ #define ACCEL_VAL_1ST 50 /* Initial acceleration/deceleration */ /* time constant */ #define ACCEL_VAL...
  • Page 90: Interrupt Handler Setting

    CHAPTER 4 PROGRAM LIST const unsigned char run_ccw_data[8][2] = { {0x00,0x00},{0x09,0x00},{0x24,0x00}, {0x21,0x00},{0x12,0x00},{0x18,0x00}, {0x06,0x00},{0x00,0x00} }; #pragma section const end 4.2.3 Interrupt handler setting /****************************************************************************** / Interrupt symbol table /****************************************************************************** / .extern _ _start .extern _int_MOTOR .extern _int_U .extern _int_V .extern _int_W .extern _int_AD0 .extern _int_AD1 .extern _int_ETC...
  • Page 91 CHAPTER 4 PROGRAM LIST ld.w [sp],r1 4,sp _int_MOTOR -- Speed control timer V_AD0: ld.w [sp],r1 4,sp _int_AD0 -- A/D converter CH0 V_AD1: ld.w [sp],r1 4,sp _int_AD1 -- A/D converter CH1 .extern V_RESET .extern V_U .extern V_V .extern V_W .extern V_ETC .extern V_MOTOR .extern V_AD0 .extern V_AD1...
  • Page 92: Startup Routine Setting

    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...
  • Page 95: Main Processing Function

    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...
  • Page 96 CHAPTER 4 PROGRAM LIST } else if ( sw == 2 ) { sw_mode = CCW ; } else if ( sw == 4 ) { sw_mode = STOP ; switch( proc_no ) { /* STOP processing */ case 0 : ( sw_mode == CW ) { _ _DI() ;...
  • Page 97 CHAPTER 4 PROGRAM LIST break ; /* CW processing, constant-speed */ case 2 : object_speed = speed ; ( (sw_mode == CCW) || (sw_mode == STOP) ) { proc_no = 3 ; /* Deceleration, set processing number */ break ; /* CW stop processing */ case 3 : ( accel_count == 0 ) {...
  • Page 98 CHAPTER 4 PROGRAM LIST break ; /* CCW stop processing */ case 6 : ( accel_count == 0 ) { accel_count = ACCEL_VAL ; /* Set acceleration/deceleration counter */ ( object_speed < -SPEED_MINI ) { object_speed += accel_spd ; ( object_speed > -SPEED_MINI ) object_speed = -SPEED_MINI; timer_count = WATCH_START ;...
  • Page 99: Led Display Function

    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 100: Motor Control Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST P3.0 = 1; } else { PDL = data | ( reg << 8 ); PDL = reg | ( reg << 8 ) | 0x8000; /****************************************************************************** / External I/O input subroutine reg : Input register number /****************************************************************************** / unsigned short IN_data( int reg )
  • Page 101 CHAPTER 4 PROGRAM LIST /****************************************************************************** / Calculation processing of speed and rotor position /****************************************************************************** / fcalcu( &wrm, &trm ) ; sum_speed += ( wrm * TH_U / RPM_RADS ) ; /* Radian -> rpm */ ( --speed_co == 0 ) { speed_co = 100000 / TS ;...
  • Page 102 CHAPTER 4 PROGRAM LIST ( init_upco > 14 ) { init_flag = 0 ; } else { init_upco++ ; } else { /****************************************************************************** / Normal revolution processing /****************************************************************************** / o_wre = abs(object_speed) * RPM_RADS * P / TH_U ; /* rpm -> radian conversion */ we = o_wre - wre ;...
  • 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;...
  • Page 104: Zero-Cross Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST 4.2.8 Zero-cross interrupt processing function /****************************************************************************** / U zero-cross point interrupt /****************************************************************************** / _ _interrupt void int_U(void) unsigned char wk ; ( ( ( init_flag == 0 ) && ( stop_flag == OFF) ) ) { sa_time = TM4 ;...
  • Page 105 CHAPTER 4 PROGRAM LIST _ _interrupt void int_V(void) unsigned char wk ; ( ( ( init_flag == 0 ) && ( stop_flag == OFF) ) ) { sa_time = TM4 ; TMC4 = 0x61; TMC4 = 0x63; /* Restart timer */ ( ~P2 &...
  • Page 106: Msec Interval Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST TMC4 = 0x61; TMC4 = 0x63; /* Restart timer */ ( ~P2 & 0x02 ) { /* Check V phase */ base_position = RAD*2/3/P ; } else { base_position = RAD/6/P ; ( object_speed < 0 ) { wk = run_ccw_data[ P2 &...
  • Page 107: A/D Converter Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST /* */ ( disp_co != 0 ) { d_speed += abs( now_speed ) ; disp_co -= 1 ; 4.2.10 A/D converter interrupt processing function /****************************************************************************** / A/D converter interrupt processing for U-phase current and speed volume */ /****************************************************************************** / _ _multi_interrupt void...
  • Page 108 CHAPTER 4 PROGRAM LIST PM4 = 0xf7 ; PMDL = 0x0000 ; OUT_data( LED11, 0xff ) ; /* LED OFF */ OUT_data( LED12, 0xff ) ; OUT_data( LED13, 0xff ) ; OUT_data( LED14, 0xff ) ; OUT_data( LED21, 0xff ) ; OUT_data( LED22, 0xff ) ;...
  • Page 109: Common Area Initialization Processing Function

    CHAPTER 4 PROGRAM LIST ADIC1 = 0x03 ; /* Set zero-cross signal interrupt pin */ FEM0 = 0x0c ; /* INTP20 both-edge interrupt */ CC2IC0 = 0x01 ; FEM1 = 0x0c ; /* INTP21 both-edge interrupt */ CC2IC1 = 0x01 ; FEM2 = 0x0c ;...
  • Page 110: Link Directive File For V850E/Ia2

    CHAPTER 4 PROGRAM LIST 4.2.14 Link directive file for V850E/IA2 /****************************************************************************** / Link directive file for V850E/IA2 /****************************************************************************** / VECT_RESET: !LOAD ?RX V0x0000000 { .vect_RESET = $PROGBITS ?AX .vect_RESET; ID_NO: !LOAD ?RX V0x0000070 { .id_NO = $PROGBITS ?AX .id_NO; VECT_U: !LOAD ?RX V0x00001f0 { .vect_U = $PROGBITS ?AX .vect_U;...
  • Page 111 CHAPTER 4 PROGRAM LIST .bss = $NOBITS _ _tp_TEXT @ %TP_SYMBOL; _ _gp_DATA @ %GP_SYMBOL &_ _tp_TEXT{DATA}; _ _ep_DATA @ %EP_SYMBOL; Application Note U17209EJ1V0AN...
  • Page 112: Program List (V850E/Ia3)

    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 ;...
  • Page 113: Constant Definition

    CHAPTER 4 PROGRAM LIST 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 ; #pragma section const begin extern const unsigned short led_pat[] ;;...
  • Page 114 CHAPTER 4 PROGRAM LIST #define LED41 0x09 #define LED42 0x08 #define DIPSW 0x0f #define SW 0x0e #define DA1 0x0a #define DA2 0x0b #define DA3 0x0c #define WRESET 0x0d #define MODE 0x10 /****************************************************************************** / Constant /****************************************************************************** / #define ON #define OFF #define CW /* CW operation mode */ #define CCW...
  • Page 115 CHAPTER 4 PROGRAM LIST #define ACCEL_TIME /* Acceleration/deceleration time */ /* constant 10 mSEC */ #define ACCEL_DATA /* Number of acceleration/deceleration */ /* incremental revolutions rpm */ #define WATCH_START /* Speed monitor start time 10 mSEC */ #define ACCEL_VAL_1ST 50 /* Initial acceleration/deceleration */ /* time constant */ #define ACCEL_VAL...
  • Page 116: Interrupt Handler Setting

    CHAPTER 4 PROGRAM LIST const unsigned char run_ccw_data[8][2] = { {0x00,0x00},{0x09,0x30},{0x21,0xc0}, {0x09,0xc0},{0x81,0x0c},{0x81,0x30}, {0x21,0x0c},{0x00,0x00} }; #pragma section const end 4.3.3 Interrupt handler setting /****************************************************************************** / Interrupt symbol table /****************************************************************************** / .extern _ _start .extern _int_MOTOR .extern _int_U .extern _int_V .extern _int_W .extern _int_AD0 .extern _int_AD1 .extern _int_ETC...
  • Page 117 CHAPTER 4 PROGRAM LIST ld.w [sp],r1 4,sp _int_MOTOR -- Speed control timer V_AD0: ld.w [sp],r1 4,sp _int_AD0 -- A/D converter CH0 V_AD1: ld.w [sp],r1 4,sp _int_AD1 -- A/D converter CH1 .extern V_RESET .extern V_U .extern V_V .extern V_W .extern V_ETC .extern V_MOTOR .extern V_AD0 .extern V_AD1...
  • Page 118: Startup Routine Setting

    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...
  • Page 121: Main Processing Function

    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...
  • Page 122 CHAPTER 4 PROGRAM LIST sw = ~IN_data( SW ) & 0x07 ; /* Read operation button */ ( sw == 1 ) { sw_mode = CW ; } else if ( sw == 2 ) { sw_mode = CCW ; } else if ( sw == 4 ) { sw_mode = STOP ;...
  • Page 123 CHAPTER 4 PROGRAM LIST ( (sw_mode == CCW) || (sw_mode == STOP) ) { proc_no = 3 ; /* Deceleration, set processing number */ break ; /* CW processing, constant-speed */ case 2 : object_speed = speed ; ( (sw_mode == CCW) || (sw_mode == STOP) ) { proc_no = 3 ;...
  • Page 124 CHAPTER 4 PROGRAM LIST object_speed = -speed ; ( (sw_mode == CW) || (sw_mode == STOP) ) { proc_no = 6 ; /* Deceleration, set processing number */ break ; /* CCW stop processing */ case 6 : ( accel_count == 0 ) { accel_count = ACCEL_VAL ;...
  • Page 125: Led Display Function

    CHAPTER 4 PROGRAM LIST OUT_data( LED42, ~0x60 ) ; } else if ( error_flag == ERR_NO2 ) { OUT_data( LED41, ~0x9e ) ; /* E2 display */ OUT_data( LED42, ~0xda ) ; } else { OUT_data( LED41, ~0x9e ) ; /* E3 display */ OUT_data( LED42, ~0xf2 ) ;...
  • Page 126: Motor Control Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST ( reg == WRESET ) { P3.0 = 0; data = 1; /* Dummy step */ P3.0 = 1; } else { PDL = data | ( reg << 8 ); PDL = reg | ( reg << 8 ) | 0x8000; /****************************************************************************** / External I/O input subroutine reg : Input register number...
  • Page 127 CHAPTER 4 PROGRAM LIST signed int o_vua, o_vva, o_vwa ; signed int o_vda, o_vqa ; /* */ /****************************************************************************** / Calculation processing of speed and rotor position /****************************************************************************** / fcalcu( &wrm, &trm ) ; sum_speed += ( wrm * TH_U / RPM_RADS ) ; /* Radian ->...
  • Page 128 CHAPTER 4 PROGRAM LIST } else { /****************************************************************************** / Normal revolution processing /****************************************************************************** / o_wre = abs(object_speed) * RPM_RADS * P / TH_U ; /* rpm -> radian conversion */ we = o_wre - wre ; o_iqap = ( ( wre * KSP ) + ( we * KSP ) ) >> KSPGETA ; o_iqa = o_iqap + ( o_iqai >>...
  • Page 129: Zero-Cross Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST cur_time = TP2CNT ; delta = ( (RAD/6/P) * cur_time ) / sa_time ; /* Calculation of rotor position */ /* difference from reference point */ /* (radian) */ ( object_speed >= 0 ) { es_trm = base_position + delta; } else { es_trm = base_position - delta;...
  • Page 130 CHAPTER 4 PROGRAM LIST TP2CTL0 &= ~0x80; TP2CTL0 |= 0x80; /* Restart timer */ ( ~P0 & 0x10 ) { /* Check W phase */ base_position = 0 ; } else { base_position = RAD/2/P ; ( object_speed < 0 ) { = run_ccw_data[ (P0>>1) &...
  • Page 131 CHAPTER 4 PROGRAM LIST wk2 = run_cw_data[ (P0>>1) & 0x07 ][1] ; TQ0CCR1 = pwm_value ; TQ0CCR2 = pwm_value ; TQ0CCR3 = pwm_value ; TQ0IOC0 = wk ; TQ0IOC3 = wk2 ; int_co++ ; /****************************************************************************** / W zero-cross point interrupt /****************************************************************************** / _ _interrupt void...
  • Page 132: Msec Interval Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST 4.3.9 10 mSEC interval interrupt processing function /****************************************************************************** / Other timer interrupt processing (10 mSEC interval) /****************************************************************************** / _ _multi_interrupt void int_ETC(void) /* Wait timer processing */ ( timer_count != 0 ) { timer_count -= 1 ; /* Acceleration/deceleration timer processing */ ( accel_count != 0 ) { accel_count -= 1 ;...
  • Page 133: Hardware Initialization Processing Function

    CHAPTER 4 PROGRAM LIST HZA0CTL0 |= 0x08 ; /* PWM output off */ error_flag = ERR_NO1 ; /* Set error No. */ 4.3.11 Hardware initialization processing function /****************************************************************************** / Hardware (peripheral I/O) initialization /****************************************************************************** / void hinit( void ) /* Port mode register initialization */ PM3 = 0xfe ;...
  • Page 134 CHAPTER 4 PROGRAM LIST TQ0IOC2 = 0x00; /* are not used */ TQ0OPT0 = 0x00; /* Select comparison mode */ TQ0CCR0 = PWM_DATA ; /* Carrier wave cycle 20 kHz */ TQ0CCR1 = PWM_DATA /2; /* Set U-phase duty to 50 */ TQ0CCR2 = PWM_DATA /2;...
  • Page 135: Common Area Initialization Processing Function

    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 ;...
  • Page 136 CHAPTER 4 PROGRAM LIST ID_NO: !LOAD ?RX V0x00000070 { .id_NO = $PROGBITS ?AX .id_NO; VECT_U: !LOAD ?RX V0x00000090 { .vect_U = $PROGBITS ?AX .vect_U; VECT_V: !LOAD ?RX V0x000000a0 { .vect_V = $PROGBITS ?AX .vect_V; VECT_W: !LOAD ?RX V0x000000b0 { .vect_W = $PROGBITS ?AX .vect_W;...
  • Page 137: Program List (V850E/Ia4)

    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 ;...
  • Page 138: Constant Definition

    CHAPTER 4 PROGRAM LIST 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 ; #pragma section const begin extern const unsigned short led_pat[] ;;...
  • Page 139 CHAPTER 4 PROGRAM LIST #define LED41 0x09 #define LED42 0x08 #define DIPSW 0x0f #define SW 0x0e #define DA1 0x0a #define DA2 0x0b #define DA3 0x0c #define WRESET 0x0d #define MODE 0x10 /****************************************************************************** / Constant /****************************************************************************** / #define ON #define OFF #define CW /* CW operation mode */ #define CCW...
  • Page 140 CHAPTER 4 PROGRAM LIST #define ACCEL_TIME /* Acceleration/deceleration time */ /* constant 10 mSEC */ #define ACCEL_DATA /* Number of acceleration/deceleration */ /* incremental revolutions rpm */ #define WATCH_START /* Speed monitor start time 10 mSEC */ #define ACCEL_VAL_1ST 50 /* Initial acceleration/deceleration */ /* time constant */ #define ACCEL_VAL...
  • Page 141: Interrupt Handler Setting

    CHAPTER 4 PROGRAM LIST const unsigned char run_ccw_data[8][2] = { {0x00,0x00},{0x09,0x30},{0x21,0xc0}, {0x09,0xc0},{0x81,0x0c},{0x81,0x30}, {0x21,0x0c},{0x00,0x00} }; #pragma section const end 4.4.3 Interrupt handler setting /****************************************************************************** / Interrupt symbol table /****************************************************************************** / .extern _ _start .extern _int_MOTOR .extern _int_U .extern _int_V .extern _int_W .extern _int_AD0 .extern _int_AD1 .extern _int_ETC...
  • Page 142 CHAPTER 4 PROGRAM LIST ld.w [sp],r1 4,sp _int_MOTOR -- Speed control timer V_AD0: ld.w [sp],r1 4,sp _int_AD0 -- A/D converter CH0 V_AD1: ld.w [sp],r1 4,sp _int_AD1 -- A/D converter CH1 .extern V_RESET .extern V_U .extern V_V .extern V_W .extern V_ETC .extern V_MOTOR .extern V_AD0 .extern V_AD1...
  • Page 143: Startup Routine Setting

    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...
  • Page 146: Main Processing Function

    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...
  • Page 147 CHAPTER 4 PROGRAM LIST sw = ~IN_data( SW ) & 0x07 ; /* Read operation button */ ( sw == 1 ) { sw_mode = CW ; } else if ( sw == 2 ) { sw_mode = CCW ; } else if ( sw == 4 ) { sw_mode = STOP ;...
  • Page 148 CHAPTER 4 PROGRAM LIST ( (sw_mode == CCW) || (sw_mode == STOP) ) { proc_no = 3 ; /* Deceleration, set processing number */ break ; /* CW processing, constant-speed */ case 2 : object_speed = speed ; ( (sw_mode == CCW) || (sw_mode == STOP) ) { proc_no = 3 ;...
  • Page 149 CHAPTER 4 PROGRAM LIST object_speed = -speed ; ( (sw_mode == CW) || (sw_mode == STOP) ) { proc_no = 6 ; /* Deceleration, set processing number */ break ; /* CCW stop processing */ case 6 : ( accel_count == 0 ) { accel_count = ACCEL_VAL ;...
  • Page 150: Led Display Function

    CHAPTER 4 PROGRAM LIST OUT_data( LED42, ~0x60 ) ; } else if ( error_flag == ERR_NO2 ) { OUT_data( LED41, ~0x9e ) ; /* E2 display */ OUT_data( LED42, ~0xda ) ; } else { OUT_data( LED41, ~0x9e ) ; /* E3 display */ OUT_data( LED42, ~0xf2 ) ;...
  • Page 151: Motor Control Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST ( reg == WRESET ) { P3.0 = 0; data = 1; /* Dummy step */ P3.0 = 1; } else { PDL = data | ( reg << 8 ); PDL = reg | ( reg << 8 ) | 0x8000; /****************************************************************************** / External I/O input subroutine reg : Input register number...
  • Page 152 CHAPTER 4 PROGRAM LIST signed int o_vua, o_vva, o_vwa ; signed int o_vda, o_vqa ; /* */ /****************************************************************************** / Calculation processing of speed and rotor position /****************************************************************************** / fcalcu( &wrm, &trm ) ; sum_speed += ( wrm * TH_U / RPM_RADS ) ; /* Radian -> rpm */ ( --speed_co == 0 ) { speed_co = 100000 / TS ;...
  • Page 153 CHAPTER 4 PROGRAM LIST } else { /****************************************************************************** / Normal revolution processing /****************************************************************************** / o_wre = abs(object_speed) * RPM_RADS * P / TH_U ; /* rpm -> radian conversion */ we = o_wre - wre ; o_iqap = ( ( wre * KSP ) + ( we * KSP ) ) >> KSPGETA ; o_iqa = o_iqap + ( o_iqai >>...
  • Page 154: Zero-Cross Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST cur_time = TP2CNT ; delta = ( (RAD/6/P) * cur_time ) / sa_time ; /* Calculation of rotor position */ /* difference from reference point */ /* radian) */ ( object_speed >= 0 ) { es_trm = base_position + delta; } else { es_trm = base_position - delta;...
  • Page 155 CHAPTER 4 PROGRAM LIST TP2CTL0 &= ~0x80; TP2CTL0 |= 0x80; /* Restart timer */ ( ~P0 & 0x10 ) { /* Check W phase */ base_position = 0 ; } else { base_position = RAD/2/P ; ( object_speed < 0 ) { = run_ccw_data[ (P0>>1) &...
  • Page 156 CHAPTER 4 PROGRAM LIST wk2 = run_cw_data[ (P0>>1) & 0x07 ][1] ; TQ0CCR1 = pwm_value ; TQ0CCR2 = pwm_value ; TQ0CCR3 = pwm_value ; TQ0IOC0 = wk ; TQ0IOC3 = wk2 ; int_co++ ; /****************************************************************************** / W zero-cross point interrupt /****************************************************************************** / _ _interrupt void...
  • Page 157: Msec Interval Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST 4.4.9 10 mSEC interval interrupt processing function /****************************************************************************** / Other timer interrupt processing (10 mSEC interval) /****************************************************************************** / _ _multi_interrupt void int_ETC(void) /* Wait timer processing */ ( timer_count != 0 ) { timer_count -= 1 ; /* Acceleration/deceleration timer processing */ ( accel_count != 0 ) { accel_count -= 1 ;...
  • Page 158: Hardware Initialization Processing Function

    CHAPTER 4 PROGRAM LIST HZA0CTL0 |= 0x08 ; /* PWM output off */ error_flag = ERR_NO1 ; /* Set error No. */ 4.4.11 Hardware initialization processing function /****************************************************************************** / Hardware (peripheral I/O) initialization /****************************************************************************** / void hinit( void ) /* Port mode register initialization */ PM3 = 0xfe ;...
  • Page 159 CHAPTER 4 PROGRAM LIST TQ0IOC2 = 0x00; /* are not used */ TQ0OPT0 = 0x00; /* Select comparison mode */ TQ0CCR0 = PWM_DATA ; /* Carrier wave cycle 20 kHz */ TQ0CCR1 = PWM_DATA /2; /* Set U-phase duty to 50 */ TQ0CCR2 = PWM_DATA /2;...
  • Page 160: Common Area Initialization Processing Function

    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 ;...
  • Page 161 CHAPTER 4 PROGRAM LIST ID_NO: !LOAD ?RX V0x00000070 { .id_NO = $PROGBITS ?AX .id_NO; VECT_U: !LOAD ?RX V0x00000090 { .vect_U = $PROGBITS ?AX .vect_U; VECT_V: !LOAD ?RX V0x000000a0 { .vect_V = $PROGBITS ?AX .vect_V; VECT_W: !LOAD ?RX V0x000000b0 { .vect_W = $PROGBITS ?AX .vect_W;...
  • Page 162: Program List (V850E/Ma3)

    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 ;...
  • Page 163: Constant Definition

    CHAPTER 4 PROGRAM LIST 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 ; #pragma section const begin extern const unsigned short led_pat[] ;;...
  • Page 164 CHAPTER 4 PROGRAM LIST #define LED42 #define DIPSW 0x10 #define SW 0x20 #define DA1 0x30 #define DA2 0x40 #define DA3 0x50 #define WRESET 0x60 #define MODE 0x70 /****************************************************************************** / Constant /****************************************************************************** / #define ON #define OFF #define CW /* CW operation mode */ #define CCW /* CCW operation mode */ #define STOP...
  • Page 165 CHAPTER 4 PROGRAM LIST #define ACCEL_DATA /* Number of acceleration/deceleration */ /* incremental revolutions rpm */ #define WATCH_START /* Speed monitor start time 10 mSEC */ #define ACCEL_VAL_1ST 50 /* Initial acceleration/deceleration */ /* time constant */ #define ACCEL_VAL /* Acceleration/deceleration time constant */ #define ACCEL_SPD /* Acceleration/deceleration constant */ #define PWM_INIT...
  • Page 166: Interrupt Handler Setting

    CHAPTER 4 PROGRAM LIST #pragma section const end 4.5.3 Interrupt handler setting /****************************************************************************** / Interrupt symbol table /****************************************************************************** / .extern _ _start .extern _int_MOTOR .extern _int_U .extern _int_V .extern _int_W .extern _int_AD0 .extern _int_AD1 .extern _int_ETC .globl V_RESET .globl V_U .globl V_V .globl V_W .globl V_ETC...
  • Page 167 CHAPTER 4 PROGRAM LIST ld.w [sp],r1 4,sp _int_AD0 -- A/D converter CH0 .extern V_RESET .extern V_U .extern V_V .extern V_W .extern V_ETC .extern V_MOTOR .extern V_AD0 /****************************************************************************** / Interrupt jump table /****************************************************************************** / .section ".vect_RESET",text #V_RESET,r1 [r1] .section ".id_NO",text .byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff .section ".vect_U",text -4,sp st.w...
  • Page 168: Startup Routine Setting

    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...
  • Page 171: Main Processing Function

    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 ;...
  • Page 174 CHAPTER 4 PROGRAM LIST break ; ( ( proc_no == 2 ) || ( proc_no == 5 ) ) { timer_count == 0 ) { ( abs( object_speed - now_speed ) > SA_SPEED_MAX ) { error_flag = ERR_NO2 ; /* Set error No. */ ( disp_co == 0 ) { led_num(1, d_speed / 100 );...
  • Page 175: Led Display Function

    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;...
  • Page 176: Motor Control Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST unsigned char *po; ( reg == SW ) { return P4; } else { return 0; 4.5.7 Motor control interrupt processing function #include "Common.h" #include "Motor.h" #pragma ioreg /* Peripheral I/O register definition */ /****************************************************************************** / Motor control timer interrupt processing /****************************************************************************** / _ _interrupt...
  • Page 177 CHAPTER 4 PROGRAM LIST ( ( stop_flag == OFF ) && ( error_flag == 0 ) ) { s_time = TMD0 ; OUT_data( WRESET, 0 ) ; /* Reset watchdog timer */ HZA0CTL1 |= 0x04; /* PWM output on */ /****************************************************************************** / Initial revolution processing /****************************************************************************** /...
  • Page 178 CHAPTER 4 PROGRAM LIST } else if ( o_iqai < -IQAMAX ) { o_iqai = -IQAMAX ; } else { o_iqai += ( KSI * we ) ; pwm_value = o_iqa ; ( pwm_value <= 0 ) { pwm_value = 1 ; } else if ( pwm_value >= PWM_DATA pwm_value = ( PWM_DATA...
  • Page 179: Zero-Cross Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST p2 = (int *)before_posi[20] ; for ( i = 0; i <= 19 ; i++ ) { *p2-- = *p1-- ; before_posi[0][0] = *trm = es_trm % (RAD/P) ; wk = before_posi[0][0] - before_posi[1][0] ; ( abs(wk) > (RAD/2/P) ) { ( wk <...
  • Page 180 CHAPTER 4 PROGRAM LIST TQ0CCR1 = pwm_value ; TQ0CCR2 = pwm_value ; TQ0CCR3 = pwm_value ; TQ0IOC0 = wk ; TQ0IOC3 = wk2 ; int_co++ ; /****************************************************************************** / V zero-cross point interrupt /****************************************************************************** / _ _interrupt void int_V(void) unsigned char wk, wk2 ;...
  • Page 181: Msec Interval Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST ( ( ( init_flag == 0 ) && ( stop_flag == OFF) ) ) { sa_time = TMENC10 ; TMENC10 = 0 ; /* Restart timer */ ( ~P3 & 0x02 ) { /* Check V phase */ base_position = RAD*2/3/P ;...
  • Page 182: A/D Converter Interrupt Processing Function

    CHAPTER 4 PROGRAM LIST 4.5.10 A/D converter interrupt processing function /****************************************************************************** / A/D converter interrupt processing /****************************************************************************** / _ _multi_interrupt void int_AD0(void) iua = (( ADCR0 & 0x3ff ) - 0x200) ; ( abs(iua) > MAX_I ) { HZA0CTL1 |= 0x08; /* PWM output off */ error_flag = ERR_NO1 ;...
  • Page 183 CHAPTER 4 PROGRAM LIST TMCD0 = 0x01; /* Supply clock to timer D0 */ TMCD0 |= 0x70; /* Select fXX/512 (3.2 uSEC) */ CMD0 = 10000 / 32; /* 10 mSEC */ TMCD0 |= 0x02; /* Start timer */ CMICD0 = 0x06; /* Set motor control interrupt timer TMD1 */ TMCD1 = 0x00;...
  • Page 184: Common Area Initialization Processing Function

    CHAPTER 4 PROGRAM LIST /* Set A/D */ ADM2 = 0x00; /* Stop (reset) A/D clock */ ADM2 = 0x01; /* Supply A/D clock */ ADM0 = 0x03; ADM1 = 0x24; /* Select timer trigger mode */ ADTS = 0x01; /* Use timer trigger selected with TQ0OPT2 of */ /* motor control function */ ADM0 |= 0x80;...
  • Page 185: Link Directive File For V850E/Ma3

    CHAPTER 4 PROGRAM LIST init_co = 0 ; init_pat = 0 ; init_upco = 0 ; 4.5.14 Link directive file for V850E/MA3 /****************************************************************************** / Link directive file for V850E/MA3 /****************************************************************************** / VECT_RESET: !LOAD ?RX V0x0000000 { .vect_RESET = $PROGBITS ?AX .vect_RESET; ID_NO: !LOAD ?RX V0x0000070 { .id_NO = $PROGBITS ?AX .id_NO;...
  • Page 186 CHAPTER 4 PROGRAM LIST .data = $PROGBITS ?AW .sdata = $PROGBITS ?AWG ; .sbss = $NOBITS ?AWG ; .bss = $NOBITS _ _tp_TEXT @ %TP_SYMBOL; _ _gp_DATA @ %GP_SYMBOL &_ _tp_TEXT{DATA}; _ _ep_DATA @ %EP_SYMBOL; Application Note U17209EJ1V0AN...

This manual is also suitable for:

V850e/ia1V850e/ia2V850e/ia3V850e/ia4V850e/ma3

Table of Contents