├── DEBUG ├── Agreement.c ├── Agreement.h ├── DAC.c ├── DAC.h ├── UART.c └── UART.h ├── EventRecorderStub.scvd ├── FOC_Control ├── Call_Functions.c ├── Call_Functions.h ├── INT_ISR.c ├── INT_ISR.h ├── Motor_Functions.h ├── PI_Control.c ├── PI_Control.h └── SVPWM.h ├── JLinkSettings.ini ├── KEILCLEAN.bat ├── Main └── main.c ├── MotorTest.zip ├── Objects └── PMSM_FOC.hex ├── PMSM_FOC.uvoptx ├── PMSM_FOC.uvprojx ├── README.md ├── RTE ├── Device │ ├── XMC4400-F100x512 │ │ ├── RTE_Device.h │ │ ├── startup_XMC4400.s │ │ └── system_XMC4400.c │ └── XMC4400-F64x512 │ │ ├── RTE_Device.h │ │ ├── startup_XMC4400.s │ │ └── system_XMC4400.c └── _Target_1 │ └── RTE_Components.h ├── Readme └── README.txt ├── SYS_Init ├── MCU_Initialize.c ├── MCU_Initialize.h ├── VAR_Initialize.c └── VAR_Initialize.h └── Sensorless_Lib ├── PMSM_FOC.lib └── SVPWM.lib /DEBUG/Agreement.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/DEBUG/Agreement.c -------------------------------------------------------------------------------- /DEBUG/Agreement.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/DEBUG/Agreement.h -------------------------------------------------------------------------------- /DEBUG/DAC.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/DEBUG/DAC.c -------------------------------------------------------------------------------- /DEBUG/DAC.h: -------------------------------------------------------------------------------- 1 | #ifndef _DAC_H_ 2 | #define _DAC_H_ 3 | #include 4 | 5 | void DAC_Init(void); 6 | void DAC_Output1(int16_t dat); 7 | void DAC_Output0(int16_t dat); 8 | void DAC_vInit(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /DEBUG/UART.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/DEBUG/UART.c -------------------------------------------------------------------------------- /DEBUG/UART.h: -------------------------------------------------------------------------------- 1 | #ifndef UART_H_ 2 | #define UART_H_ 3 | 4 | #include 5 | 6 | extern void UART_Init(void); 7 | extern void UART_SendData(uint16_t uwData); 8 | extern void UART_SendBuffer(const uint8_t *Buffer, uint16_t length); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /EventRecorderStub.scvd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /FOC_Control/Call_Functions.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/FOC_Control/Call_Functions.c -------------------------------------------------------------------------------- /FOC_Control/Call_Functions.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/FOC_Control/Call_Functions.h -------------------------------------------------------------------------------- /FOC_Control/INT_ISR.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/FOC_Control/INT_ISR.c -------------------------------------------------------------------------------- /FOC_Control/INT_ISR.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/FOC_Control/INT_ISR.h -------------------------------------------------------------------------------- /FOC_Control/Motor_Functions.h: -------------------------------------------------------------------------------- 1 | #ifndef _Motor_Functions_h 2 | #define _Motor_Functions_h 3 | 4 | #include 5 | 6 | extern const int16_t sintable16[3600]; 7 | 8 | extern void Re_Constuct_3_Phase_Current(void); 9 | 10 | extern void Iuvw_to_Idq(uint16_t anglee); 11 | 12 | extern void Udq_to_UarphaUbeta(uint16_t anglee); 13 | 14 | extern void Thetae_Lock_CCU8(void); 15 | 16 | extern void Thetae_Inc_CCU8(void); 17 | 18 | extern void IF_Thetae_Delay(void); 19 | 20 | extern void ASMO(void); 21 | 22 | extern void SMO_Thetae_Delay(void); 23 | 24 | extern void SMOIF_Thetae_Delay(void); 25 | 26 | extern void Data_Record(void); 27 | 28 | extern void IF_SMO_Switch(void); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /FOC_Control/PI_Control.c: -------------------------------------------------------------------------------- 1 | #include "PI_Control.h" 2 | #include "VAR_Initialize.h" 3 | 4 | int32_t SMO_Output; 5 | 6 | float P_output_pos = 0; 7 | float I_output_pos = 0; 8 | float I_Sum = 0; 9 | float I_Max = 50000; 10 | float output = 0; 11 | 12 | float P_Inc_Iq; 13 | float I_Inc_Iq; 14 | float Inc_Iq; 15 | float Output_Iq; 16 | 17 | float P_Inc_Id; 18 | float I_Inc_Id; 19 | float Inc_Id; 20 | float Output_Id; 21 | 22 | void PI_SMO_PLL(void) 23 | { 24 | float P_output_inc; 25 | float I_output_inc; 26 | 27 | PI_SMO.i32_e2 = PI_SMO.i32_e1; 28 | PI_SMO.i32_e1 = SMO.i32_PLL_Error; 29 | 30 | P_output_inc = PI_SMO.flo_kp*(PI_SMO.i32_e1-PI_SMO.i32_e2); 31 | I_output_inc = PI_SMO.flo_ki*PI_SMO.i32_e1; 32 | 33 | SMO_Output = P_output_inc + I_output_inc; 34 | 35 | SMO.i16_Thetae = (SMO.i16_Thetae + SMO_Output + 3600)%3600; 36 | } 37 | 38 | void PI_Id_Loop(void) 39 | { 40 | PI_Id.i32_e2 = PI_Id.i32_e1; 41 | PI_Id.i32_e1 = Motor.cmd.i16_Id - Motor.info.i16_Id; 42 | 43 | P_Inc_Id = PI_Id.flo_kp*(PI_Id.i32_e1-PI_Id.i32_e2); 44 | I_Inc_Id = PI_Id.flo_ki*PI_Id.i32_e1; 45 | 46 | Inc_Id = P_Inc_Id + I_Inc_Id; 47 | 48 | Output_Id = Output_Id + Inc_Id; 49 | 50 | if(Output_Id >= PI_Id.i32_output_limit) 51 | {Output_Id = PI_Id.i32_output_limit;} 52 | else if(Output_Id <= -PI_Id.i32_output_limit) 53 | { 54 | Output_Id = -PI_Id.i32_output_limit; 55 | } 56 | 57 | Motor.info.i16_Ud = (int)Output_Id; 58 | } 59 | 60 | void PI_Iq_Loop(void) 61 | { 62 | PI_Iq.i32_e2 = PI_Iq.i32_e1; 63 | PI_Iq.i32_e1 = Motor.cmd.i16_Iq - Motor.info.i16_Iq; 64 | 65 | P_Inc_Iq = PI_Iq.flo_kp*(PI_Iq.i32_e1-PI_Iq.i32_e2); 66 | I_Inc_Iq = PI_Iq.flo_ki*PI_Iq.i32_e1; 67 | 68 | Inc_Iq = P_Inc_Iq + I_Inc_Iq; 69 | 70 | Output_Iq = Output_Iq + Inc_Iq; 71 | 72 | if(Output_Iq >= PI_Iq.i32_output_limit) Output_Iq = PI_Iq.i32_output_limit; 73 | else if(Output_Iq <= -PI_Iq.i32_output_limit) Output_Iq = -PI_Iq.i32_output_limit; 74 | 75 | Motor.info.i16_Uq = (int)Output_Iq; 76 | 77 | } 78 | 79 | void PI_Speed_Loop(void) 80 | { 81 | float output_inc; 82 | float P_output_inc; 83 | float I_output_inc; 84 | 85 | PI_Speed.i32_e2 = PI_Speed.i32_e1; 86 | PI_Speed.i32_e1 = Motor.cmd.i16_Speed - SMO.i16_Speed_Est; 87 | 88 | P_output_inc = PI_Speed.flo_kp*(PI_Speed.i32_e1-PI_Speed.i32_e2); 89 | I_output_inc = PI_Speed.flo_ki*PI_Speed.i32_e1; 90 | 91 | output_inc = P_output_inc + I_output_inc; 92 | output = output + output_inc; 93 | 94 | if(output >= PI_Speed.i32_output_limit) output = PI_Speed.i32_output_limit; 95 | else if(output < -PI_Speed.i32_output_limit) output = -PI_Speed.i32_output_limit; 96 | 97 | Motor.cmd.i16_Iq = output; 98 | } 99 | -------------------------------------------------------------------------------- /FOC_Control/PI_Control.h: -------------------------------------------------------------------------------- 1 | #ifndef _PI_Control_H_ 2 | #define _PI_Control_H_ 3 | #include 4 | 5 | extern void PI_Id_Loop(void); 6 | extern void PI_Iq_Loop(void); 7 | extern void PI_SMO_PLL(void); 8 | extern void PI_Speed_Loop(void); 9 | extern float I_Max; 10 | extern float I_Sum; 11 | extern float output; 12 | extern float P_Inc_Iq; 13 | extern float I_Inc_Iq; 14 | extern float Inc_Iq; 15 | extern float Output_Iq; 16 | 17 | extern float P_Inc_Id; 18 | extern float I_Inc_Id; 19 | extern float Inc_Id; 20 | extern float Output_Id; 21 | extern int32_t SMO_Output; 22 | 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /FOC_Control/SVPWM.h: -------------------------------------------------------------------------------- 1 | #ifndef _SVPWM_H_ 2 | #define _SVPWM_H_ 3 | 4 | #include 5 | 6 | typedef struct { 7 | int16_t PWM_Period; 8 | int16_t t1sat; 9 | int16_t t2sat; 10 | int16_t t1; 11 | int16_t t2; 12 | int16_t t_Sum; 13 | int16_t taon; 14 | int16_t tbon; 15 | int16_t tcon; 16 | int16_t Part; 17 | int16_t Sector_Old; 18 | int16_t Sector; 19 | int16_t Sector_NUM; 20 | int16_t X; 21 | int16_t Y; 22 | int16_t Z; 23 | int16_t A; 24 | int16_t B; 25 | int16_t C; 26 | int16_t Vref1; 27 | int16_t Vref2; 28 | int16_t Vref3; 29 | int16_t PDC_U; 30 | int16_t PDC_V; 31 | int16_t PDC_W; 32 | } TSVPWM16_7; 33 | 34 | 35 | extern TSVPWM16_7 SVPWM16; 36 | 37 | 38 | void SVPWM16_7(int16_t V_alpha, int16_t V_beta); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /JLinkSettings.ini: -------------------------------------------------------------------------------- 1 | [BREAKPOINTS] 2 | ForceImpTypeAny = 0 3 | ShowInfoWin = 1 4 | EnableFlashBP = 2 5 | BPDuringExecution = 0 6 | [CFI] 7 | CFISize = 0x00 8 | CFIAddr = 0x00 9 | [CPU] 10 | MonModeVTableAddr = 0xFFFFFFFF 11 | MonModeDebug = 0 12 | MaxNumAPs = 0 13 | LowPowerHandlingMode = 0 14 | OverrideMemMap = 0 15 | AllowSimulation = 1 16 | ScriptFile="" 17 | [FLASH] 18 | CacheExcludeSize = 0x00 19 | CacheExcludeAddr = 0x00 20 | MinNumBytesFlashDL = 0 21 | SkipProgOnCRCMatch = 1 22 | VerifyDownload = 1 23 | AllowCaching = 1 24 | EnableFlashDL = 2 25 | Override = 1 26 | Device="Cortex-M4" 27 | [GENERAL] 28 | WorkRAMSize = 0x00 29 | WorkRAMAddr = 0x00 30 | RAMUsageLimit = 0x00 31 | [SWO] 32 | SWOLogFile="" 33 | [MEM] 34 | RdOverrideOrMask = 0x00 35 | RdOverrideAndMask = 0xFFFFFFFF 36 | RdOverrideAddr = 0xFFFFFFFF 37 | WrOverrideOrMask = 0x00 38 | WrOverrideAndMask = 0xFFFFFFFF 39 | WrOverrideAddr = 0xFFFFFFFF 40 | -------------------------------------------------------------------------------- /KEILCLEAN.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/KEILCLEAN.bat -------------------------------------------------------------------------------- /Main/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/Main/main.c -------------------------------------------------------------------------------- /MotorTest.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/MotorTest.zip -------------------------------------------------------------------------------- /PMSM_FOC.uvoptx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0 5 | 6 |
### uVision Project, (C) Keil Software
7 | 8 | 9 | *.c 10 | *.s*; *.src; *.a* 11 | *.obj; *.o 12 | *.lib 13 | *.txt; *.h; *.inc 14 | *.plm 15 | *.cpp 16 | 0 17 | 18 | 19 | 20 | 0 21 | 0 22 | 23 | 24 | 25 | Target 1 26 | 0x4 27 | ARM-ADS 28 | 29 | 12000000 30 | 31 | 1 32 | 1 33 | 0 34 | 1 35 | 0 36 | 37 | 38 | 1 39 | 65535 40 | 0 41 | 0 42 | 0 43 | 44 | 45 | 79 46 | 66 47 | 8 48 | .\Listings\ 49 | 50 | 51 | 1 52 | 1 53 | 1 54 | 0 55 | 1 56 | 1 57 | 0 58 | 1 59 | 0 60 | 0 61 | 0 62 | 0 63 | 64 | 65 | 1 66 | 1 67 | 1 68 | 1 69 | 1 70 | 1 71 | 1 72 | 0 73 | 0 74 | 75 | 76 | 1 77 | 0 78 | 1 79 | 80 | 255 81 | 82 | 0 83 | 1 84 | 1 85 | 1 86 | 1 87 | 1 88 | 1 89 | 1 90 | 1 91 | 1 92 | 1 93 | 1 94 | 1 95 | 1 96 | 0 97 | 1 98 | 1 99 | 1 100 | 1 101 | 0 102 | 0 103 | 1 104 | 0 105 | 0 106 | 4 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | Segger\JL2CM3.dll 118 | 119 | 120 | 121 | 0 122 | UL2CM3 123 | UL2CM3(-S0 -C0 -P0 ) -FN2 -FC1000 -FD20000000 -FF0XMC4400_512 -FF1XMC4400c_512 -FL080000 -FL180000 -FS0C000000 -FS18000000 -FP0($$Device:XMC4400-F100x512$Flash\XMC4400_512.FLM) -FP1($$Device:XMC4400-F100x512$Flash\XMC4400c_512.FLM) 124 | 125 | 126 | 0 127 | JL2CM3 128 | -U591028154 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC120000000 -TP21 -TDS8077 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN2 -FF0XMC4400_512.FLM -FS0C000000 -FL080000 -FP0($$Device:XMC4400-F100x512$Flash\XMC4400_512.FLM) -FF1XMC4400c_512.FLM -FS18000000 -FL180000 -FP1($$Device:XMC4400-F100x512$Flash\XMC4400c_512.FLM) 129 | 130 | 131 | 0 132 | DLGUARM 133 | 134 | 135 | 136 | 0 137 | ARMRTXEVENTFLAGS 138 | -L70 -Z18 -C0 -M0 -T1 139 | 140 | 141 | 0 142 | DLGTARM 143 | (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0) 144 | 145 | 146 | 0 147 | ARMDBGFLAGS 148 | 149 | 150 | 151 | 152 | 153 | 154 | 0 155 | 1 156 | GlobalVar,0x0A 157 | 158 | 159 | 1 160 | 1 161 | Motor,0x0A 162 | 163 | 164 | 2 165 | 1 166 | PI_Id,0x0A 167 | 168 | 169 | 3 170 | 1 171 | PI_Iq,0x0A 172 | 173 | 174 | 4 175 | 1 176 | SVPWM16_7 177 | 178 | 179 | 5 180 | 1 181 | SVPWM16,0x0A 182 | 183 | 184 | 6 185 | 1 186 | GPIO_Init 187 | 188 | 189 | 7 190 | 1 191 | speed_time 192 | 193 | 194 | 8 195 | 1 196 | ((CCU4_CC4_TypeDef *) 0x4000C400UL)->CV[0]&0x0000FFFF,0x0A 197 | 198 | 199 | 9 200 | 1 201 | Uart_Send_Flag 202 | 203 | 204 | 10 205 | 1 206 | uart_state_flag 207 | 208 | 209 | 11 210 | 1 211 | d_sum,0x0A 212 | 213 | 214 | 12 215 | 1 216 | d_count,0x0A 217 | 218 | 219 | 13 220 | 1 221 | __disable_irq 222 | 223 | 224 | 14 225 | 1 226 | CCU80_Init 227 | 228 | 229 | 15 230 | 1 231 | SMO,0x0A 232 | 233 | 234 | 16 235 | 1 236 | Cur_Calibration_Iu_sum,0x0A 237 | 238 | 239 | 17 240 | 1 241 | Cur_Calibration_Iv_sum,0x0A 242 | 243 | 244 | 18 245 | 1 246 | Cur_Calibration_Iw_sum,0x0A 247 | 248 | 249 | 19 250 | 1 251 | PI_Speed.flo_kp,0x0A 252 | 253 | 254 | 20 255 | 1 256 | PI_Speed.flo_ki,0x0A 257 | 258 | 259 | 21 260 | 1 261 | I_Sum,0x0A 262 | 263 | 264 | 22 265 | 1 266 | PI_Speed,0x0A 267 | 268 | 269 | 23 270 | 1 271 | P_output_pos,0x10 272 | 273 | 274 | 24 275 | 1 276 | I_output_pos,0x10 277 | 278 | 279 | 25 280 | 1 281 | I_Max,0x10 282 | 283 | 284 | 26 285 | 1 286 | Motor.cmd.i16_Iq,0x0A 287 | 288 | 289 | 27 290 | 1 291 | output 292 | 293 | 294 | 28 295 | 1 296 | GPIO_Init 297 | 298 | 299 | 29 300 | 1 301 | PI_SMO,0x0A 302 | 303 | 304 | 305 | 0 306 | 307 | 308 | 0 309 | 1 310 | 1 311 | 0 312 | 0 313 | 0 314 | 0 315 | 1 316 | 0 317 | 0 318 | 0 319 | 0 320 | 0 321 | 0 322 | 0 323 | 0 324 | 0 325 | 0 326 | 0 327 | 0 328 | 1 329 | 0 330 | 0 331 | 0 332 | 333 | 334 | 335 | 0 336 | 0 337 | 0 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | MAIN 351 | 1 352 | 0 353 | 0 354 | 0 355 | 356 | 1 357 | 1 358 | 1 359 | 0 360 | 0 361 | 0 362 | .\Main\main.c 363 | main.c 364 | 0 365 | 0 366 | 367 | 368 | 369 | 370 | SYS_Init 371 | 1 372 | 0 373 | 0 374 | 0 375 | 376 | 2 377 | 2 378 | 1 379 | 0 380 | 0 381 | 0 382 | .\SYS_Init\MCU_Initialize.c 383 | MCU_Initialize.c 384 | 0 385 | 0 386 | 387 | 388 | 2 389 | 3 390 | 1 391 | 0 392 | 0 393 | 0 394 | .\SYS_Init\VAR_Initialize.c 395 | VAR_Initialize.c 396 | 0 397 | 0 398 | 399 | 400 | 401 | 402 | FOC_Control 403 | 1 404 | 0 405 | 0 406 | 0 407 | 408 | 3 409 | 4 410 | 1 411 | 0 412 | 0 413 | 0 414 | .\FOC_Control\Call_Functions.c 415 | Call_Functions.c 416 | 0 417 | 0 418 | 419 | 420 | 3 421 | 5 422 | 1 423 | 0 424 | 0 425 | 0 426 | .\FOC_Control\INT_ISR.c 427 | INT_ISR.c 428 | 0 429 | 0 430 | 431 | 432 | 3 433 | 6 434 | 1 435 | 0 436 | 0 437 | 0 438 | .\FOC_Control\PI_Control.c 439 | PI_Control.c 440 | 0 441 | 0 442 | 443 | 444 | 3 445 | 7 446 | 5 447 | 0 448 | 0 449 | 0 450 | .\FOC_Control\Motor_Functions.h 451 | Motor_Functions.h 452 | 0 453 | 0 454 | 455 | 456 | 3 457 | 8 458 | 5 459 | 0 460 | 0 461 | 0 462 | .\FOC_Control\SVPWM.h 463 | SVPWM.h 464 | 0 465 | 0 466 | 467 | 468 | 3 469 | 9 470 | 4 471 | 0 472 | 0 473 | 0 474 | .\Sensorless_Lib\PMSM_FOC.lib 475 | PMSM_FOC.lib 476 | 0 477 | 0 478 | 479 | 480 | 3 481 | 10 482 | 4 483 | 0 484 | 0 485 | 0 486 | $TC_ROOT$\..\..\study\XHY\Github\GITHUB\Sensorless_FOC\Sensorless_Lib\SVPWM.lib 487 | ..\..\study\XHY\Github\GITHUB\Sensorless_FOC\Sensorless_Lib\SVPWM.lib 488 | 0 489 | 0 490 | 491 | 492 | 493 | 494 | DEBUG 495 | 1 496 | 0 497 | 0 498 | 0 499 | 500 | 4 501 | 11 502 | 1 503 | 0 504 | 0 505 | 0 506 | .\DEBUG\Agreement.c 507 | Agreement.c 508 | 0 509 | 0 510 | 511 | 512 | 4 513 | 12 514 | 1 515 | 0 516 | 0 517 | 0 518 | .\DEBUG\DAC.c 519 | DAC.c 520 | 0 521 | 0 522 | 523 | 524 | 4 525 | 13 526 | 1 527 | 0 528 | 0 529 | 0 530 | .\DEBUG\UART.c 531 | UART.c 532 | 0 533 | 0 534 | 535 | 536 | 537 | 538 | Readme 539 | 1 540 | 0 541 | 0 542 | 0 543 | 544 | 5 545 | 14 546 | 5 547 | 0 548 | 0 549 | 0 550 | .\Readme\README.txt 551 | README.txt 552 | 0 553 | 0 554 | 555 | 556 | 557 | 558 | ::CMSIS 559 | 0 560 | 0 561 | 0 562 | 1 563 | 564 | 565 | 566 | ::Device 567 | 0 568 | 0 569 | 0 570 | 1 571 | 572 | 573 |
574 | -------------------------------------------------------------------------------- /PMSM_FOC.uvprojx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2.1 5 | 6 |
### uVision Project, (C) Keil Software
7 | 8 | 9 | 10 | Target 1 11 | 0x4 12 | ARM-ADS 13 | 5060750::V5.06 update 6 (build 750)::ARMCC 14 | 0 15 | 16 | 17 | XMC4400-F100x512 18 | Infineon 19 | Infineon.XMC4000_DFP.2.11.0 20 | http://dave.infineon.com/Libraries/CMSIS_PACK/ 21 | IRAM(0x20000000,0xFFC0) IRAM2(0x1FFFC000,0x4000) IROM(0x08000000,0x80000) IROM2(0x0C000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE 22 | 23 | 24 | UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN2 -FF0XMC4400_512 -FS0C000000 -FL080000 -FF1XMC4400c_512 -FS18000000 -FL180000 -FP0($$Device:XMC4400-F100x512$Flash\XMC4400_512.FLM) -FP1($$Device:XMC4400-F100x512$Flash\XMC4400c_512.FLM)) 25 | 0 26 | $$Device:XMC4400-F100x512$Device\XMC4400_series\Include\XMC4400.h 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | $$Device:XMC4400-F100x512$SVD\XMC4400.svd 37 | 0 38 | 0 39 | 40 | 41 | 42 | 43 | 44 | 45 | 0 46 | 0 47 | 0 48 | 0 49 | 1 50 | 51 | .\Objects\ 52 | PMSM_FOC 53 | 1 54 | 0 55 | 1 56 | 1 57 | 1 58 | .\Listings\ 59 | 1 60 | 0 61 | 0 62 | 63 | 0 64 | 0 65 | 66 | 67 | 0 68 | 0 69 | 0 70 | 0 71 | 72 | 73 | 0 74 | 0 75 | 76 | 77 | 0 78 | 0 79 | 0 80 | 0 81 | 82 | 83 | 0 84 | 0 85 | 86 | 87 | 0 88 | 0 89 | 0 90 | 0 91 | 92 | 0 93 | 94 | 95 | 96 | 0 97 | 0 98 | 0 99 | 0 100 | 0 101 | 1 102 | 0 103 | 0 104 | 0 105 | 0 106 | 3 107 | 108 | 109 | 1 110 | 111 | 112 | SARMCM3.DLL 113 | -REMAP -MPU 114 | DCM.DLL 115 | -pCM4 116 | SARMCM3.DLL 117 | -MPU 118 | TCM.DLL 119 | -pCM4 120 | 121 | 122 | 123 | 1 124 | 0 125 | 0 126 | 0 127 | 16 128 | 129 | 130 | 131 | 132 | 1 133 | 0 134 | 0 135 | 1 136 | 1 137 | 4096 138 | 139 | 1 140 | BIN\UL2CM3.DLL 141 | "" () 142 | 143 | 144 | 145 | 146 | 0 147 | 148 | 149 | 150 | 0 151 | 1 152 | 1 153 | 1 154 | 1 155 | 1 156 | 1 157 | 1 158 | 0 159 | 1 160 | 1 161 | 0 162 | 1 163 | 1 164 | 0 165 | 0 166 | 1 167 | 1 168 | 1 169 | 1 170 | 1 171 | 1 172 | 1 173 | 1 174 | 1 175 | 0 176 | 0 177 | "Cortex-M4" 178 | 179 | 0 180 | 0 181 | 0 182 | 1 183 | 1 184 | 0 185 | 0 186 | 2 187 | 0 188 | 1 189 | 1 190 | 8 191 | 0 192 | 0 193 | 0 194 | 0 195 | 3 196 | 4 197 | 0 198 | 0 199 | 0 200 | 0 201 | 0 202 | 0 203 | 0 204 | 0 205 | 0 206 | 0 207 | 1 208 | 0 209 | 0 210 | 0 211 | 0 212 | 1 213 | 1 214 | 215 | 216 | 0 217 | 0x0 218 | 0x0 219 | 220 | 221 | 0 222 | 0x0 223 | 0x0 224 | 225 | 226 | 0 227 | 0x0 228 | 0x0 229 | 230 | 231 | 0 232 | 0x0 233 | 0x0 234 | 235 | 236 | 0 237 | 0x0 238 | 0x0 239 | 240 | 241 | 0 242 | 0x0 243 | 0x0 244 | 245 | 246 | 0 247 | 0x20000000 248 | 0xffc0 249 | 250 | 251 | 1 252 | 0x8000000 253 | 0x80000 254 | 255 | 256 | 0 257 | 0x0 258 | 0x0 259 | 260 | 261 | 1 262 | 0x0 263 | 0x0 264 | 265 | 266 | 1 267 | 0x0 268 | 0x0 269 | 270 | 271 | 1 272 | 0x0 273 | 0x0 274 | 275 | 276 | 1 277 | 0x8000000 278 | 0x80000 279 | 280 | 281 | 1 282 | 0xc000000 283 | 0x80000 284 | 285 | 286 | 0 287 | 0x0 288 | 0x0 289 | 290 | 291 | 0 292 | 0x0 293 | 0x0 294 | 295 | 296 | 0 297 | 0x0 298 | 0x0 299 | 300 | 301 | 0 302 | 0x20000000 303 | 0xffc0 304 | 305 | 306 | 0 307 | 0x1fffc000 308 | 0x4000 309 | 310 | 311 | 312 | 313 | 314 | 1 315 | 1 316 | 0 317 | 0 318 | 1 319 | 0 320 | 0 321 | 0 322 | 0 323 | 0 324 | 2 325 | 0 326 | 0 327 | 1 328 | 1 329 | 0 330 | 1 331 | 1 332 | 1 333 | 1 334 | 0 335 | 0 336 | 0 337 | 338 | 339 | 340 | 341 | .\FOC;.\PMSM;.\SYS_Init;.\FOC_Control;.\DEBUG 342 | 343 | 344 | 345 | 1 346 | 0 347 | 0 348 | 0 349 | 0 350 | 0 351 | 0 352 | 0 353 | 0 354 | 0 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 1 364 | 0 365 | 0 366 | 0 367 | 1 368 | 0 369 | 0x08000000 370 | 0x20000000 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | MAIN 384 | 385 | 386 | main.c 387 | 1 388 | .\Main\main.c 389 | 390 | 391 | 392 | 393 | SYS_Init 394 | 395 | 396 | MCU_Initialize.c 397 | 1 398 | .\SYS_Init\MCU_Initialize.c 399 | 400 | 401 | VAR_Initialize.c 402 | 1 403 | .\SYS_Init\VAR_Initialize.c 404 | 405 | 406 | 407 | 408 | FOC_Control 409 | 410 | 411 | Call_Functions.c 412 | 1 413 | .\FOC_Control\Call_Functions.c 414 | 415 | 416 | INT_ISR.c 417 | 1 418 | .\FOC_Control\INT_ISR.c 419 | 420 | 421 | PI_Control.c 422 | 1 423 | .\FOC_Control\PI_Control.c 424 | 425 | 426 | Motor_Functions.h 427 | 5 428 | .\FOC_Control\Motor_Functions.h 429 | 430 | 431 | SVPWM.h 432 | 5 433 | .\FOC_Control\SVPWM.h 434 | 435 | 436 | PMSM_FOC.lib 437 | 4 438 | .\Sensorless_Lib\PMSM_FOC.lib 439 | 440 | 441 | ..\..\study\XHY\Github\GITHUB\Sensorless_FOC\Sensorless_Lib\SVPWM.lib 442 | 4 443 | $TC_ROOT$\..\..\study\XHY\Github\GITHUB\Sensorless_FOC\Sensorless_Lib\SVPWM.lib 444 | 445 | 446 | 447 | 448 | DEBUG 449 | 450 | 451 | Agreement.c 452 | 1 453 | .\DEBUG\Agreement.c 454 | 455 | 456 | DAC.c 457 | 1 458 | .\DEBUG\DAC.c 459 | 460 | 461 | UART.c 462 | 1 463 | .\DEBUG\UART.c 464 | 465 | 466 | 467 | 468 | Readme 469 | 470 | 471 | README.txt 472 | 5 473 | .\Readme\README.txt 474 | 475 | 476 | 477 | 478 | ::CMSIS 479 | 480 | 481 | ::Device 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | RTE\Device\XMC4400-F100x512\RTE_Device.h 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | RTE\Device\XMC4400-F100x512\startup_XMC4400.s 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | RTE\Device\XMC4400-F100x512\system_XMC4400.c 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | RTE\Device\XMC4400-F64x512\RTE_Device.h 560 | 561 | 562 | 563 | 564 | 565 | RTE\Device\XMC4400-F64x512\startup_XMC4400.s 566 | 567 | 568 | 569 | 570 | 571 | RTE\Device\XMC4400-F64x512\system_XMC4400.c 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 |
580 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | - [ SensorlessFOC](#head1) 2 | - [ 一、介绍 ](#head2) 3 | - [ 二、引脚定义](#head3) 4 | - [ 三、软件设计](#head4) 5 | # SensorlessFOC 6 | 感谢陆兵同学 @gitee.com/robbinlu 编写的上位机MotorTest 7 | ## 一、介绍 8 | 基于 XMC4400F100K512 的PMSM无位置传感器驱动控制程序 9 | ## 二、引脚定义 10 | 注:Sensorless FOC 不需要使用位置传感器接口 11 | + #### A/D采样输入: 12 | 13 | | Iu | Iv | Iw | RP | 14 | | :----:| :----: | :----: |:----: | 15 | | P14.2 | P15.2 | P14.8 | P14.1 | 16 | 17 | + #### 六路PWM脉冲输出: 18 | 19 | | UH | UL | VH | VL | WH | WL | 20 | | :----:| :----: | :----: |:----: | :----: | :----: | 21 | | P0.5 | P0.2 | P0.4 | P0.1 | P0.3 | P0.0 | 22 | 23 | + #### D/A输出: 24 | 25 | | DAC1 | 26 | | :----:| 27 | | P14.9 | 28 | 29 | + #### 通讯接口 (UART): 30 | 31 | | RX | TX | 32 | | :----:| :----: | 33 | | P2.2 | P2.5 | 34 | 35 | ## 三、软件设计 36 | * #### 底层驱动 : 37 | 1. **CCU8** : 38 | - 生成3路带死区的互补的PWM信号 39 | - 一路专用的PWM用于触发采样和PWM占空比更新 40 | 2. **VADC** : 41 | - VADC0 G0、G2、G3三组同步采样(G0主 G2,G3从) 42 | 3. **POSIF** : 43 | - 独立多通道模式用于保护封波 44 | 4. **USIC** : 45 | - ASC协议UART模式,用于和上位机通信 46 | 5. **DAC**: 47 | - DAC1输出用于观测器和角度的实时Debug 48 | 49 | * #### 主要中断: 50 | 1. **CCU80_0_IRQHandler**: 51 | - 更新下一个62.5us内的PWM信号占空比 52 | - 处理初始定位和闭环I/F启动相关流程 53 | 2. **VADC0_G0_0_IRQHandler**: 54 | - 三相电流重构 55 | - 观测器反电势估计 56 | - 锁相环角度估计与转速估计 57 | - I/F-FOC切换相关流程 58 | - dq轴电流环运算 59 | - 虚拟示波器Flash存储 60 | 1. **SysTick_Handler**: 61 | - 转速环运算 62 | - 上位机显示 63 | - 虚拟示波器Flash数据显示 64 | 65 | Control_Loop_Mode 1:电流单闭环 2:转速电流双闭环 66 | -------------------------------------------------------------------------------- /RTE/Device/XMC4400-F100x512/startup_XMC4400.s: -------------------------------------------------------------------------------- 1 | ;******************************************************************************* 2 | ;* @file startup_XMC4400.s 3 | ;* @brief CMSIS Core Device Startup File for 4 | ;* Infineon XMC4400 Device Series 5 | ;* @version V1.5 6 | ;* @date June 2016 7 | ;* 8 | ;* @cond 9 | ;********************************************************************************************************************* 10 | ;* Copyright (c) 2012-2016, Infineon Technologies AG 11 | ;* All rights reserved. 12 | ;* 13 | ;* Redistribution and use in source and binary forms, with or without modification,are permitted provided that the 14 | ;* following conditions are met: 15 | ;* 16 | ;* Redistributions of source code must retain the above copyright notice, this list of conditions and the following 17 | ;* disclaimer. 18 | ;* 19 | ;* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 20 | ;* disclaimer in the documentation and/or other materials provided with the distribution. 21 | ;* 22 | ;* Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote 23 | ;* products derived from this software without specific prior written permission. 24 | ;* 25 | ;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 26 | ;* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | ;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | ;* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | ;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 | ;* WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | ;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | ;* 33 | ;* To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with 34 | ;* Infineon Technologies AG dave@infineon.com). 35 | ;********************************************************************************************************************* 36 | ;* 37 | ;************************** Version History ************************************ 38 | ; V0.2, August 2012, First version 39 | ; V1.0, February 2013, FIX for CPU prefetch bug implemented 40 | ; V1.1, August 2013, Fix the bug of stack pointer alignment to a 8 byte boundary 41 | ; V1.2, November 2014, Disable CPU workaround. Increased stack size. 42 | ; Removed DAVE3 dependency 43 | ; V1.3, November 2015, Remove peripherals not included in device. 44 | ; V1.4, March 2016, Fix weak definition of Veneers. 45 | ; Only relevant for AA, which needs ENABLE_PMU_CM_001_WORKAROUND 46 | ; V1.5, June 2016, Rename ENABLE_CPU_CM_001_WORKAROUND to ENABLE_PMU_CM_001_WORKAROUND 47 | ; Action required: If using AA step, use ENABLE_PMU_CM_001_WORKAROUND instead of ENABLE_CPU_CM_001_WORKAROUND 48 | ;******************************************************************************* 49 | ;* @endcond 50 | 51 | ; ------------------ <<< Use Configuration Wizard in Context Menu >>> ------------------ 52 | 53 | ; Stack Configuration 54 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> 55 | ; 56 | 57 | Stack_Size EQU 0x00000800 58 | 59 | AREA STACK, NOINIT, READWRITE, ALIGN=3 60 | Stack_Mem SPACE Stack_Size 61 | __initial_sp 62 | 63 | 64 | ; Heap Configuration 65 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> 66 | ; 67 | 68 | Heap_Size EQU 0x00000200 69 | 70 | AREA HEAP, NOINIT, READWRITE, ALIGN=3 71 | __heap_base 72 | Heap_Mem SPACE Heap_Size 73 | __heap_limit 74 | 75 | PRESERVE8 76 | THUMB 77 | 78 | IF :DEF:ENABLE_PMU_CM_001_WORKAROUND 79 | MACRO 80 | Entry $Handler 81 | DCD $Handler._Veneer 82 | MEND 83 | ELSE 84 | MACRO 85 | Entry $Handler 86 | DCD $Handler 87 | MEND 88 | ENDIF 89 | 90 | ; Vector Table Mapped to Address 0 at Reset 91 | 92 | AREA RESET, DATA, READONLY 93 | EXPORT __Vectors 94 | EXPORT __Vectors_End 95 | EXPORT __Vectors_Size 96 | 97 | __Vectors DCD __initial_sp ; 0 Top of Stack 98 | DCD Reset_Handler ; 1 Reset Handler 99 | Entry NMI_Handler ; 2 NMI Handler 100 | Entry HardFault_Handler ; 3 Hard Fault Handler 101 | Entry MemManage_Handler ; 4 MPU Fault Handler 102 | Entry BusFault_Handler ; 5 Bus Fault Handler 103 | Entry UsageFault_Handler ; 6 Usage Fault Handler 104 | DCD 0 ; 7 Reserved 105 | DCD 0 ; 8 Reserved 106 | DCD 0 ; 9 Reserved 107 | DCD 0 ; 10 Reserved 108 | Entry SVC_Handler ; 11 SVCall Handler 109 | Entry DebugMon_Handler ; 12 Debug Monitor Handler 110 | DCD 0 ; 13 Reserved 111 | Entry PendSV_Handler ; 14 PendSV Handler 112 | Entry SysTick_Handler ; 15 SysTick Handler 113 | 114 | ; Interrupt Handlers for Service Requests (SR) from XMC4400 Peripherals */ 115 | Entry SCU_0_IRQHandler ; Handler name for SR SCU_0 116 | Entry ERU0_0_IRQHandler ; Handler name for SR ERU0_0 117 | Entry ERU0_1_IRQHandler ; Handler name for SR ERU0_1 118 | Entry ERU0_2_IRQHandler ; Handler name for SR ERU0_2 119 | Entry ERU0_3_IRQHandler ; Handler name for SR ERU0_3 120 | Entry ERU1_0_IRQHandler ; Handler name for SR ERU1_0 121 | Entry ERU1_1_IRQHandler ; Handler name for SR ERU1_1 122 | Entry ERU1_2_IRQHandler ; Handler name for SR ERU1_2 123 | Entry ERU1_3_IRQHandler ; Handler name for SR ERU1_3 124 | DCD 0 ; Not Available 125 | DCD 0 ; Not Available 126 | DCD 0 ; Not Available 127 | Entry PMU0_0_IRQHandler ; Handler name for SR PMU0_0 128 | DCD 0 ; Not Available 129 | Entry VADC0_C0_0_IRQHandler ; Handler name for SR VADC0_C0_0 130 | Entry VADC0_C0_1_IRQHandler ; Handler name for SR VADC0_C0_1 131 | Entry VADC0_C0_2_IRQHandler ; Handler name for SR VADC0_C0_1 132 | Entry VADC0_C0_3_IRQHandler ; Handler name for SR VADC0_C0_3 133 | Entry VADC0_G0_0_IRQHandler ; Handler name for SR VADC0_G0_0 134 | Entry VADC0_G0_1_IRQHandler ; Handler name for SR VADC0_G0_1 135 | Entry VADC0_G0_2_IRQHandler ; Handler name for SR VADC0_G0_2 136 | Entry VADC0_G0_3_IRQHandler ; Handler name for SR VADC0_G0_3 137 | Entry VADC0_G1_0_IRQHandler ; Handler name for SR VADC0_G1_0 138 | Entry VADC0_G1_1_IRQHandler ; Handler name for SR VADC0_G1_1 139 | Entry VADC0_G1_2_IRQHandler ; Handler name for SR VADC0_G1_2 140 | Entry VADC0_G1_3_IRQHandler ; Handler name for SR VADC0_G1_3 141 | Entry VADC0_G2_0_IRQHandler ; Handler name for SR VADC0_G2_0 142 | Entry VADC0_G2_1_IRQHandler ; Handler name for SR VADC0_G2_1 143 | Entry VADC0_G2_2_IRQHandler ; Handler name for SR VADC0_G2_2 144 | Entry VADC0_G2_3_IRQHandler ; Handler name for SR VADC0_G2_3 145 | Entry VADC0_G3_0_IRQHandler ; Handler name for SR VADC0_G3_0 146 | Entry VADC0_G3_1_IRQHandler ; Handler name for SR VADC0_G3_1 147 | Entry VADC0_G3_2_IRQHandler ; Handler name for SR VADC0_G3_2 148 | Entry VADC0_G3_3_IRQHandler ; Handler name for SR VADC0_G3_3 149 | Entry DSD0_0_IRQHandler ; Handler name for SR DSD_SRM_0 150 | Entry DSD0_1_IRQHandler ; Handler name for SR DSD_SRM_1 151 | Entry DSD0_2_IRQHandler ; Handler name for SR DSD_SRM_2 152 | Entry DSD0_3_IRQHandler ; Handler name for SR DSD_SRM_3 153 | Entry DSD0_4_IRQHandler ; Handler name for SR DSD_SRA_0 154 | Entry DSD0_5_IRQHandler ; Handler name for SR DSD_SRA_1 155 | Entry DSD0_6_IRQHandler ; Handler name for SR DSD_SRA_2 156 | Entry DSD0_7_IRQHandler ; Handler name for SR DSD_SRA_3 157 | Entry DAC0_0_IRQHandler ; Handler name for SR DAC0_0 158 | Entry DAC0_1_IRQHandler ; Handler name for SR DAC0_1 159 | Entry CCU40_0_IRQHandler ; Handler name for SR CCU40_0 160 | Entry CCU40_1_IRQHandler ; Handler name for SR CCU40_1 161 | Entry CCU40_2_IRQHandler ; Handler name for SR CCU40_2 162 | Entry CCU40_3_IRQHandler ; Handler name for SR CCU40_3 163 | Entry CCU41_0_IRQHandler ; Handler name for SR CCU41_0 164 | Entry CCU41_1_IRQHandler ; Handler name for SR CCU41_1 165 | Entry CCU41_2_IRQHandler ; Handler name for SR CCU41_2 166 | Entry CCU41_3_IRQHandler ; Handler name for SR CCU41_3 167 | Entry CCU42_0_IRQHandler ; Handler name for SR CCU42_0 168 | Entry CCU42_1_IRQHandler ; Handler name for SR CCU42_1 169 | Entry CCU42_2_IRQHandler ; Handler name for SR CCU42_2 170 | Entry CCU42_3_IRQHandler ; Handler name for SR CCU42_3 171 | Entry CCU43_0_IRQHandler ; Handler name for SR CCU43_0 172 | Entry CCU43_1_IRQHandler ; Handler name for SR CCU43_1 173 | Entry CCU43_2_IRQHandler ; Handler name for SR CCU43_2 174 | Entry CCU43_3_IRQHandler ; Handler name for SR CCU43_3 175 | Entry CCU80_0_IRQHandler ; Handler name for SR CCU80_0 176 | Entry CCU80_1_IRQHandler ; Handler name for SR CCU80_1 177 | Entry CCU80_2_IRQHandler ; Handler name for SR CCU80_2 178 | Entry CCU80_3_IRQHandler ; Handler name for SR CCU80_3 179 | Entry CCU81_0_IRQHandler ; Handler name for SR CCU81_0 180 | Entry CCU81_1_IRQHandler ; Handler name for SR CCU81_1 181 | Entry CCU81_2_IRQHandler ; Handler name for SR CCU81_2 182 | Entry CCU81_3_IRQHandler ; Handler name for SR CCU81_3 183 | Entry POSIF0_0_IRQHandler ; Handler name for SR POSIF0_0 184 | Entry POSIF0_1_IRQHandler ; Handler name for SR POSIF0_1 185 | Entry POSIF1_0_IRQHandler ; Handler name for SR POSIF1_0 186 | Entry POSIF1_1_IRQHandler ; Handler name for SR POSIF1_1 187 | Entry HRPWM_0_IRQHandler ; Handler name for SR HRPWM_0 188 | Entry HRPWM_1_IRQHandler ; Handler name for SR HRPWM_1 189 | Entry HRPWM_2_IRQHandler ; Handler name for SR HRPWM_2 190 | Entry HRPWM_3_IRQHandler ; Handler name for SR HRPWM_3 191 | Entry CAN0_0_IRQHandler ; Handler name for SR CAN0_0 192 | Entry CAN0_1_IRQHandler ; Handler name for SR CAN0_1 193 | Entry CAN0_2_IRQHandler ; Handler name for SR CAN0_2 194 | Entry CAN0_3_IRQHandler ; Handler name for SR CAN0_3 195 | Entry CAN0_4_IRQHandler ; Handler name for SR CAN0_4 196 | Entry CAN0_5_IRQHandler ; Handler name for SR CAN0_5 197 | Entry CAN0_6_IRQHandler ; Handler name for SR CAN0_6 198 | Entry CAN0_7_IRQHandler ; Handler name for SR CAN0_7 199 | Entry USIC0_0_IRQHandler ; Handler name for SR USIC0_0 200 | Entry USIC0_1_IRQHandler ; Handler name for SR USIC0_1 201 | Entry USIC0_2_IRQHandler ; Handler name for SR USIC0_2 202 | Entry USIC0_3_IRQHandler ; Handler name for SR USIC0_3 203 | Entry USIC0_4_IRQHandler ; Handler name for SR USIC0_4 204 | Entry USIC0_5_IRQHandler ; Handler name for SR USIC0_5 205 | Entry USIC1_0_IRQHandler ; Handler name for SR USIC1_0 206 | Entry USIC1_1_IRQHandler ; Handler name for SR USIC1_1 207 | Entry USIC1_2_IRQHandler ; Handler name for SR USIC1_2 208 | Entry USIC1_3_IRQHandler ; Handler name for SR USIC1_3 209 | Entry USIC1_4_IRQHandler ; Handler name for SR USIC1_4 210 | Entry USIC1_5_IRQHandler ; Handler name for SR USIC1_5 211 | DCD 0 ; Not Available 212 | DCD 0 ; Not Available 213 | DCD 0 ; Not Available 214 | DCD 0 ; Not Available 215 | DCD 0 ; Not Available 216 | DCD 0 ; Not Available 217 | Entry LEDTS0_0_IRQHandler ; Handler name for SR LEDTS0_0 218 | DCD 0 ; Not Available 219 | Entry FCE0_0_IRQHandler ; Handler name for SR FCE0_0 220 | Entry GPDMA0_0_IRQHandler ; Handler name for SR GPDMA0_0 221 | DCD 0 ; Not Available 222 | Entry USB0_0_IRQHandler ; Handler name for SR USB0_0 223 | Entry ETH0_0_IRQHandler ; Handler name for SR ETH0_0 224 | DCD 0 ; Not Available 225 | DCD 0 ; Not Available 226 | DCD 0 ; Not Available 227 | __Vectors_End 228 | 229 | __Vectors_Size EQU __Vectors_End - __Vectors 230 | 231 | AREA |.text|, CODE, READONLY 232 | 233 | ; Reset Handler 234 | 235 | Reset_Handler PROC 236 | EXPORT Reset_Handler [WEAK] 237 | IMPORT SystemInit 238 | IMPORT __main 239 | LDR SP, =__initial_sp 240 | LDR R0, =SystemInit 241 | BLX R0 242 | LDR R0, =__main 243 | BX R0 244 | ENDP 245 | 246 | ; Dummy Exception Handlers (infinite loops which can be modified) 247 | 248 | Default_Handler PROC 249 | EXPORT NMI_Handler [WEAK] 250 | EXPORT HardFault_Handler [WEAK] 251 | EXPORT MemManage_Handler [WEAK] 252 | EXPORT BusFault_Handler [WEAK] 253 | EXPORT UsageFault_Handler [WEAK] 254 | EXPORT SVC_Handler [WEAK] 255 | EXPORT DebugMon_Handler [WEAK] 256 | EXPORT PendSV_Handler [WEAK] 257 | EXPORT SysTick_Handler [WEAK] 258 | 259 | EXPORT SCU_0_IRQHandler [WEAK] 260 | EXPORT ERU0_0_IRQHandler [WEAK] 261 | EXPORT ERU0_1_IRQHandler [WEAK] 262 | EXPORT ERU0_2_IRQHandler [WEAK] 263 | EXPORT ERU0_3_IRQHandler [WEAK] 264 | EXPORT ERU1_0_IRQHandler [WEAK] 265 | EXPORT ERU1_1_IRQHandler [WEAK] 266 | EXPORT ERU1_2_IRQHandler [WEAK] 267 | EXPORT ERU1_3_IRQHandler [WEAK] 268 | EXPORT PMU0_0_IRQHandler [WEAK] 269 | EXPORT VADC0_C0_0_IRQHandler [WEAK] 270 | EXPORT VADC0_C0_1_IRQHandler [WEAK] 271 | EXPORT VADC0_C0_2_IRQHandler [WEAK] 272 | EXPORT VADC0_C0_3_IRQHandler [WEAK] 273 | EXPORT VADC0_G0_0_IRQHandler [WEAK] 274 | EXPORT VADC0_G0_1_IRQHandler [WEAK] 275 | EXPORT VADC0_G0_2_IRQHandler [WEAK] 276 | EXPORT VADC0_G0_3_IRQHandler [WEAK] 277 | EXPORT VADC0_G1_0_IRQHandler [WEAK] 278 | EXPORT VADC0_G1_1_IRQHandler [WEAK] 279 | EXPORT VADC0_G1_2_IRQHandler [WEAK] 280 | EXPORT VADC0_G1_3_IRQHandler [WEAK] 281 | EXPORT VADC0_G2_0_IRQHandler [WEAK] 282 | EXPORT VADC0_G2_1_IRQHandler [WEAK] 283 | EXPORT VADC0_G2_2_IRQHandler [WEAK] 284 | EXPORT VADC0_G2_3_IRQHandler [WEAK] 285 | EXPORT VADC0_G3_0_IRQHandler [WEAK] 286 | EXPORT VADC0_G3_1_IRQHandler [WEAK] 287 | EXPORT VADC0_G3_2_IRQHandler [WEAK] 288 | EXPORT VADC0_G3_3_IRQHandler [WEAK] 289 | EXPORT DSD0_0_IRQHandler [WEAK] 290 | EXPORT DSD0_1_IRQHandler [WEAK] 291 | EXPORT DSD0_2_IRQHandler [WEAK] 292 | EXPORT DSD0_3_IRQHandler [WEAK] 293 | EXPORT DSD0_4_IRQHandler [WEAK] 294 | EXPORT DSD0_5_IRQHandler [WEAK] 295 | EXPORT DSD0_6_IRQHandler [WEAK] 296 | EXPORT DSD0_7_IRQHandler [WEAK] 297 | EXPORT DAC0_0_IRQHandler [WEAK] 298 | EXPORT DAC0_1_IRQHandler [WEAK] 299 | EXPORT CCU40_0_IRQHandler [WEAK] 300 | EXPORT CCU40_1_IRQHandler [WEAK] 301 | EXPORT CCU40_2_IRQHandler [WEAK] 302 | EXPORT CCU40_3_IRQHandler [WEAK] 303 | EXPORT CCU41_0_IRQHandler [WEAK] 304 | EXPORT CCU41_1_IRQHandler [WEAK] 305 | EXPORT CCU41_2_IRQHandler [WEAK] 306 | EXPORT CCU41_3_IRQHandler [WEAK] 307 | EXPORT CCU42_0_IRQHandler [WEAK] 308 | EXPORT CCU42_1_IRQHandler [WEAK] 309 | EXPORT CCU42_2_IRQHandler [WEAK] 310 | EXPORT CCU42_3_IRQHandler [WEAK] 311 | EXPORT CCU43_0_IRQHandler [WEAK] 312 | EXPORT CCU43_1_IRQHandler [WEAK] 313 | EXPORT CCU43_2_IRQHandler [WEAK] 314 | EXPORT CCU43_3_IRQHandler [WEAK] 315 | EXPORT CCU80_0_IRQHandler [WEAK] 316 | EXPORT CCU80_1_IRQHandler [WEAK] 317 | EXPORT CCU80_2_IRQHandler [WEAK] 318 | EXPORT CCU80_3_IRQHandler [WEAK] 319 | EXPORT CCU81_0_IRQHandler [WEAK] 320 | EXPORT CCU81_1_IRQHandler [WEAK] 321 | EXPORT CCU81_2_IRQHandler [WEAK] 322 | EXPORT CCU81_3_IRQHandler [WEAK] 323 | EXPORT POSIF0_0_IRQHandler [WEAK] 324 | EXPORT POSIF0_1_IRQHandler [WEAK] 325 | EXPORT POSIF1_0_IRQHandler [WEAK] 326 | EXPORT POSIF1_1_IRQHandler [WEAK] 327 | EXPORT HRPWM_0_IRQHandler [WEAK] 328 | EXPORT HRPWM_1_IRQHandler [WEAK] 329 | EXPORT HRPWM_2_IRQHandler [WEAK] 330 | EXPORT HRPWM_3_IRQHandler [WEAK] 331 | EXPORT CAN0_0_IRQHandler [WEAK] 332 | EXPORT CAN0_1_IRQHandler [WEAK] 333 | EXPORT CAN0_2_IRQHandler [WEAK] 334 | EXPORT CAN0_3_IRQHandler [WEAK] 335 | EXPORT CAN0_4_IRQHandler [WEAK] 336 | EXPORT CAN0_5_IRQHandler [WEAK] 337 | EXPORT CAN0_6_IRQHandler [WEAK] 338 | EXPORT CAN0_7_IRQHandler [WEAK] 339 | EXPORT USIC0_0_IRQHandler [WEAK] 340 | EXPORT USIC0_1_IRQHandler [WEAK] 341 | EXPORT USIC0_2_IRQHandler [WEAK] 342 | EXPORT USIC0_3_IRQHandler [WEAK] 343 | EXPORT USIC0_4_IRQHandler [WEAK] 344 | EXPORT USIC0_5_IRQHandler [WEAK] 345 | EXPORT USIC1_0_IRQHandler [WEAK] 346 | EXPORT USIC1_1_IRQHandler [WEAK] 347 | EXPORT USIC1_2_IRQHandler [WEAK] 348 | EXPORT USIC1_3_IRQHandler [WEAK] 349 | EXPORT USIC1_4_IRQHandler [WEAK] 350 | EXPORT USIC1_5_IRQHandler [WEAK] 351 | EXPORT LEDTS0_0_IRQHandler [WEAK] 352 | EXPORT FCE0_0_IRQHandler [WEAK] 353 | EXPORT GPDMA0_0_IRQHandler [WEAK] 354 | EXPORT USB0_0_IRQHandler [WEAK] 355 | EXPORT ETH0_0_IRQHandler [WEAK] 356 | 357 | NMI_Handler 358 | HardFault_Handler 359 | MemManage_Handler 360 | BusFault_Handler 361 | UsageFault_Handler 362 | SVC_Handler 363 | DebugMon_Handler 364 | PendSV_Handler 365 | SysTick_Handler 366 | SCU_0_IRQHandler 367 | ERU0_0_IRQHandler 368 | ERU0_1_IRQHandler 369 | ERU0_2_IRQHandler 370 | ERU0_3_IRQHandler 371 | ERU1_0_IRQHandler 372 | ERU1_1_IRQHandler 373 | ERU1_2_IRQHandler 374 | ERU1_3_IRQHandler 375 | PMU0_0_IRQHandler 376 | VADC0_C0_0_IRQHandler 377 | VADC0_C0_1_IRQHandler 378 | VADC0_C0_2_IRQHandler 379 | VADC0_C0_3_IRQHandler 380 | VADC0_G0_0_IRQHandler 381 | VADC0_G0_1_IRQHandler 382 | VADC0_G0_2_IRQHandler 383 | VADC0_G0_3_IRQHandler 384 | VADC0_G1_0_IRQHandler 385 | VADC0_G1_1_IRQHandler 386 | VADC0_G1_2_IRQHandler 387 | VADC0_G1_3_IRQHandler 388 | VADC0_G2_0_IRQHandler 389 | VADC0_G2_1_IRQHandler 390 | VADC0_G2_2_IRQHandler 391 | VADC0_G2_3_IRQHandler 392 | VADC0_G3_0_IRQHandler 393 | VADC0_G3_1_IRQHandler 394 | VADC0_G3_2_IRQHandler 395 | VADC0_G3_3_IRQHandler 396 | DSD0_0_IRQHandler 397 | DSD0_1_IRQHandler 398 | DSD0_2_IRQHandler 399 | DSD0_3_IRQHandler 400 | DSD0_4_IRQHandler 401 | DSD0_5_IRQHandler 402 | DSD0_6_IRQHandler 403 | DSD0_7_IRQHandler 404 | DAC0_0_IRQHandler 405 | DAC0_1_IRQHandler 406 | CCU40_0_IRQHandler 407 | CCU40_1_IRQHandler 408 | CCU40_2_IRQHandler 409 | CCU40_3_IRQHandler 410 | CCU41_0_IRQHandler 411 | CCU41_1_IRQHandler 412 | CCU41_2_IRQHandler 413 | CCU41_3_IRQHandler 414 | CCU42_0_IRQHandler 415 | CCU42_1_IRQHandler 416 | CCU42_2_IRQHandler 417 | CCU42_3_IRQHandler 418 | CCU43_0_IRQHandler 419 | CCU43_1_IRQHandler 420 | CCU43_2_IRQHandler 421 | CCU43_3_IRQHandler 422 | CCU80_0_IRQHandler 423 | CCU80_1_IRQHandler 424 | CCU80_2_IRQHandler 425 | CCU80_3_IRQHandler 426 | CCU81_0_IRQHandler 427 | CCU81_1_IRQHandler 428 | CCU81_2_IRQHandler 429 | CCU81_3_IRQHandler 430 | POSIF0_0_IRQHandler 431 | POSIF0_1_IRQHandler 432 | POSIF1_0_IRQHandler 433 | POSIF1_1_IRQHandler 434 | HRPWM_0_IRQHandler 435 | HRPWM_1_IRQHandler 436 | HRPWM_2_IRQHandler 437 | HRPWM_3_IRQHandler 438 | CAN0_0_IRQHandler 439 | CAN0_1_IRQHandler 440 | CAN0_2_IRQHandler 441 | CAN0_3_IRQHandler 442 | CAN0_4_IRQHandler 443 | CAN0_5_IRQHandler 444 | CAN0_6_IRQHandler 445 | CAN0_7_IRQHandler 446 | USIC0_0_IRQHandler 447 | USIC0_1_IRQHandler 448 | USIC0_2_IRQHandler 449 | USIC0_3_IRQHandler 450 | USIC0_4_IRQHandler 451 | USIC0_5_IRQHandler 452 | USIC1_0_IRQHandler 453 | USIC1_1_IRQHandler 454 | USIC1_2_IRQHandler 455 | USIC1_3_IRQHandler 456 | USIC1_4_IRQHandler 457 | USIC1_5_IRQHandler 458 | LEDTS0_0_IRQHandler 459 | FCE0_0_IRQHandler 460 | GPDMA0_0_IRQHandler 461 | USB0_0_IRQHandler 462 | ETH0_0_IRQHandler 463 | 464 | B . 465 | 466 | ENDP 467 | 468 | IF :DEF:ENABLE_PMU_CM_001_WORKAROUND 469 | 470 | MACRO 471 | Insert_ExceptionHandlerVeneer $Handler_Func 472 | $Handler_Func._Veneer\ 473 | PROC 474 | EXPORT $Handler_Func._Veneer [WEAK] 475 | LDR R0, =$Handler_Func 476 | PUSH {LR} ;/* Breaks AAPCS */ 477 | SUB SP,#4 ;/* Restores AAPCS */ 478 | BLX R0 479 | ADD SP,#4 480 | POP {PC} 481 | ALIGN 482 | LTORG 483 | ENDP 484 | MEND 485 | 486 | Insert_ExceptionHandlerVeneer NMI_Handler 487 | Insert_ExceptionHandlerVeneer HardFault_Handler 488 | Insert_ExceptionHandlerVeneer MemManage_Handler 489 | Insert_ExceptionHandlerVeneer BusFault_Handler 490 | Insert_ExceptionHandlerVeneer UsageFault_Handler 491 | Insert_ExceptionHandlerVeneer SVC_Handler 492 | Insert_ExceptionHandlerVeneer DebugMon_Handler 493 | Insert_ExceptionHandlerVeneer PendSV_Handler 494 | Insert_ExceptionHandlerVeneer SysTick_Handler 495 | 496 | Insert_ExceptionHandlerVeneer SCU_0_IRQHandler 497 | Insert_ExceptionHandlerVeneer ERU0_0_IRQHandler 498 | Insert_ExceptionHandlerVeneer ERU0_1_IRQHandler 499 | Insert_ExceptionHandlerVeneer ERU0_2_IRQHandler 500 | Insert_ExceptionHandlerVeneer ERU0_3_IRQHandler 501 | Insert_ExceptionHandlerVeneer ERU1_0_IRQHandler 502 | Insert_ExceptionHandlerVeneer ERU1_1_IRQHandler 503 | Insert_ExceptionHandlerVeneer ERU1_2_IRQHandler 504 | Insert_ExceptionHandlerVeneer ERU1_3_IRQHandler 505 | Insert_ExceptionHandlerVeneer PMU0_0_IRQHandler 506 | Insert_ExceptionHandlerVeneer VADC0_C0_0_IRQHandler 507 | Insert_ExceptionHandlerVeneer VADC0_C0_1_IRQHandler 508 | Insert_ExceptionHandlerVeneer VADC0_C0_2_IRQHandler 509 | Insert_ExceptionHandlerVeneer VADC0_C0_3_IRQHandler 510 | Insert_ExceptionHandlerVeneer VADC0_G0_0_IRQHandler 511 | Insert_ExceptionHandlerVeneer VADC0_G0_1_IRQHandler 512 | Insert_ExceptionHandlerVeneer VADC0_G0_2_IRQHandler 513 | Insert_ExceptionHandlerVeneer VADC0_G0_3_IRQHandler 514 | Insert_ExceptionHandlerVeneer VADC0_G1_0_IRQHandler 515 | Insert_ExceptionHandlerVeneer VADC0_G1_1_IRQHandler 516 | Insert_ExceptionHandlerVeneer VADC0_G1_2_IRQHandler 517 | Insert_ExceptionHandlerVeneer VADC0_G1_3_IRQHandler 518 | Insert_ExceptionHandlerVeneer VADC0_G2_0_IRQHandler 519 | Insert_ExceptionHandlerVeneer VADC0_G2_1_IRQHandler 520 | Insert_ExceptionHandlerVeneer VADC0_G2_2_IRQHandler 521 | Insert_ExceptionHandlerVeneer VADC0_G2_3_IRQHandler 522 | Insert_ExceptionHandlerVeneer VADC0_G3_0_IRQHandler 523 | Insert_ExceptionHandlerVeneer VADC0_G3_1_IRQHandler 524 | Insert_ExceptionHandlerVeneer VADC0_G3_2_IRQHandler 525 | Insert_ExceptionHandlerVeneer VADC0_G3_3_IRQHandler 526 | Insert_ExceptionHandlerVeneer DSD0_0_IRQHandler 527 | Insert_ExceptionHandlerVeneer DSD0_1_IRQHandler 528 | Insert_ExceptionHandlerVeneer DSD0_2_IRQHandler 529 | Insert_ExceptionHandlerVeneer DSD0_3_IRQHandler 530 | Insert_ExceptionHandlerVeneer DSD0_4_IRQHandler 531 | Insert_ExceptionHandlerVeneer DSD0_5_IRQHandler 532 | Insert_ExceptionHandlerVeneer DSD0_6_IRQHandler 533 | Insert_ExceptionHandlerVeneer DSD0_7_IRQHandler 534 | Insert_ExceptionHandlerVeneer DAC0_0_IRQHandler 535 | Insert_ExceptionHandlerVeneer DAC0_1_IRQHandler 536 | Insert_ExceptionHandlerVeneer CCU40_0_IRQHandler 537 | Insert_ExceptionHandlerVeneer CCU40_1_IRQHandler 538 | Insert_ExceptionHandlerVeneer CCU40_2_IRQHandler 539 | Insert_ExceptionHandlerVeneer CCU40_3_IRQHandler 540 | Insert_ExceptionHandlerVeneer CCU41_0_IRQHandler 541 | Insert_ExceptionHandlerVeneer CCU41_1_IRQHandler 542 | Insert_ExceptionHandlerVeneer CCU41_2_IRQHandler 543 | Insert_ExceptionHandlerVeneer CCU41_3_IRQHandler 544 | Insert_ExceptionHandlerVeneer CCU42_0_IRQHandler 545 | Insert_ExceptionHandlerVeneer CCU42_1_IRQHandler 546 | Insert_ExceptionHandlerVeneer CCU42_2_IRQHandler 547 | Insert_ExceptionHandlerVeneer CCU42_3_IRQHandler 548 | Insert_ExceptionHandlerVeneer CCU43_0_IRQHandler 549 | Insert_ExceptionHandlerVeneer CCU43_1_IRQHandler 550 | Insert_ExceptionHandlerVeneer CCU43_2_IRQHandler 551 | Insert_ExceptionHandlerVeneer CCU43_3_IRQHandler 552 | Insert_ExceptionHandlerVeneer CCU80_0_IRQHandler 553 | Insert_ExceptionHandlerVeneer CCU80_1_IRQHandler 554 | Insert_ExceptionHandlerVeneer CCU80_2_IRQHandler 555 | Insert_ExceptionHandlerVeneer CCU80_3_IRQHandler 556 | Insert_ExceptionHandlerVeneer CCU81_0_IRQHandler 557 | Insert_ExceptionHandlerVeneer CCU81_1_IRQHandler 558 | Insert_ExceptionHandlerVeneer CCU81_2_IRQHandler 559 | Insert_ExceptionHandlerVeneer CCU81_3_IRQHandler 560 | Insert_ExceptionHandlerVeneer POSIF0_0_IRQHandler 561 | Insert_ExceptionHandlerVeneer POSIF0_1_IRQHandler 562 | Insert_ExceptionHandlerVeneer POSIF1_0_IRQHandler 563 | Insert_ExceptionHandlerVeneer POSIF1_1_IRQHandler 564 | Insert_ExceptionHandlerVeneer HRPWM_0_IRQHandler 565 | Insert_ExceptionHandlerVeneer HRPWM_1_IRQHandler 566 | Insert_ExceptionHandlerVeneer HRPWM_2_IRQHandler 567 | Insert_ExceptionHandlerVeneer HRPWM_3_IRQHandler 568 | Insert_ExceptionHandlerVeneer CAN0_0_IRQHandler 569 | Insert_ExceptionHandlerVeneer CAN0_1_IRQHandler 570 | Insert_ExceptionHandlerVeneer CAN0_2_IRQHandler 571 | Insert_ExceptionHandlerVeneer CAN0_3_IRQHandler 572 | Insert_ExceptionHandlerVeneer CAN0_4_IRQHandler 573 | Insert_ExceptionHandlerVeneer CAN0_5_IRQHandler 574 | Insert_ExceptionHandlerVeneer CAN0_6_IRQHandler 575 | Insert_ExceptionHandlerVeneer CAN0_7_IRQHandler 576 | Insert_ExceptionHandlerVeneer USIC0_0_IRQHandler 577 | Insert_ExceptionHandlerVeneer USIC0_1_IRQHandler 578 | Insert_ExceptionHandlerVeneer USIC0_2_IRQHandler 579 | Insert_ExceptionHandlerVeneer USIC0_3_IRQHandler 580 | Insert_ExceptionHandlerVeneer USIC0_4_IRQHandler 581 | Insert_ExceptionHandlerVeneer USIC0_5_IRQHandler 582 | Insert_ExceptionHandlerVeneer USIC1_0_IRQHandler 583 | Insert_ExceptionHandlerVeneer USIC1_1_IRQHandler 584 | Insert_ExceptionHandlerVeneer USIC1_2_IRQHandler 585 | Insert_ExceptionHandlerVeneer USIC1_3_IRQHandler 586 | Insert_ExceptionHandlerVeneer USIC1_4_IRQHandler 587 | Insert_ExceptionHandlerVeneer USIC1_5_IRQHandler 588 | Insert_ExceptionHandlerVeneer LEDTS0_0_IRQHandler 589 | Insert_ExceptionHandlerVeneer FCE0_0_IRQHandler 590 | Insert_ExceptionHandlerVeneer GPDMA0_0_IRQHandler 591 | Insert_ExceptionHandlerVeneer USB0_0_IRQHandler 592 | Insert_ExceptionHandlerVeneer ETH0_0_IRQHandler 593 | ENDIF 594 | 595 | ALIGN 596 | 597 | ; User Initial Stack & Heap 598 | 599 | IF :DEF:__MICROLIB 600 | 601 | EXPORT __initial_sp 602 | EXPORT __heap_base 603 | EXPORT __heap_limit 604 | 605 | ELSE 606 | 607 | IMPORT __use_two_region_memory 608 | EXPORT __user_initial_stackheap 609 | __user_initial_stackheap 610 | 611 | LDR R0, = Heap_Mem 612 | LDR R1, =(Stack_Mem + Stack_Size) 613 | LDR R2, = (Heap_Mem + Heap_Size) 614 | LDR R3, = Stack_Mem 615 | BX LR 616 | 617 | ALIGN 618 | 619 | ENDIF 620 | 621 | 622 | END 623 | -------------------------------------------------------------------------------- /RTE/Device/XMC4400-F100x512/system_XMC4400.c: -------------------------------------------------------------------------------- 1 | /********************************************************************************************************************* 2 | * @file system_XMC4400.c 3 | * @brief CMSIS Cortex-M4 Device Peripheral Access Layer Header File for the Infineon XMC4400 Device Series 4 | * @version V3.1.3 5 | * @date 26. Sep 2017 6 | * 7 | * @cond 8 | ********************************************************************************************************************* 9 | * Copyright (c) 2014-2017, Infineon Technologies AG 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the 13 | * following conditions are met: 14 | * 15 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following 16 | * disclaimer. 17 | * 18 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 19 | * disclaimer in the documentation and/or other materials provided with the distribution. 20 | * 21 | * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote 22 | * products derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 25 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with 33 | * Infineon Technologies AG dave@infineon.com). 34 | ********************************************************************************************************************* 35 | * 36 | ********************** Version History *************************************** 37 | * V3.1.0, Dec 2014, Added options to configure clock settings 38 | * V3.1.1, 01. Jun 2016, Fix masking of OSCHPCTRL value 39 | * V3.1.2, 19. Jun 2017, Rely on cmsis_compiler.h instead of defining __WEAK 40 | * Added support for ARM Compiler 6 (armclang) 41 | * V3.1.3, 26. Sep 2017, Disable FPU if FPU_USED is zero 42 | ****************************************************************************** 43 | * @endcond 44 | */ 45 | 46 | /******************************************************************************* 47 | * HEADER FILES 48 | *******************************************************************************/ 49 | #include 50 | 51 | #include 52 | #include "system_XMC4400.h" 53 | 54 | /******************************************************************************* 55 | * MACROS 56 | *******************************************************************************/ 57 | #define CHIPID_LOC ((uint8_t *)0x20000000UL) 58 | #define HRPWM_CHARDATA_LOC ((uint8_t *)0x20000084UL) 59 | 60 | #define PMU_FLASH_WS (0x3U) 61 | 62 | #define FPLL_FREQUENCY (120000000U) 63 | #define FOSCREF (2500000U) 64 | #define DELAY_CNT_50US_50MHZ (2500UL) 65 | #define DELAY_CNT_150US_50MHZ (7500UL) 66 | #define DELAY_CNT_50US_60MHZ (3000UL) 67 | #define DELAY_CNT_50US_90MHZ (4500UL) 68 | #define DELAY_CNT_50US_120MHZ (6000UL) 69 | 70 | #define SCU_PLL_PLLSTAT_OSC_USABLE (SCU_PLL_PLLSTAT_PLLHV_Msk | \ 71 | SCU_PLL_PLLSTAT_PLLLV_Msk | \ 72 | SCU_PLL_PLLSTAT_PLLSP_Msk) 73 | 74 | /* 75 | //-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ 76 | */ 77 | 78 | /* 79 | // Clock configuration 80 | */ 81 | 82 | /* 83 | // External crystal frequency [Hz] 84 | // <8000000=> 8MHz 85 | // <12000000=> 12MHz 86 | // <16000000=> 16MHz 87 | // Defines external crystal frequency 88 | // Default: 8MHz 89 | */ 90 | #define OSCHP_FREQUENCY (12000000U) 91 | 92 | #if OSCHP_FREQUENCY == 8000000U 93 | #define USB_PDIV (1U) 94 | #define USB_NDIV (95U) 95 | #define USB_DIV (3U) 96 | 97 | #elif OSCHP_FREQUENCY == 12000000U 98 | #define USB_PDIV (1U) 99 | #define USB_NDIV (63U) 100 | #define USB_DIV (3U) 101 | 102 | #elif OSCHP_FREQUENCY == 16000000U 103 | #define USB_PDIV (1U) 104 | #define USB_NDIV (47U) 105 | #define USB_DIV (3U) 106 | 107 | #else 108 | #error "External crystal frequency not supported" 109 | 110 | #endif 111 | 112 | /* 113 | // System clock (fSYS) source selection 114 | // <0=> Backup clock (24MHz) 115 | // <1=> Maximum clock frequency using PLL (120MHz) 116 | // Default: Maximum clock frequency using PLL (120MHz) 117 | */ 118 | #define SYS_CLOCK_SRC 1 119 | #define SYS_CLOCK_SRC_OFI 0 120 | #define SYS_CLOCK_SRC_PLL 1 121 | 122 | /* 123 | // Backup clock calibration mode 124 | // <0=> Factory calibration 125 | // <1=> Automatic calibration 126 | // Default: Automatic calibration 127 | */ 128 | #define FOFI_CALIBRATION_MODE 1 129 | #define FOFI_CALIBRATION_MODE_FACTORY 0 130 | #define FOFI_CALIBRATION_MODE_AUTOMATIC 1 131 | 132 | /* 133 | // Standby clock (fSTDBY) source selection 134 | // <0=> Internal slow oscillator (32768Hz) 135 | // <1=> External crystal (32768Hz) 136 | // Default: Internal slow oscillator (32768Hz) 137 | */ 138 | #define STDBY_CLOCK_SRC 0 139 | #define STDBY_CLOCK_SRC_OSI 0 140 | #define STDBY_CLOCK_SRC_OSCULP 1 141 | 142 | /* 143 | // PLL clock source selection 144 | // <0=> External crystal 145 | // <1=> External direct input 146 | // <2=> Internal fast oscillator 147 | // Default: External crystal 148 | */ 149 | #define PLL_CLOCK_SRC 0 150 | #define PLL_CLOCK_SRC_EXT_XTAL 0 151 | #define PLL_CLOCK_SRC_EXT_DIRECT 1 152 | #define PLL_CLOCK_SRC_OFI 2 153 | 154 | #if PLL_CLOCK_SRC == PLL_CLOCK_SRC_EXT_XTAL 155 | #if OSCHP_FREQUENCY == 8000000U 156 | #define PLL_PDIV (1U) 157 | #define PLL_NDIV (89U) 158 | #define PLL_K2DIV (2U) 159 | 160 | #elif OSCHP_FREQUENCY == 12000000U 161 | #define PLL_PDIV (1U) 162 | #define PLL_NDIV (79U) 163 | #define PLL_K2DIV (3U) 164 | 165 | #elif OSCHP_FREQUENCY == 16000000U 166 | #define PLL_PDIV (1U) 167 | #define PLL_NDIV (59U) 168 | #define PLL_K2DIV (3U) 169 | 170 | #else 171 | #error "External crystal frequency not supported" 172 | 173 | #endif 174 | 175 | #define VCO ((OSCHP_FREQUENCY / (PLL_PDIV + 1UL)) * (PLL_NDIV + 1UL)) 176 | 177 | #else /* PLL_CLOCK_SRC == PLL_CLOCK_SRC_EXT_XTAL */ 178 | 179 | #define PLL_PDIV (1U) 180 | #define PLL_NDIV (39U) 181 | #define PLL_K2DIV (3U) 182 | 183 | #define VCO ((OFI_FREQUENCY / (PLL_PDIV + 1UL)) * (PLL_NDIV + 1UL)) 184 | 185 | #endif /* PLL_CLOCK_SRC == PLL_CLOCK_SRC_OFI */ 186 | 187 | #define PLL_K2DIV_0 ((VCO / OFI_FREQUENCY) - 1UL) 188 | #define PLL_K2DIV_1 ((VCO / 60000000U) - 1UL) 189 | #define PLL_K2DIV_2 ((VCO / 90000000U) - 1UL) 190 | 191 | #define SCU_CLK_CLKCLR_ENABLE_USBCLK SCU_CLK_CLKCLR_USBCDI_Msk 192 | #define SCU_CLK_CLKCLR_ENABLE_ETHCLK SCU_CLK_CLKCLR_ETH0CDI_Msk 193 | #define SCU_CLK_CLKCLR_ENABLE_CCUCLK SCU_CLK_CLKCLR_CCUCDI_Msk 194 | #define SCU_CLK_CLKCLR_ENABLE_WDTCLK SCU_CLK_CLKCLR_WDTCDI_Msk 195 | 196 | #define SCU_CLK_USBCLKCR_USBSEL_USBPLL (0U << SCU_CLK_USBCLKCR_USBSEL_Pos) 197 | #define SCU_CLK_USBCLKCR_USBSEL_PLL (1U << SCU_CLK_USBCLKCR_USBSEL_Pos) 198 | 199 | #define SCU_CLK_WDTCLKCR_WDTSEL_OFI (0U << SCU_CLK_WDTCLKCR_WDTSEL_Pos) 200 | #define SCU_CLK_WDTCLKCR_WDTSEL_STANDBY (1U << SCU_CLK_WDTCLKCR_WDTSEL_Pos) 201 | #define SCU_CLK_WDTCLKCR_WDTSEL_PLL (2U << SCU_CLK_WDTCLKCR_WDTSEL_Pos) 202 | 203 | #define SCU_CLK_EXTCLKCR_ECKSEL_SYS (0U << SCU_CLK_EXTCLKCR_ECKSEL_Pos) 204 | #define SCU_CLK_EXTCLKCR_ECKSEL_USBPLL (2U << SCU_CLK_EXTCLKCR_ECKSEL_Pos) 205 | #define SCU_CLK_EXTCLKCR_ECKSEL_PLL (3U << SCU_CLK_EXTCLKCR_ECKSEL_Pos) 206 | #define SCU_CLK_EXTCLKCR_ECKSEL_STANDBY (4U << SCU_CLK_EXTCLKCR_ECKSEL_Pos) 207 | 208 | #define EXTCLK_PIN_P0_8 (0) 209 | #define EXTCLK_PIN_P1_15 (1) 210 | 211 | /* 212 | // Clock tree 213 | // CPU clock divider 214 | // <0=> fCPU = fSYS 215 | // <1=> fCPU = fSYS / 2 216 | // Peripheral clock divider 217 | // <0=> fPB = fCPU 218 | // <1=> fPB = fCPU / 2 219 | // Enable CCU clock 220 | // CCU clock divider 221 | // <0=> fCCU = fCPU 222 | // <1=> fCCU = fCPU / 2 223 | // 224 | // Enable WDT clock 225 | // WDT clock divider <1-256><#-1> 226 | // WDT clock source <0=> fOFI 227 | // <1=> fSTDBY 228 | // <2=> fPLL 229 | // 230 | // Enable ETH clock 231 | // 232 | // Enable USB clock 233 | // USB clock source <0=> USBPLL 234 | // <1=> PLL 235 | // 236 | // External Clock configuration 237 | // External clock source selection 238 | // <0=> System clock 239 | // <2=> USB PLL clock 240 | // <3=> PLL clock 241 | // <4=> Standby clock 242 | // External clock divider <1-512><#-1> 243 | // Only valid for USB PLL and PLL clocks 244 | // External Pin Selection 245 | // <0=> P0.8 246 | // <1=> P1.15 247 | // 248 | // 249 | */ 250 | #define ENABLE_SCUCLK (0U) 251 | #define CPUCLKDIV (0U) 252 | #define PBCLKDIV (0U) 253 | #define CCUCLKDIV (0U) 254 | #define WDTCLKDIV (0U | SCU_CLK_WDTCLKCR_WDTSEL_OFI) 255 | #define USBCLKDIV (0U | SCU_CLK_USBCLKCR_USBSEL_USBPLL | USB_DIV) 256 | 257 | #define ENABLE_EXTCLK (0U) 258 | #define EXTCLKDIV (0U | SCU_CLK_EXTCLKCR_ECKSEL_SYS) 259 | #define EXTCLK_PIN (0U) 260 | 261 | #define ENABLE_PLL \ 262 | (SYS_CLOCK_SRC == SYS_CLOCK_SRC_PLL) || \ 263 | (((ENABLE_SCUCLK & SCU_CLK_CLKSET_USBCEN_Msk) != 0) && ((USBCLKDIV & SCU_CLK_USBCLKCR_USBSEL_Msk) == SCU_CLK_USBCLKCR_USBSEL_PLL)) || \ 264 | (((ENABLE_SCUCLK & SCU_CLK_CLKSET_WDTCEN_Msk) != 0) && ((WDTCLKDIV & SCU_CLK_WDTCLKCR_WDTSEL_Msk) == SCU_CLK_WDTCLKCR_WDTSEL_PLL)) 265 | 266 | /* 267 | // 268 | */ 269 | 270 | /* 271 | //-------- <<< end of configuration section >>> ------------------ 272 | */ 273 | 274 | /******************************************************************************* 275 | * GLOBAL VARIABLES 276 | *******************************************************************************/ 277 | #if defined ( __CC_ARM ) 278 | uint32_t SystemCoreClock __attribute__((at(0x2000FFC0))); 279 | uint8_t g_chipid[16] __attribute__((at(0x2000FFC4))); 280 | uint32_t g_hrpwm_char_data[3] __attribute__((at(0x2000FFD4))); 281 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 282 | uint32_t SystemCoreClock __attribute__((section(".ARM.__at_0x2000FFC0"))); 283 | uint8_t g_chipid[16] __attribute__((section(".ARM.__at_0x2000FFC4"))); 284 | uint32_t g_hrpwm_char_data[3] __attribute__((section(".ARM.__at_0x2000FFD4"))); 285 | #elif defined ( __ICCARM__ ) 286 | __no_init uint32_t SystemCoreClock; 287 | __no_init uint8_t g_chipid[16]; 288 | __no_init uint32_t g_hrpwm_char_data[3]; 289 | #elif defined ( __GNUC__ ) 290 | uint32_t SystemCoreClock __attribute__((section(".no_init"))); 291 | uint8_t g_chipid[16] __attribute__((section(".no_init"))); 292 | uint32_t g_hrpwm_char_data[3] __attribute__((section(".no_init"))); 293 | #elif defined ( __TASKING__ ) 294 | uint32_t SystemCoreClock __at( 0x2000FFC0 ); 295 | uint8_t g_chipid[16] __at( 0x2000FFC4 ); 296 | uint32_t g_hrpwm_char_data[3] __at( 0x2000FFD4 ); 297 | #endif 298 | 299 | extern uint32_t __Vectors; 300 | 301 | /******************************************************************************* 302 | * LOCAL FUNCTIONS 303 | *******************************************************************************/ 304 | static void delay(uint32_t cycles) 305 | { 306 | volatile uint32_t i; 307 | 308 | for(i = 0UL; i < cycles ;++i) 309 | { 310 | __NOP(); 311 | } 312 | } 313 | 314 | /******************************************************************************* 315 | * API IMPLEMENTATION 316 | *******************************************************************************/ 317 | 318 | __WEAK void SystemInit(void) 319 | { 320 | memcpy(g_chipid, CHIPID_LOC, 16); 321 | memcpy(g_hrpwm_char_data, HRPWM_CHARDATA_LOC, 12); 322 | 323 | SystemCoreSetup(); 324 | SystemCoreClockSetup(); 325 | } 326 | 327 | __WEAK void SystemCoreSetup(void) 328 | { 329 | uint32_t temp; 330 | 331 | /* relocate vector table */ 332 | __disable_irq(); 333 | SCB->VTOR = (uint32_t)(&__Vectors); 334 | __DSB(); 335 | __enable_irq(); 336 | 337 | /* __FPU_PRESENT = 1 defined in device header file */ 338 | /* __FPU_USED value depends on compiler/linker options. */ 339 | /* __FPU_USED = 0 if -mfloat-abi=soft is selected */ 340 | /* __FPU_USED = 1 if -mfloat-abi=softfp or –mfloat-abi=hard */ 341 | 342 | #if ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) 343 | SCB->CPACR |= ((3UL << 10*2) | /* set CP10 Full Access */ 344 | (3UL << 11*2) ); /* set CP11 Full Access */ 345 | #else 346 | SCB->CPACR = 0; 347 | #endif 348 | 349 | /* Enable unaligned memory access - SCB_CCR.UNALIGN_TRP = 0 */ 350 | SCB->CCR &= ~(SCB_CCR_UNALIGN_TRP_Msk); 351 | 352 | temp = FLASH0->FCON; 353 | temp &= ~FLASH_FCON_WSPFLASH_Msk; 354 | temp |= PMU_FLASH_WS; 355 | FLASH0->FCON = temp; 356 | } 357 | 358 | __WEAK void SystemCoreClockSetup(void) 359 | { 360 | #if FOFI_CALIBRATION_MODE == FOFI_CALIBRATION_MODE_FACTORY 361 | /* Enable factory calibration */ 362 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_FOTR_Msk; 363 | #else 364 | /* Automatic calibration uses the fSTDBY */ 365 | 366 | /* Enable HIB domain */ 367 | /* Power up HIB domain if and only if it is currently powered down */ 368 | if((SCU_POWER->PWRSTAT & SCU_POWER_PWRSTAT_HIBEN_Msk) == 0) 369 | { 370 | SCU_POWER->PWRSET |= SCU_POWER_PWRSET_HIB_Msk; 371 | 372 | while((SCU_POWER->PWRSTAT & SCU_POWER_PWRSTAT_HIBEN_Msk) == 0) 373 | { 374 | /* wait until HIB domain is enabled */ 375 | } 376 | } 377 | 378 | /* Remove the reset only if HIB domain were in a state of reset */ 379 | if((SCU_RESET->RSTSTAT) & SCU_RESET_RSTSTAT_HIBRS_Msk) 380 | { 381 | SCU_RESET->RSTCLR |= SCU_RESET_RSTCLR_HIBRS_Msk; 382 | delay(DELAY_CNT_150US_50MHZ); 383 | } 384 | 385 | #if STDBY_CLOCK_SRC == STDBY_CLOCK_SRC_OSCULP 386 | /* Enable OSC_ULP */ 387 | if ((SCU_HIBERNATE->OSCULCTRL & SCU_HIBERNATE_OSCULCTRL_MODE_Msk) != 0UL) 388 | { 389 | /*enable OSC_ULP*/ 390 | while (SCU_GENERAL->MIRRSTS & SCU_GENERAL_MIRRSTS_OSCULCTRL_Msk) 391 | { 392 | /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */ 393 | } 394 | SCU_HIBERNATE->OSCULCTRL &= ~SCU_HIBERNATE_OSCULCTRL_MODE_Msk; 395 | 396 | /* Check if the clock is OK using OSCULP Oscillator Watchdog*/ 397 | while (SCU_GENERAL->MIRRSTS & SCU_GENERAL_MIRRSTS_HDCR_Msk) 398 | { 399 | /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */ 400 | } 401 | SCU_HIBERNATE->HDCR |= SCU_HIBERNATE_HDCR_ULPWDGEN_Msk; 402 | 403 | /* wait till clock is stable */ 404 | do 405 | { 406 | while (SCU_GENERAL->MIRRSTS & SCU_GENERAL_MIRRSTS_HDCLR_Msk) 407 | { 408 | /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */ 409 | } 410 | SCU_HIBERNATE->HDCLR |= SCU_HIBERNATE_HDCLR_ULPWDG_Msk; 411 | 412 | delay(DELAY_CNT_50US_50MHZ); 413 | 414 | } while ((SCU_HIBERNATE->HDSTAT & SCU_HIBERNATE_HDSTAT_ULPWDG_Msk) != 0UL); 415 | 416 | } 417 | 418 | /* now OSC_ULP is running and can be used*/ 419 | /* Select OSC_ULP as the clock source for RTC and STDBY*/ 420 | while (SCU_GENERAL->MIRRSTS & SCU_GENERAL_MIRRSTS_HDCR_Msk) 421 | { 422 | /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */ 423 | } 424 | SCU_HIBERNATE->HDCR |= SCU_HIBERNATE_HDCR_RCS_Msk | SCU_HIBERNATE_HDCR_STDBYSEL_Msk; 425 | 426 | #endif /* STDBY_CLOCK_SRC == STDBY_CLOCK_SRC_OSCULP */ 427 | 428 | /* Enable automatic calibration of internal fast oscillator */ 429 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_AOTREN_Msk; 430 | #endif /* FOFI_CALIBRATION_MODE == FOFI_CALIBRATION_MODE_AUTOMATIC */ 431 | 432 | delay(DELAY_CNT_50US_50MHZ); 433 | 434 | #if ENABLE_PLL 435 | 436 | /* enable PLL */ 437 | SCU_PLL->PLLCON0 &= ~(SCU_PLL_PLLCON0_VCOPWD_Msk | SCU_PLL_PLLCON0_PLLPWD_Msk); 438 | 439 | #if PLL_CLOCK_SRC != PLL_CLOCK_SRC_OFI 440 | /* enable OSC_HP */ 441 | if ((SCU_OSC->OSCHPCTRL & SCU_OSC_OSCHPCTRL_MODE_Msk) != 0U) 442 | { 443 | SCU_OSC->OSCHPCTRL &= ~(SCU_OSC_OSCHPCTRL_MODE_Msk | SCU_OSC_OSCHPCTRL_OSCVAL_Msk); 444 | SCU_OSC->OSCHPCTRL |= ((OSCHP_GetFrequency() / FOSCREF) - 1UL) << SCU_OSC_OSCHPCTRL_OSCVAL_Pos; 445 | 446 | /* select OSC_HP clock as PLL input */ 447 | SCU_PLL->PLLCON2 &= ~SCU_PLL_PLLCON2_PINSEL_Msk; 448 | 449 | /* restart OSC Watchdog */ 450 | SCU_PLL->PLLCON0 &= ~SCU_PLL_PLLCON0_OSCRES_Msk; 451 | 452 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_OSC_USABLE) != SCU_PLL_PLLSTAT_OSC_USABLE) 453 | { 454 | /* wait till OSC_HP output frequency is usable */ 455 | } 456 | } 457 | #else /* PLL_CLOCK_SRC != PLL_CLOCK_SRC_OFI */ 458 | 459 | /* select backup clock as PLL input */ 460 | SCU_PLL->PLLCON2 |= SCU_PLL_PLLCON2_PINSEL_Msk; 461 | #endif 462 | 463 | /* Go to bypass the Main PLL */ 464 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_VCOBYP_Msk; 465 | 466 | /* disconnect Oscillator from PLL */ 467 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_FINDIS_Msk; 468 | 469 | /* Setup divider settings for main PLL */ 470 | SCU_PLL->PLLCON1 = ((PLL_NDIV << SCU_PLL_PLLCON1_NDIV_Pos) | 471 | (PLL_K2DIV_0 << SCU_PLL_PLLCON1_K2DIV_Pos) | 472 | (PLL_PDIV << SCU_PLL_PLLCON1_PDIV_Pos)); 473 | 474 | /* Set OSCDISCDIS */ 475 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_OSCDISCDIS_Msk; 476 | 477 | /* connect Oscillator to PLL */ 478 | SCU_PLL->PLLCON0 &= ~SCU_PLL_PLLCON0_FINDIS_Msk; 479 | 480 | /* restart PLL Lock detection */ 481 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_RESLD_Msk; 482 | 483 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOLOCK_Msk) == 0U) 484 | { 485 | /* wait for PLL Lock */ 486 | } 487 | 488 | /* Disable bypass- put PLL clock back */ 489 | SCU_PLL->PLLCON0 &= ~SCU_PLL_PLLCON0_VCOBYP_Msk; 490 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOBYST_Msk) != 0U) 491 | { 492 | /* wait for normal mode */ 493 | } 494 | #endif /* ENABLE_PLL */ 495 | 496 | #if (SYS_CLOCK_SRC == SYS_CLOCK_SRC_PLL) 497 | /* Switch system clock to PLL */ 498 | SCU_CLK->SYSCLKCR |= SCU_CLK_SYSCLKCR_SYSSEL_Msk; 499 | #else 500 | /* Switch system clock to backup clock */ 501 | SCU_CLK->SYSCLKCR &= ~SCU_CLK_SYSCLKCR_SYSSEL_Msk; 502 | #endif 503 | 504 | /* Before scaling to final frequency we need to setup the clock dividers */ 505 | SCU_CLK->PBCLKCR = PBCLKDIV; 506 | SCU_CLK->CPUCLKCR = CPUCLKDIV; 507 | SCU_CLK->CCUCLKCR = CCUCLKDIV; 508 | SCU_CLK->WDTCLKCR = WDTCLKDIV; 509 | SCU_CLK->USBCLKCR = USBCLKDIV; 510 | 511 | #if ENABLE_PLL 512 | /* PLL frequency stepping...*/ 513 | /* Reset OSCDISCDIS */ 514 | SCU_PLL->PLLCON0 &= ~SCU_PLL_PLLCON0_OSCDISCDIS_Msk; 515 | 516 | SCU_PLL->PLLCON1 = ((PLL_NDIV << SCU_PLL_PLLCON1_NDIV_Pos) | 517 | (PLL_K2DIV_1 << SCU_PLL_PLLCON1_K2DIV_Pos) | 518 | (PLL_PDIV << SCU_PLL_PLLCON1_PDIV_Pos)); 519 | 520 | 521 | delay(DELAY_CNT_50US_60MHZ); 522 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOLOCK_Msk) == 0U) 523 | { 524 | /* wait for PLL Lock */ 525 | } 526 | 527 | SCU_PLL->PLLCON1 = ((PLL_NDIV << SCU_PLL_PLLCON1_NDIV_Pos) | 528 | (PLL_K2DIV_2 << SCU_PLL_PLLCON1_K2DIV_Pos) | 529 | (PLL_PDIV << SCU_PLL_PLLCON1_PDIV_Pos)); 530 | 531 | 532 | delay(DELAY_CNT_50US_90MHZ); 533 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOLOCK_Msk) == 0U) 534 | { 535 | /* wait for PLL Lock */ 536 | } 537 | 538 | SCU_PLL->PLLCON1 = ((PLL_NDIV << SCU_PLL_PLLCON1_NDIV_Pos) | 539 | (PLL_K2DIV << SCU_PLL_PLLCON1_K2DIV_Pos) | 540 | (PLL_PDIV << SCU_PLL_PLLCON1_PDIV_Pos)); 541 | 542 | 543 | delay(DELAY_CNT_50US_120MHZ); 544 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOLOCK_Msk) == 0U) 545 | { 546 | /* wait for PLL Lock */ 547 | } 548 | 549 | SCU_TRAP->TRAPCLR = SCU_TRAP_TRAPCLR_SOSCWDGT_Msk | SCU_TRAP_TRAPCLR_SVCOLCKT_Msk; 550 | #endif /* ENABLE_PLL */ 551 | 552 | #if (((ENABLE_SCUCLK & SCU_CLK_CLKSET_USBCEN_Msk) != 0) && ((USBCLKDIV & SCU_CLK_USBCLKCR_USBSEL_Msk) == SCU_CLK_USBCLKCR_USBSEL_USBPLL)) 553 | /* enable USB PLL first */ 554 | SCU_PLL->USBPLLCON &= ~(SCU_PLL_USBPLLCON_VCOPWD_Msk | SCU_PLL_USBPLLCON_PLLPWD_Msk); 555 | 556 | /* USB PLL uses as clock input the OSC_HP */ 557 | /* check and if not already running enable OSC_HP */ 558 | if ((SCU_OSC->OSCHPCTRL & SCU_OSC_OSCHPCTRL_MODE_Msk) != 0U) 559 | { 560 | /* check if Main PLL is switched on for OSC WDG*/ 561 | if ((SCU_PLL->PLLCON0 &(SCU_PLL_PLLCON0_VCOPWD_Msk | SCU_PLL_PLLCON0_PLLPWD_Msk)) != 0UL) 562 | { 563 | /* enable PLL first */ 564 | SCU_PLL->PLLCON0 &= ~(SCU_PLL_PLLCON0_VCOPWD_Msk | SCU_PLL_PLLCON0_PLLPWD_Msk); 565 | } 566 | 567 | SCU_OSC->OSCHPCTRL &= ~(SCU_OSC_OSCHPCTRL_MODE_Msk | SCU_OSC_OSCHPCTRL_OSCVAL_Msk); 568 | SCU_OSC->OSCHPCTRL |= ((OSCHP_GetFrequency() / FOSCREF) - 1UL) << SCU_OSC_OSCHPCTRL_OSCVAL_Pos; 569 | 570 | /* restart OSC Watchdog */ 571 | SCU_PLL->PLLCON0 &= ~SCU_PLL_PLLCON0_OSCRES_Msk; 572 | 573 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_OSC_USABLE) != SCU_PLL_PLLSTAT_OSC_USABLE) 574 | { 575 | /* wait till OSC_HP output frequency is usable */ 576 | } 577 | } 578 | 579 | /* Setup USB PLL */ 580 | /* Go to bypass the USB PLL */ 581 | SCU_PLL->USBPLLCON |= SCU_PLL_USBPLLCON_VCOBYP_Msk; 582 | 583 | /* disconnect Oscillator from USB PLL */ 584 | SCU_PLL->USBPLLCON |= SCU_PLL_USBPLLCON_FINDIS_Msk; 585 | 586 | /* Setup Divider settings for USB PLL */ 587 | SCU_PLL->USBPLLCON = ((USB_NDIV << SCU_PLL_USBPLLCON_NDIV_Pos) | 588 | (USB_PDIV << SCU_PLL_USBPLLCON_PDIV_Pos)); 589 | 590 | /* Set OSCDISCDIS */ 591 | SCU_PLL->USBPLLCON |= SCU_PLL_USBPLLCON_OSCDISCDIS_Msk; 592 | 593 | /* connect Oscillator to USB PLL */ 594 | SCU_PLL->USBPLLCON &= ~SCU_PLL_USBPLLCON_FINDIS_Msk; 595 | 596 | /* restart PLL Lock detection */ 597 | SCU_PLL->USBPLLCON |= SCU_PLL_USBPLLCON_RESLD_Msk; 598 | 599 | while ((SCU_PLL->USBPLLSTAT & SCU_PLL_USBPLLSTAT_VCOLOCK_Msk) == 0U) 600 | { 601 | /* wait for PLL Lock */ 602 | } 603 | #endif /* (USBCLKDIV & SCU_CLK_USBCLKCR_USBSEL_Msk) */ 604 | 605 | /* Enable selected clocks */ 606 | SCU_CLK->CLKSET = ENABLE_SCUCLK; 607 | 608 | #if ENABLE_EXTCLK == 1 609 | /* Configure external clock */ 610 | SCU_CLK->EXTCLKCR = EXTCLKDIV; 611 | 612 | #if EXTCLK_PIN == EXTCLK_PIN_P1_15 613 | /* P1.15 */ 614 | PORT1->PDR1 &= ~PORT1_PDR1_PD15_Msk; 615 | PORT1->IOCR12 = (PORT1->IOCR12 & ~PORT0_IOCR12_PC15_Msk) | (0x11U << PORT0_IOCR12_PC15_Pos); 616 | #else 617 | /* P0.8 */ 618 | PORT0->HWSEL &= ~PORT0_HWSEL_HW8_Msk; 619 | PORT0->PDR1 &= ~PORT0_PDR1_PD8_Msk; 620 | PORT0->IOCR8 = (PORT0->IOCR8 & ~PORT0_IOCR8_PC8_Msk) | (0x11U << PORT0_IOCR8_PC8_Pos); 621 | #endif 622 | 623 | #endif /* ENABLE_EXTCLK == 1 */ 624 | 625 | SystemCoreClockUpdate(); 626 | } 627 | 628 | __WEAK void SystemCoreClockUpdate(void) 629 | { 630 | uint32_t pdiv; 631 | uint32_t ndiv; 632 | uint32_t kdiv; 633 | uint32_t temp; 634 | 635 | if (SCU_CLK->SYSCLKCR & SCU_CLK_SYSCLKCR_SYSSEL_Msk) 636 | { 637 | /* fPLL is clock source for fSYS */ 638 | if(SCU_PLL->PLLCON2 & SCU_PLL_PLLCON2_PINSEL_Msk) 639 | { 640 | /* PLL input clock is the backup clock (fOFI) */ 641 | temp = OFI_FREQUENCY; 642 | } 643 | else 644 | { 645 | /* PLL input clock is the high performance osicllator (fOSCHP) */ 646 | temp = OSCHP_GetFrequency(); 647 | } 648 | 649 | /* check if PLL is locked */ 650 | if (SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOLOCK_Msk) 651 | { 652 | /* PLL normal mode */ 653 | /* read back divider settings */ 654 | pdiv = ((SCU_PLL->PLLCON1 & SCU_PLL_PLLCON1_PDIV_Msk) >> SCU_PLL_PLLCON1_PDIV_Pos) + 1; 655 | ndiv = ((SCU_PLL->PLLCON1 & SCU_PLL_PLLCON1_NDIV_Msk) >> SCU_PLL_PLLCON1_NDIV_Pos) + 1; 656 | kdiv = ((SCU_PLL->PLLCON1 & SCU_PLL_PLLCON1_K2DIV_Msk) >> SCU_PLL_PLLCON1_K2DIV_Pos) + 1; 657 | 658 | temp = (temp / (pdiv * kdiv)) * ndiv; 659 | } 660 | else 661 | { 662 | /* PLL prescalar mode */ 663 | /* read back divider settings */ 664 | kdiv = ((SCU_PLL->PLLCON1 & SCU_PLL_PLLCON1_K1DIV_Msk) >> SCU_PLL_PLLCON1_K1DIV_Pos) + 1; 665 | 666 | temp = (temp / kdiv); 667 | } 668 | } 669 | else 670 | { 671 | /* fOFI is clock source for fSYS */ 672 | temp = OFI_FREQUENCY; 673 | } 674 | 675 | temp = temp / ((SCU_CLK->SYSCLKCR & SCU_CLK_SYSCLKCR_SYSDIV_Msk) + 1); 676 | temp = temp / ((SCU_CLK->CPUCLKCR & SCU_CLK_CPUCLKCR_CPUDIV_Msk) + 1); 677 | 678 | SystemCoreClock = temp; 679 | } 680 | 681 | __WEAK uint32_t OSCHP_GetFrequency(void) 682 | { 683 | return OSCHP_FREQUENCY; 684 | } 685 | -------------------------------------------------------------------------------- /RTE/Device/XMC4400-F64x512/startup_XMC4400.s: -------------------------------------------------------------------------------- 1 | ;******************************************************************************* 2 | ;* @file startup_XMC4400.s 3 | ;* @brief CMSIS Core Device Startup File for 4 | ;* Infineon XMC4400 Device Series 5 | ;* @version V1.5 6 | ;* @date June 2016 7 | ;* 8 | ;* @cond 9 | ;********************************************************************************************************************* 10 | ;* Copyright (c) 2012-2016, Infineon Technologies AG 11 | ;* All rights reserved. 12 | ;* 13 | ;* Redistribution and use in source and binary forms, with or without modification,are permitted provided that the 14 | ;* following conditions are met: 15 | ;* 16 | ;* Redistributions of source code must retain the above copyright notice, this list of conditions and the following 17 | ;* disclaimer. 18 | ;* 19 | ;* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 20 | ;* disclaimer in the documentation and/or other materials provided with the distribution. 21 | ;* 22 | ;* Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote 23 | ;* products derived from this software without specific prior written permission. 24 | ;* 25 | ;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 26 | ;* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | ;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | ;* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | ;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 | ;* WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | ;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | ;* 33 | ;* To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with 34 | ;* Infineon Technologies AG dave@infineon.com). 35 | ;********************************************************************************************************************* 36 | ;* 37 | ;************************** Version History ************************************ 38 | ; V0.2, August 2012, First version 39 | ; V1.0, February 2013, FIX for CPU prefetch bug implemented 40 | ; V1.1, August 2013, Fix the bug of stack pointer alignment to a 8 byte boundary 41 | ; V1.2, November 2014, Disable CPU workaround. Increased stack size. 42 | ; Removed DAVE3 dependency 43 | ; V1.3, November 2015, Remove peripherals not included in device. 44 | ; V1.4, March 2016, Fix weak definition of Veneers. 45 | ; Only relevant for AA, which needs ENABLE_PMU_CM_001_WORKAROUND 46 | ; V1.5, June 2016, Rename ENABLE_CPU_CM_001_WORKAROUND to ENABLE_PMU_CM_001_WORKAROUND 47 | ; Action required: If using AA step, use ENABLE_PMU_CM_001_WORKAROUND instead of ENABLE_CPU_CM_001_WORKAROUND 48 | ;******************************************************************************* 49 | ;* @endcond 50 | 51 | ; ------------------ <<< Use Configuration Wizard in Context Menu >>> ------------------ 52 | 53 | ; Stack Configuration 54 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> 55 | ; 56 | 57 | Stack_Size EQU 0x00000800 58 | 59 | AREA STACK, NOINIT, READWRITE, ALIGN=3 60 | Stack_Mem SPACE Stack_Size 61 | __initial_sp 62 | 63 | 64 | ; Heap Configuration 65 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> 66 | ; 67 | 68 | Heap_Size EQU 0x00000200 69 | 70 | AREA HEAP, NOINIT, READWRITE, ALIGN=3 71 | __heap_base 72 | Heap_Mem SPACE Heap_Size 73 | __heap_limit 74 | 75 | PRESERVE8 76 | THUMB 77 | 78 | IF :DEF:ENABLE_PMU_CM_001_WORKAROUND 79 | MACRO 80 | Entry $Handler 81 | DCD $Handler._Veneer 82 | MEND 83 | ELSE 84 | MACRO 85 | Entry $Handler 86 | DCD $Handler 87 | MEND 88 | ENDIF 89 | 90 | ; Vector Table Mapped to Address 0 at Reset 91 | 92 | AREA RESET, DATA, READONLY 93 | EXPORT __Vectors 94 | EXPORT __Vectors_End 95 | EXPORT __Vectors_Size 96 | 97 | __Vectors DCD __initial_sp ; 0 Top of Stack 98 | DCD Reset_Handler ; 1 Reset Handler 99 | Entry NMI_Handler ; 2 NMI Handler 100 | Entry HardFault_Handler ; 3 Hard Fault Handler 101 | Entry MemManage_Handler ; 4 MPU Fault Handler 102 | Entry BusFault_Handler ; 5 Bus Fault Handler 103 | Entry UsageFault_Handler ; 6 Usage Fault Handler 104 | DCD 0 ; 7 Reserved 105 | DCD 0 ; 8 Reserved 106 | DCD 0 ; 9 Reserved 107 | DCD 0 ; 10 Reserved 108 | Entry SVC_Handler ; 11 SVCall Handler 109 | Entry DebugMon_Handler ; 12 Debug Monitor Handler 110 | DCD 0 ; 13 Reserved 111 | Entry PendSV_Handler ; 14 PendSV Handler 112 | Entry SysTick_Handler ; 15 SysTick Handler 113 | 114 | ; Interrupt Handlers for Service Requests (SR) from XMC4400 Peripherals */ 115 | Entry SCU_0_IRQHandler ; Handler name for SR SCU_0 116 | Entry ERU0_0_IRQHandler ; Handler name for SR ERU0_0 117 | Entry ERU0_1_IRQHandler ; Handler name for SR ERU0_1 118 | Entry ERU0_2_IRQHandler ; Handler name for SR ERU0_2 119 | Entry ERU0_3_IRQHandler ; Handler name for SR ERU0_3 120 | Entry ERU1_0_IRQHandler ; Handler name for SR ERU1_0 121 | Entry ERU1_1_IRQHandler ; Handler name for SR ERU1_1 122 | Entry ERU1_2_IRQHandler ; Handler name for SR ERU1_2 123 | Entry ERU1_3_IRQHandler ; Handler name for SR ERU1_3 124 | DCD 0 ; Not Available 125 | DCD 0 ; Not Available 126 | DCD 0 ; Not Available 127 | Entry PMU0_0_IRQHandler ; Handler name for SR PMU0_0 128 | DCD 0 ; Not Available 129 | Entry VADC0_C0_0_IRQHandler ; Handler name for SR VADC0_C0_0 130 | Entry VADC0_C0_1_IRQHandler ; Handler name for SR VADC0_C0_1 131 | Entry VADC0_C0_2_IRQHandler ; Handler name for SR VADC0_C0_1 132 | Entry VADC0_C0_3_IRQHandler ; Handler name for SR VADC0_C0_3 133 | Entry VADC0_G0_0_IRQHandler ; Handler name for SR VADC0_G0_0 134 | Entry VADC0_G0_1_IRQHandler ; Handler name for SR VADC0_G0_1 135 | Entry VADC0_G0_2_IRQHandler ; Handler name for SR VADC0_G0_2 136 | Entry VADC0_G0_3_IRQHandler ; Handler name for SR VADC0_G0_3 137 | Entry VADC0_G1_0_IRQHandler ; Handler name for SR VADC0_G1_0 138 | Entry VADC0_G1_1_IRQHandler ; Handler name for SR VADC0_G1_1 139 | Entry VADC0_G1_2_IRQHandler ; Handler name for SR VADC0_G1_2 140 | Entry VADC0_G1_3_IRQHandler ; Handler name for SR VADC0_G1_3 141 | Entry VADC0_G2_0_IRQHandler ; Handler name for SR VADC0_G2_0 142 | Entry VADC0_G2_1_IRQHandler ; Handler name for SR VADC0_G2_1 143 | Entry VADC0_G2_2_IRQHandler ; Handler name for SR VADC0_G2_2 144 | Entry VADC0_G2_3_IRQHandler ; Handler name for SR VADC0_G2_3 145 | Entry VADC0_G3_0_IRQHandler ; Handler name for SR VADC0_G3_0 146 | Entry VADC0_G3_1_IRQHandler ; Handler name for SR VADC0_G3_1 147 | Entry VADC0_G3_2_IRQHandler ; Handler name for SR VADC0_G3_2 148 | Entry VADC0_G3_3_IRQHandler ; Handler name for SR VADC0_G3_3 149 | Entry DSD0_0_IRQHandler ; Handler name for SR DSD_SRM_0 150 | Entry DSD0_1_IRQHandler ; Handler name for SR DSD_SRM_1 151 | Entry DSD0_2_IRQHandler ; Handler name for SR DSD_SRM_2 152 | Entry DSD0_3_IRQHandler ; Handler name for SR DSD_SRM_3 153 | Entry DSD0_4_IRQHandler ; Handler name for SR DSD_SRA_0 154 | Entry DSD0_5_IRQHandler ; Handler name for SR DSD_SRA_1 155 | Entry DSD0_6_IRQHandler ; Handler name for SR DSD_SRA_2 156 | Entry DSD0_7_IRQHandler ; Handler name for SR DSD_SRA_3 157 | Entry DAC0_0_IRQHandler ; Handler name for SR DAC0_0 158 | Entry DAC0_1_IRQHandler ; Handler name for SR DAC0_1 159 | Entry CCU40_0_IRQHandler ; Handler name for SR CCU40_0 160 | Entry CCU40_1_IRQHandler ; Handler name for SR CCU40_1 161 | Entry CCU40_2_IRQHandler ; Handler name for SR CCU40_2 162 | Entry CCU40_3_IRQHandler ; Handler name for SR CCU40_3 163 | Entry CCU41_0_IRQHandler ; Handler name for SR CCU41_0 164 | Entry CCU41_1_IRQHandler ; Handler name for SR CCU41_1 165 | Entry CCU41_2_IRQHandler ; Handler name for SR CCU41_2 166 | Entry CCU41_3_IRQHandler ; Handler name for SR CCU41_3 167 | Entry CCU42_0_IRQHandler ; Handler name for SR CCU42_0 168 | Entry CCU42_1_IRQHandler ; Handler name for SR CCU42_1 169 | Entry CCU42_2_IRQHandler ; Handler name for SR CCU42_2 170 | Entry CCU42_3_IRQHandler ; Handler name for SR CCU42_3 171 | Entry CCU43_0_IRQHandler ; Handler name for SR CCU43_0 172 | Entry CCU43_1_IRQHandler ; Handler name for SR CCU43_1 173 | Entry CCU43_2_IRQHandler ; Handler name for SR CCU43_2 174 | Entry CCU43_3_IRQHandler ; Handler name for SR CCU43_3 175 | Entry CCU80_0_IRQHandler ; Handler name for SR CCU80_0 176 | Entry CCU80_1_IRQHandler ; Handler name for SR CCU80_1 177 | Entry CCU80_2_IRQHandler ; Handler name for SR CCU80_2 178 | Entry CCU80_3_IRQHandler ; Handler name for SR CCU80_3 179 | Entry CCU81_0_IRQHandler ; Handler name for SR CCU81_0 180 | Entry CCU81_1_IRQHandler ; Handler name for SR CCU81_1 181 | Entry CCU81_2_IRQHandler ; Handler name for SR CCU81_2 182 | Entry CCU81_3_IRQHandler ; Handler name for SR CCU81_3 183 | Entry POSIF0_0_IRQHandler ; Handler name for SR POSIF0_0 184 | Entry POSIF0_1_IRQHandler ; Handler name for SR POSIF0_1 185 | Entry POSIF1_0_IRQHandler ; Handler name for SR POSIF1_0 186 | Entry POSIF1_1_IRQHandler ; Handler name for SR POSIF1_1 187 | Entry HRPWM_0_IRQHandler ; Handler name for SR HRPWM_0 188 | Entry HRPWM_1_IRQHandler ; Handler name for SR HRPWM_1 189 | Entry HRPWM_2_IRQHandler ; Handler name for SR HRPWM_2 190 | Entry HRPWM_3_IRQHandler ; Handler name for SR HRPWM_3 191 | Entry CAN0_0_IRQHandler ; Handler name for SR CAN0_0 192 | Entry CAN0_1_IRQHandler ; Handler name for SR CAN0_1 193 | Entry CAN0_2_IRQHandler ; Handler name for SR CAN0_2 194 | Entry CAN0_3_IRQHandler ; Handler name for SR CAN0_3 195 | Entry CAN0_4_IRQHandler ; Handler name for SR CAN0_4 196 | Entry CAN0_5_IRQHandler ; Handler name for SR CAN0_5 197 | Entry CAN0_6_IRQHandler ; Handler name for SR CAN0_6 198 | Entry CAN0_7_IRQHandler ; Handler name for SR CAN0_7 199 | Entry USIC0_0_IRQHandler ; Handler name for SR USIC0_0 200 | Entry USIC0_1_IRQHandler ; Handler name for SR USIC0_1 201 | Entry USIC0_2_IRQHandler ; Handler name for SR USIC0_2 202 | Entry USIC0_3_IRQHandler ; Handler name for SR USIC0_3 203 | Entry USIC0_4_IRQHandler ; Handler name for SR USIC0_4 204 | Entry USIC0_5_IRQHandler ; Handler name for SR USIC0_5 205 | Entry USIC1_0_IRQHandler ; Handler name for SR USIC1_0 206 | Entry USIC1_1_IRQHandler ; Handler name for SR USIC1_1 207 | Entry USIC1_2_IRQHandler ; Handler name for SR USIC1_2 208 | Entry USIC1_3_IRQHandler ; Handler name for SR USIC1_3 209 | Entry USIC1_4_IRQHandler ; Handler name for SR USIC1_4 210 | Entry USIC1_5_IRQHandler ; Handler name for SR USIC1_5 211 | DCD 0 ; Not Available 212 | DCD 0 ; Not Available 213 | DCD 0 ; Not Available 214 | DCD 0 ; Not Available 215 | DCD 0 ; Not Available 216 | DCD 0 ; Not Available 217 | Entry LEDTS0_0_IRQHandler ; Handler name for SR LEDTS0_0 218 | DCD 0 ; Not Available 219 | Entry FCE0_0_IRQHandler ; Handler name for SR FCE0_0 220 | Entry GPDMA0_0_IRQHandler ; Handler name for SR GPDMA0_0 221 | DCD 0 ; Not Available 222 | Entry USB0_0_IRQHandler ; Handler name for SR USB0_0 223 | Entry ETH0_0_IRQHandler ; Handler name for SR ETH0_0 224 | DCD 0 ; Not Available 225 | DCD 0 ; Not Available 226 | DCD 0 ; Not Available 227 | __Vectors_End 228 | 229 | __Vectors_Size EQU __Vectors_End - __Vectors 230 | 231 | AREA |.text|, CODE, READONLY 232 | 233 | ; Reset Handler 234 | 235 | Reset_Handler PROC 236 | EXPORT Reset_Handler [WEAK] 237 | IMPORT SystemInit 238 | IMPORT __main 239 | LDR SP, =__initial_sp 240 | LDR R0, =SystemInit 241 | BLX R0 242 | LDR R0, =__main 243 | BX R0 244 | ENDP 245 | 246 | ; Dummy Exception Handlers (infinite loops which can be modified) 247 | 248 | Default_Handler PROC 249 | EXPORT NMI_Handler [WEAK] 250 | EXPORT HardFault_Handler [WEAK] 251 | EXPORT MemManage_Handler [WEAK] 252 | EXPORT BusFault_Handler [WEAK] 253 | EXPORT UsageFault_Handler [WEAK] 254 | EXPORT SVC_Handler [WEAK] 255 | EXPORT DebugMon_Handler [WEAK] 256 | EXPORT PendSV_Handler [WEAK] 257 | EXPORT SysTick_Handler [WEAK] 258 | 259 | EXPORT SCU_0_IRQHandler [WEAK] 260 | EXPORT ERU0_0_IRQHandler [WEAK] 261 | EXPORT ERU0_1_IRQHandler [WEAK] 262 | EXPORT ERU0_2_IRQHandler [WEAK] 263 | EXPORT ERU0_3_IRQHandler [WEAK] 264 | EXPORT ERU1_0_IRQHandler [WEAK] 265 | EXPORT ERU1_1_IRQHandler [WEAK] 266 | EXPORT ERU1_2_IRQHandler [WEAK] 267 | EXPORT ERU1_3_IRQHandler [WEAK] 268 | EXPORT PMU0_0_IRQHandler [WEAK] 269 | EXPORT VADC0_C0_0_IRQHandler [WEAK] 270 | EXPORT VADC0_C0_1_IRQHandler [WEAK] 271 | EXPORT VADC0_C0_2_IRQHandler [WEAK] 272 | EXPORT VADC0_C0_3_IRQHandler [WEAK] 273 | EXPORT VADC0_G0_0_IRQHandler [WEAK] 274 | EXPORT VADC0_G0_1_IRQHandler [WEAK] 275 | EXPORT VADC0_G0_2_IRQHandler [WEAK] 276 | EXPORT VADC0_G0_3_IRQHandler [WEAK] 277 | EXPORT VADC0_G1_0_IRQHandler [WEAK] 278 | EXPORT VADC0_G1_1_IRQHandler [WEAK] 279 | EXPORT VADC0_G1_2_IRQHandler [WEAK] 280 | EXPORT VADC0_G1_3_IRQHandler [WEAK] 281 | EXPORT VADC0_G2_0_IRQHandler [WEAK] 282 | EXPORT VADC0_G2_1_IRQHandler [WEAK] 283 | EXPORT VADC0_G2_2_IRQHandler [WEAK] 284 | EXPORT VADC0_G2_3_IRQHandler [WEAK] 285 | EXPORT VADC0_G3_0_IRQHandler [WEAK] 286 | EXPORT VADC0_G3_1_IRQHandler [WEAK] 287 | EXPORT VADC0_G3_2_IRQHandler [WEAK] 288 | EXPORT VADC0_G3_3_IRQHandler [WEAK] 289 | EXPORT DSD0_0_IRQHandler [WEAK] 290 | EXPORT DSD0_1_IRQHandler [WEAK] 291 | EXPORT DSD0_2_IRQHandler [WEAK] 292 | EXPORT DSD0_3_IRQHandler [WEAK] 293 | EXPORT DSD0_4_IRQHandler [WEAK] 294 | EXPORT DSD0_5_IRQHandler [WEAK] 295 | EXPORT DSD0_6_IRQHandler [WEAK] 296 | EXPORT DSD0_7_IRQHandler [WEAK] 297 | EXPORT DAC0_0_IRQHandler [WEAK] 298 | EXPORT DAC0_1_IRQHandler [WEAK] 299 | EXPORT CCU40_0_IRQHandler [WEAK] 300 | EXPORT CCU40_1_IRQHandler [WEAK] 301 | EXPORT CCU40_2_IRQHandler [WEAK] 302 | EXPORT CCU40_3_IRQHandler [WEAK] 303 | EXPORT CCU41_0_IRQHandler [WEAK] 304 | EXPORT CCU41_1_IRQHandler [WEAK] 305 | EXPORT CCU41_2_IRQHandler [WEAK] 306 | EXPORT CCU41_3_IRQHandler [WEAK] 307 | EXPORT CCU42_0_IRQHandler [WEAK] 308 | EXPORT CCU42_1_IRQHandler [WEAK] 309 | EXPORT CCU42_2_IRQHandler [WEAK] 310 | EXPORT CCU42_3_IRQHandler [WEAK] 311 | EXPORT CCU43_0_IRQHandler [WEAK] 312 | EXPORT CCU43_1_IRQHandler [WEAK] 313 | EXPORT CCU43_2_IRQHandler [WEAK] 314 | EXPORT CCU43_3_IRQHandler [WEAK] 315 | EXPORT CCU80_0_IRQHandler [WEAK] 316 | EXPORT CCU80_1_IRQHandler [WEAK] 317 | EXPORT CCU80_2_IRQHandler [WEAK] 318 | EXPORT CCU80_3_IRQHandler [WEAK] 319 | EXPORT CCU81_0_IRQHandler [WEAK] 320 | EXPORT CCU81_1_IRQHandler [WEAK] 321 | EXPORT CCU81_2_IRQHandler [WEAK] 322 | EXPORT CCU81_3_IRQHandler [WEAK] 323 | EXPORT POSIF0_0_IRQHandler [WEAK] 324 | EXPORT POSIF0_1_IRQHandler [WEAK] 325 | EXPORT POSIF1_0_IRQHandler [WEAK] 326 | EXPORT POSIF1_1_IRQHandler [WEAK] 327 | EXPORT HRPWM_0_IRQHandler [WEAK] 328 | EXPORT HRPWM_1_IRQHandler [WEAK] 329 | EXPORT HRPWM_2_IRQHandler [WEAK] 330 | EXPORT HRPWM_3_IRQHandler [WEAK] 331 | EXPORT CAN0_0_IRQHandler [WEAK] 332 | EXPORT CAN0_1_IRQHandler [WEAK] 333 | EXPORT CAN0_2_IRQHandler [WEAK] 334 | EXPORT CAN0_3_IRQHandler [WEAK] 335 | EXPORT CAN0_4_IRQHandler [WEAK] 336 | EXPORT CAN0_5_IRQHandler [WEAK] 337 | EXPORT CAN0_6_IRQHandler [WEAK] 338 | EXPORT CAN0_7_IRQHandler [WEAK] 339 | EXPORT USIC0_0_IRQHandler [WEAK] 340 | EXPORT USIC0_1_IRQHandler [WEAK] 341 | EXPORT USIC0_2_IRQHandler [WEAK] 342 | EXPORT USIC0_3_IRQHandler [WEAK] 343 | EXPORT USIC0_4_IRQHandler [WEAK] 344 | EXPORT USIC0_5_IRQHandler [WEAK] 345 | EXPORT USIC1_0_IRQHandler [WEAK] 346 | EXPORT USIC1_1_IRQHandler [WEAK] 347 | EXPORT USIC1_2_IRQHandler [WEAK] 348 | EXPORT USIC1_3_IRQHandler [WEAK] 349 | EXPORT USIC1_4_IRQHandler [WEAK] 350 | EXPORT USIC1_5_IRQHandler [WEAK] 351 | EXPORT LEDTS0_0_IRQHandler [WEAK] 352 | EXPORT FCE0_0_IRQHandler [WEAK] 353 | EXPORT GPDMA0_0_IRQHandler [WEAK] 354 | EXPORT USB0_0_IRQHandler [WEAK] 355 | EXPORT ETH0_0_IRQHandler [WEAK] 356 | 357 | NMI_Handler 358 | HardFault_Handler 359 | MemManage_Handler 360 | BusFault_Handler 361 | UsageFault_Handler 362 | SVC_Handler 363 | DebugMon_Handler 364 | PendSV_Handler 365 | SysTick_Handler 366 | SCU_0_IRQHandler 367 | ERU0_0_IRQHandler 368 | ERU0_1_IRQHandler 369 | ERU0_2_IRQHandler 370 | ERU0_3_IRQHandler 371 | ERU1_0_IRQHandler 372 | ERU1_1_IRQHandler 373 | ERU1_2_IRQHandler 374 | ERU1_3_IRQHandler 375 | PMU0_0_IRQHandler 376 | VADC0_C0_0_IRQHandler 377 | VADC0_C0_1_IRQHandler 378 | VADC0_C0_2_IRQHandler 379 | VADC0_C0_3_IRQHandler 380 | VADC0_G0_0_IRQHandler 381 | VADC0_G0_1_IRQHandler 382 | VADC0_G0_2_IRQHandler 383 | VADC0_G0_3_IRQHandler 384 | VADC0_G1_0_IRQHandler 385 | VADC0_G1_1_IRQHandler 386 | VADC0_G1_2_IRQHandler 387 | VADC0_G1_3_IRQHandler 388 | VADC0_G2_0_IRQHandler 389 | VADC0_G2_1_IRQHandler 390 | VADC0_G2_2_IRQHandler 391 | VADC0_G2_3_IRQHandler 392 | VADC0_G3_0_IRQHandler 393 | VADC0_G3_1_IRQHandler 394 | VADC0_G3_2_IRQHandler 395 | VADC0_G3_3_IRQHandler 396 | DSD0_0_IRQHandler 397 | DSD0_1_IRQHandler 398 | DSD0_2_IRQHandler 399 | DSD0_3_IRQHandler 400 | DSD0_4_IRQHandler 401 | DSD0_5_IRQHandler 402 | DSD0_6_IRQHandler 403 | DSD0_7_IRQHandler 404 | DAC0_0_IRQHandler 405 | DAC0_1_IRQHandler 406 | CCU40_0_IRQHandler 407 | CCU40_1_IRQHandler 408 | CCU40_2_IRQHandler 409 | CCU40_3_IRQHandler 410 | CCU41_0_IRQHandler 411 | CCU41_1_IRQHandler 412 | CCU41_2_IRQHandler 413 | CCU41_3_IRQHandler 414 | CCU42_0_IRQHandler 415 | CCU42_1_IRQHandler 416 | CCU42_2_IRQHandler 417 | CCU42_3_IRQHandler 418 | CCU43_0_IRQHandler 419 | CCU43_1_IRQHandler 420 | CCU43_2_IRQHandler 421 | CCU43_3_IRQHandler 422 | CCU80_0_IRQHandler 423 | CCU80_1_IRQHandler 424 | CCU80_2_IRQHandler 425 | CCU80_3_IRQHandler 426 | CCU81_0_IRQHandler 427 | CCU81_1_IRQHandler 428 | CCU81_2_IRQHandler 429 | CCU81_3_IRQHandler 430 | POSIF0_0_IRQHandler 431 | POSIF0_1_IRQHandler 432 | POSIF1_0_IRQHandler 433 | POSIF1_1_IRQHandler 434 | HRPWM_0_IRQHandler 435 | HRPWM_1_IRQHandler 436 | HRPWM_2_IRQHandler 437 | HRPWM_3_IRQHandler 438 | CAN0_0_IRQHandler 439 | CAN0_1_IRQHandler 440 | CAN0_2_IRQHandler 441 | CAN0_3_IRQHandler 442 | CAN0_4_IRQHandler 443 | CAN0_5_IRQHandler 444 | CAN0_6_IRQHandler 445 | CAN0_7_IRQHandler 446 | USIC0_0_IRQHandler 447 | USIC0_1_IRQHandler 448 | USIC0_2_IRQHandler 449 | USIC0_3_IRQHandler 450 | USIC0_4_IRQHandler 451 | USIC0_5_IRQHandler 452 | USIC1_0_IRQHandler 453 | USIC1_1_IRQHandler 454 | USIC1_2_IRQHandler 455 | USIC1_3_IRQHandler 456 | USIC1_4_IRQHandler 457 | USIC1_5_IRQHandler 458 | LEDTS0_0_IRQHandler 459 | FCE0_0_IRQHandler 460 | GPDMA0_0_IRQHandler 461 | USB0_0_IRQHandler 462 | ETH0_0_IRQHandler 463 | 464 | B . 465 | 466 | ENDP 467 | 468 | IF :DEF:ENABLE_PMU_CM_001_WORKAROUND 469 | 470 | MACRO 471 | Insert_ExceptionHandlerVeneer $Handler_Func 472 | $Handler_Func._Veneer\ 473 | PROC 474 | EXPORT $Handler_Func._Veneer [WEAK] 475 | LDR R0, =$Handler_Func 476 | PUSH {LR} ;/* Breaks AAPCS */ 477 | SUB SP,#4 ;/* Restores AAPCS */ 478 | BLX R0 479 | ADD SP,#4 480 | POP {PC} 481 | ALIGN 482 | LTORG 483 | ENDP 484 | MEND 485 | 486 | Insert_ExceptionHandlerVeneer NMI_Handler 487 | Insert_ExceptionHandlerVeneer HardFault_Handler 488 | Insert_ExceptionHandlerVeneer MemManage_Handler 489 | Insert_ExceptionHandlerVeneer BusFault_Handler 490 | Insert_ExceptionHandlerVeneer UsageFault_Handler 491 | Insert_ExceptionHandlerVeneer SVC_Handler 492 | Insert_ExceptionHandlerVeneer DebugMon_Handler 493 | Insert_ExceptionHandlerVeneer PendSV_Handler 494 | Insert_ExceptionHandlerVeneer SysTick_Handler 495 | 496 | Insert_ExceptionHandlerVeneer SCU_0_IRQHandler 497 | Insert_ExceptionHandlerVeneer ERU0_0_IRQHandler 498 | Insert_ExceptionHandlerVeneer ERU0_1_IRQHandler 499 | Insert_ExceptionHandlerVeneer ERU0_2_IRQHandler 500 | Insert_ExceptionHandlerVeneer ERU0_3_IRQHandler 501 | Insert_ExceptionHandlerVeneer ERU1_0_IRQHandler 502 | Insert_ExceptionHandlerVeneer ERU1_1_IRQHandler 503 | Insert_ExceptionHandlerVeneer ERU1_2_IRQHandler 504 | Insert_ExceptionHandlerVeneer ERU1_3_IRQHandler 505 | Insert_ExceptionHandlerVeneer PMU0_0_IRQHandler 506 | Insert_ExceptionHandlerVeneer VADC0_C0_0_IRQHandler 507 | Insert_ExceptionHandlerVeneer VADC0_C0_1_IRQHandler 508 | Insert_ExceptionHandlerVeneer VADC0_C0_2_IRQHandler 509 | Insert_ExceptionHandlerVeneer VADC0_C0_3_IRQHandler 510 | Insert_ExceptionHandlerVeneer VADC0_G0_0_IRQHandler 511 | Insert_ExceptionHandlerVeneer VADC0_G0_1_IRQHandler 512 | Insert_ExceptionHandlerVeneer VADC0_G0_2_IRQHandler 513 | Insert_ExceptionHandlerVeneer VADC0_G0_3_IRQHandler 514 | Insert_ExceptionHandlerVeneer VADC0_G1_0_IRQHandler 515 | Insert_ExceptionHandlerVeneer VADC0_G1_1_IRQHandler 516 | Insert_ExceptionHandlerVeneer VADC0_G1_2_IRQHandler 517 | Insert_ExceptionHandlerVeneer VADC0_G1_3_IRQHandler 518 | Insert_ExceptionHandlerVeneer VADC0_G2_0_IRQHandler 519 | Insert_ExceptionHandlerVeneer VADC0_G2_1_IRQHandler 520 | Insert_ExceptionHandlerVeneer VADC0_G2_2_IRQHandler 521 | Insert_ExceptionHandlerVeneer VADC0_G2_3_IRQHandler 522 | Insert_ExceptionHandlerVeneer VADC0_G3_0_IRQHandler 523 | Insert_ExceptionHandlerVeneer VADC0_G3_1_IRQHandler 524 | Insert_ExceptionHandlerVeneer VADC0_G3_2_IRQHandler 525 | Insert_ExceptionHandlerVeneer VADC0_G3_3_IRQHandler 526 | Insert_ExceptionHandlerVeneer DSD0_0_IRQHandler 527 | Insert_ExceptionHandlerVeneer DSD0_1_IRQHandler 528 | Insert_ExceptionHandlerVeneer DSD0_2_IRQHandler 529 | Insert_ExceptionHandlerVeneer DSD0_3_IRQHandler 530 | Insert_ExceptionHandlerVeneer DSD0_4_IRQHandler 531 | Insert_ExceptionHandlerVeneer DSD0_5_IRQHandler 532 | Insert_ExceptionHandlerVeneer DSD0_6_IRQHandler 533 | Insert_ExceptionHandlerVeneer DSD0_7_IRQHandler 534 | Insert_ExceptionHandlerVeneer DAC0_0_IRQHandler 535 | Insert_ExceptionHandlerVeneer DAC0_1_IRQHandler 536 | Insert_ExceptionHandlerVeneer CCU40_0_IRQHandler 537 | Insert_ExceptionHandlerVeneer CCU40_1_IRQHandler 538 | Insert_ExceptionHandlerVeneer CCU40_2_IRQHandler 539 | Insert_ExceptionHandlerVeneer CCU40_3_IRQHandler 540 | Insert_ExceptionHandlerVeneer CCU41_0_IRQHandler 541 | Insert_ExceptionHandlerVeneer CCU41_1_IRQHandler 542 | Insert_ExceptionHandlerVeneer CCU41_2_IRQHandler 543 | Insert_ExceptionHandlerVeneer CCU41_3_IRQHandler 544 | Insert_ExceptionHandlerVeneer CCU42_0_IRQHandler 545 | Insert_ExceptionHandlerVeneer CCU42_1_IRQHandler 546 | Insert_ExceptionHandlerVeneer CCU42_2_IRQHandler 547 | Insert_ExceptionHandlerVeneer CCU42_3_IRQHandler 548 | Insert_ExceptionHandlerVeneer CCU43_0_IRQHandler 549 | Insert_ExceptionHandlerVeneer CCU43_1_IRQHandler 550 | Insert_ExceptionHandlerVeneer CCU43_2_IRQHandler 551 | Insert_ExceptionHandlerVeneer CCU43_3_IRQHandler 552 | Insert_ExceptionHandlerVeneer CCU80_0_IRQHandler 553 | Insert_ExceptionHandlerVeneer CCU80_1_IRQHandler 554 | Insert_ExceptionHandlerVeneer CCU80_2_IRQHandler 555 | Insert_ExceptionHandlerVeneer CCU80_3_IRQHandler 556 | Insert_ExceptionHandlerVeneer CCU81_0_IRQHandler 557 | Insert_ExceptionHandlerVeneer CCU81_1_IRQHandler 558 | Insert_ExceptionHandlerVeneer CCU81_2_IRQHandler 559 | Insert_ExceptionHandlerVeneer CCU81_3_IRQHandler 560 | Insert_ExceptionHandlerVeneer POSIF0_0_IRQHandler 561 | Insert_ExceptionHandlerVeneer POSIF0_1_IRQHandler 562 | Insert_ExceptionHandlerVeneer POSIF1_0_IRQHandler 563 | Insert_ExceptionHandlerVeneer POSIF1_1_IRQHandler 564 | Insert_ExceptionHandlerVeneer HRPWM_0_IRQHandler 565 | Insert_ExceptionHandlerVeneer HRPWM_1_IRQHandler 566 | Insert_ExceptionHandlerVeneer HRPWM_2_IRQHandler 567 | Insert_ExceptionHandlerVeneer HRPWM_3_IRQHandler 568 | Insert_ExceptionHandlerVeneer CAN0_0_IRQHandler 569 | Insert_ExceptionHandlerVeneer CAN0_1_IRQHandler 570 | Insert_ExceptionHandlerVeneer CAN0_2_IRQHandler 571 | Insert_ExceptionHandlerVeneer CAN0_3_IRQHandler 572 | Insert_ExceptionHandlerVeneer CAN0_4_IRQHandler 573 | Insert_ExceptionHandlerVeneer CAN0_5_IRQHandler 574 | Insert_ExceptionHandlerVeneer CAN0_6_IRQHandler 575 | Insert_ExceptionHandlerVeneer CAN0_7_IRQHandler 576 | Insert_ExceptionHandlerVeneer USIC0_0_IRQHandler 577 | Insert_ExceptionHandlerVeneer USIC0_1_IRQHandler 578 | Insert_ExceptionHandlerVeneer USIC0_2_IRQHandler 579 | Insert_ExceptionHandlerVeneer USIC0_3_IRQHandler 580 | Insert_ExceptionHandlerVeneer USIC0_4_IRQHandler 581 | Insert_ExceptionHandlerVeneer USIC0_5_IRQHandler 582 | Insert_ExceptionHandlerVeneer USIC1_0_IRQHandler 583 | Insert_ExceptionHandlerVeneer USIC1_1_IRQHandler 584 | Insert_ExceptionHandlerVeneer USIC1_2_IRQHandler 585 | Insert_ExceptionHandlerVeneer USIC1_3_IRQHandler 586 | Insert_ExceptionHandlerVeneer USIC1_4_IRQHandler 587 | Insert_ExceptionHandlerVeneer USIC1_5_IRQHandler 588 | Insert_ExceptionHandlerVeneer LEDTS0_0_IRQHandler 589 | Insert_ExceptionHandlerVeneer FCE0_0_IRQHandler 590 | Insert_ExceptionHandlerVeneer GPDMA0_0_IRQHandler 591 | Insert_ExceptionHandlerVeneer USB0_0_IRQHandler 592 | Insert_ExceptionHandlerVeneer ETH0_0_IRQHandler 593 | ENDIF 594 | 595 | ALIGN 596 | 597 | ; User Initial Stack & Heap 598 | 599 | IF :DEF:__MICROLIB 600 | 601 | EXPORT __initial_sp 602 | EXPORT __heap_base 603 | EXPORT __heap_limit 604 | 605 | ELSE 606 | 607 | IMPORT __use_two_region_memory 608 | EXPORT __user_initial_stackheap 609 | __user_initial_stackheap 610 | 611 | LDR R0, = Heap_Mem 612 | LDR R1, =(Stack_Mem + Stack_Size) 613 | LDR R2, = (Heap_Mem + Heap_Size) 614 | LDR R3, = Stack_Mem 615 | BX LR 616 | 617 | ALIGN 618 | 619 | ENDIF 620 | 621 | 622 | END 623 | -------------------------------------------------------------------------------- /RTE/Device/XMC4400-F64x512/system_XMC4400.c: -------------------------------------------------------------------------------- 1 | /********************************************************************************************************************* 2 | * @file system_XMC4400.c 3 | * @brief CMSIS Cortex-M4 Device Peripheral Access Layer Header File for the Infineon XMC4400 Device Series 4 | * @version V3.1.4 5 | * @date 29. Oct 2018 6 | * 7 | * @cond 8 | ********************************************************************************************************************* 9 | * Copyright (c) 2014-2018, Infineon Technologies AG 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the 13 | * following conditions are met: 14 | * 15 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following 16 | * disclaimer. 17 | * 18 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 19 | * disclaimer in the documentation and/or other materials provided with the distribution. 20 | * 21 | * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote 22 | * products derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 25 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with 33 | * Infineon Technologies AG dave@infineon.com). 34 | ********************************************************************************************************************* 35 | * 36 | ********************** Version History *************************************** 37 | * V3.1.0, Dec 2014, Added options to configure clock settings 38 | * V3.1.1, 01. Jun 2016, Fix masking of OSCHPCTRL value 39 | * V3.1.2, 19. Jun 2017, Rely on cmsis_compiler.h instead of defining __WEAK 40 | * Added support for ARM Compiler 6 (armclang) 41 | * V3.1.3, 26. Sep 2017, Disable FPU if FPU_USED is zero 42 | * V3.1.4, 29. Oct 2018, Fix variable location of SystemCoreClock, g_hrpwm_char_data and g_chipid for ARMCC compiler 43 | ****************************************************************************** 44 | * @endcond 45 | */ 46 | 47 | /******************************************************************************* 48 | * HEADER FILES 49 | *******************************************************************************/ 50 | #include 51 | 52 | #include 53 | #include "system_XMC4400.h" 54 | 55 | /******************************************************************************* 56 | * MACROS 57 | *******************************************************************************/ 58 | #define CHIPID_LOC ((uint8_t *)0x20000000UL) 59 | #define HRPWM_CHARDATA_LOC ((uint8_t *)0x20000084UL) 60 | 61 | #define PMU_FLASH_WS (0x3U) 62 | 63 | #define FPLL_FREQUENCY (120000000U) 64 | #define FOSCREF (2500000U) 65 | #define DELAY_CNT_50US_50MHZ (2500UL) 66 | #define DELAY_CNT_150US_50MHZ (7500UL) 67 | #define DELAY_CNT_50US_60MHZ (3000UL) 68 | #define DELAY_CNT_50US_90MHZ (4500UL) 69 | #define DELAY_CNT_50US_120MHZ (6000UL) 70 | 71 | #define SCU_PLL_PLLSTAT_OSC_USABLE (SCU_PLL_PLLSTAT_PLLHV_Msk | \ 72 | SCU_PLL_PLLSTAT_PLLLV_Msk | \ 73 | SCU_PLL_PLLSTAT_PLLSP_Msk) 74 | 75 | /* 76 | //-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ 77 | */ 78 | 79 | /* 80 | // Clock configuration 81 | */ 82 | 83 | /* 84 | // External crystal frequency [Hz] 85 | // <8000000=> 8MHz 86 | // <12000000=> 12MHz 87 | // <16000000=> 16MHz 88 | // Defines external crystal frequency 89 | // Default: 8MHz 90 | */ 91 | #define OSCHP_FREQUENCY (12000000U) 92 | 93 | #if OSCHP_FREQUENCY == 8000000U 94 | #define USB_PDIV (1U) 95 | #define USB_NDIV (95U) 96 | #define USB_DIV (3U) 97 | 98 | #elif OSCHP_FREQUENCY == 12000000U 99 | #define USB_PDIV (1U) 100 | #define USB_NDIV (63U) 101 | #define USB_DIV (3U) 102 | 103 | #elif OSCHP_FREQUENCY == 16000000U 104 | #define USB_PDIV (1U) 105 | #define USB_NDIV (47U) 106 | #define USB_DIV (3U) 107 | 108 | #else 109 | #error "External crystal frequency not supported" 110 | 111 | #endif 112 | 113 | /* 114 | // System clock (fSYS) source selection 115 | // <0=> Backup clock (24MHz) 116 | // <1=> Maximum clock frequency using PLL (120MHz) 117 | // Default: Maximum clock frequency using PLL (120MHz) 118 | */ 119 | #define SYS_CLOCK_SRC 1 120 | #define SYS_CLOCK_SRC_OFI 0 121 | #define SYS_CLOCK_SRC_PLL 1 122 | 123 | /* 124 | // Backup clock calibration mode 125 | // <0=> Factory calibration 126 | // <1=> Automatic calibration 127 | // Default: Automatic calibration 128 | */ 129 | #define FOFI_CALIBRATION_MODE 1 130 | #define FOFI_CALIBRATION_MODE_FACTORY 0 131 | #define FOFI_CALIBRATION_MODE_AUTOMATIC 1 132 | 133 | /* 134 | // Standby clock (fSTDBY) source selection 135 | // <0=> Internal slow oscillator (32768Hz) 136 | // <1=> External crystal (32768Hz) 137 | // Default: Internal slow oscillator (32768Hz) 138 | */ 139 | #define STDBY_CLOCK_SRC 0 140 | #define STDBY_CLOCK_SRC_OSI 0 141 | #define STDBY_CLOCK_SRC_OSCULP 1 142 | 143 | /* 144 | // PLL clock source selection 145 | // <0=> External crystal 146 | // <1=> External direct input 147 | // <2=> Internal fast oscillator 148 | // Default: External crystal 149 | */ 150 | #define PLL_CLOCK_SRC 2 151 | #define PLL_CLOCK_SRC_EXT_XTAL 0 152 | #define PLL_CLOCK_SRC_EXT_DIRECT 1 153 | #define PLL_CLOCK_SRC_OFI 2 154 | 155 | #if PLL_CLOCK_SRC == PLL_CLOCK_SRC_EXT_XTAL 156 | #if OSCHP_FREQUENCY == 8000000U 157 | #define PLL_PDIV (1U) 158 | #define PLL_NDIV (89U) 159 | #define PLL_K2DIV (2U) 160 | 161 | #elif OSCHP_FREQUENCY == 12000000U 162 | #define PLL_PDIV (1U) 163 | #define PLL_NDIV (79U) 164 | #define PLL_K2DIV (3U) 165 | 166 | #elif OSCHP_FREQUENCY == 16000000U 167 | #define PLL_PDIV (1U) 168 | #define PLL_NDIV (59U) 169 | #define PLL_K2DIV (3U) 170 | 171 | #else 172 | #error "External crystal frequency not supported" 173 | 174 | #endif 175 | 176 | #define VCO ((OSCHP_FREQUENCY / (PLL_PDIV + 1UL)) * (PLL_NDIV + 1UL)) 177 | 178 | #else /* PLL_CLOCK_SRC == PLL_CLOCK_SRC_EXT_XTAL */ 179 | 180 | #define PLL_PDIV (1U) 181 | #define PLL_NDIV (39U) 182 | #define PLL_K2DIV (3U) 183 | 184 | #define VCO ((OFI_FREQUENCY / (PLL_PDIV + 1UL)) * (PLL_NDIV + 1UL)) 185 | 186 | #endif /* PLL_CLOCK_SRC == PLL_CLOCK_SRC_OFI */ 187 | 188 | #define PLL_K2DIV_0 ((VCO / OFI_FREQUENCY) - 1UL) 189 | #define PLL_K2DIV_1 ((VCO / 60000000U) - 1UL) 190 | #define PLL_K2DIV_2 ((VCO / 90000000U) - 1UL) 191 | 192 | #define SCU_CLK_CLKCLR_ENABLE_USBCLK SCU_CLK_CLKCLR_USBCDI_Msk 193 | #define SCU_CLK_CLKCLR_ENABLE_ETHCLK SCU_CLK_CLKCLR_ETH0CDI_Msk 194 | #define SCU_CLK_CLKCLR_ENABLE_CCUCLK SCU_CLK_CLKCLR_CCUCDI_Msk 195 | #define SCU_CLK_CLKCLR_ENABLE_WDTCLK SCU_CLK_CLKCLR_WDTCDI_Msk 196 | 197 | #define SCU_CLK_USBCLKCR_USBSEL_USBPLL (0U << SCU_CLK_USBCLKCR_USBSEL_Pos) 198 | #define SCU_CLK_USBCLKCR_USBSEL_PLL (1U << SCU_CLK_USBCLKCR_USBSEL_Pos) 199 | 200 | #define SCU_CLK_WDTCLKCR_WDTSEL_OFI (0U << SCU_CLK_WDTCLKCR_WDTSEL_Pos) 201 | #define SCU_CLK_WDTCLKCR_WDTSEL_STANDBY (1U << SCU_CLK_WDTCLKCR_WDTSEL_Pos) 202 | #define SCU_CLK_WDTCLKCR_WDTSEL_PLL (2U << SCU_CLK_WDTCLKCR_WDTSEL_Pos) 203 | 204 | #define SCU_CLK_EXTCLKCR_ECKSEL_SYS (0U << SCU_CLK_EXTCLKCR_ECKSEL_Pos) 205 | #define SCU_CLK_EXTCLKCR_ECKSEL_USBPLL (2U << SCU_CLK_EXTCLKCR_ECKSEL_Pos) 206 | #define SCU_CLK_EXTCLKCR_ECKSEL_PLL (3U << SCU_CLK_EXTCLKCR_ECKSEL_Pos) 207 | #define SCU_CLK_EXTCLKCR_ECKSEL_STANDBY (4U << SCU_CLK_EXTCLKCR_ECKSEL_Pos) 208 | 209 | #define EXTCLK_PIN_P0_8 (0) 210 | #define EXTCLK_PIN_P1_15 (1) 211 | 212 | /* 213 | // Clock tree 214 | // CPU clock divider 215 | // <0=> fCPU = fSYS 216 | // <1=> fCPU = fSYS / 2 217 | // Peripheral clock divider 218 | // <0=> fPB = fCPU 219 | // <1=> fPB = fCPU / 2 220 | // Enable CCU clock 221 | // CCU clock divider 222 | // <0=> fCCU = fCPU 223 | // <1=> fCCU = fCPU / 2 224 | // 225 | // Enable WDT clock 226 | // WDT clock divider <1-256><#-1> 227 | // WDT clock source <0=> fOFI 228 | // <1=> fSTDBY 229 | // <2=> fPLL 230 | // 231 | // Enable ETH clock 232 | // 233 | // Enable USB clock 234 | // USB clock source <0=> USBPLL 235 | // <1=> PLL 236 | // 237 | // External Clock configuration 238 | // External clock source selection 239 | // <0=> System clock 240 | // <2=> USB PLL clock 241 | // <3=> PLL clock 242 | // <4=> Standby clock 243 | // External clock divider <1-512><#-1> 244 | // Only valid for USB PLL and PLL clocks 245 | // External Pin Selection 246 | // <0=> P0.8 247 | // <1=> P1.15 248 | // 249 | // 250 | */ 251 | #define ENABLE_SCUCLK (0U) 252 | #define CPUCLKDIV (0U) 253 | #define PBCLKDIV (0U) 254 | #define CCUCLKDIV (0U) 255 | #define WDTCLKDIV (0U | SCU_CLK_WDTCLKCR_WDTSEL_OFI) 256 | #define USBCLKDIV (0U | SCU_CLK_USBCLKCR_USBSEL_USBPLL | USB_DIV) 257 | 258 | #define ENABLE_EXTCLK (0U) 259 | #define EXTCLKDIV (0U | SCU_CLK_EXTCLKCR_ECKSEL_SYS) 260 | #define EXTCLK_PIN (0U) 261 | 262 | #define ENABLE_PLL \ 263 | (SYS_CLOCK_SRC == SYS_CLOCK_SRC_PLL) || \ 264 | (((ENABLE_SCUCLK & SCU_CLK_CLKSET_USBCEN_Msk) != 0) && ((USBCLKDIV & SCU_CLK_USBCLKCR_USBSEL_Msk) == SCU_CLK_USBCLKCR_USBSEL_PLL)) || \ 265 | (((ENABLE_SCUCLK & SCU_CLK_CLKSET_WDTCEN_Msk) != 0) && ((WDTCLKDIV & SCU_CLK_WDTCLKCR_WDTSEL_Msk) == SCU_CLK_WDTCLKCR_WDTSEL_PLL)) 266 | 267 | /* 268 | // 269 | */ 270 | 271 | /* 272 | //-------- <<< end of configuration section >>> ------------------ 273 | */ 274 | 275 | /******************************************************************************* 276 | * GLOBAL VARIABLES 277 | *******************************************************************************/ 278 | #if defined ( __CC_ARM ) 279 | uint32_t SystemCoreClock __attribute__((at(0x2000FFC0))); 280 | uint8_t g_chipid[16] __attribute__((at(0x2000FFC4))); 281 | uint32_t g_hrpwm_char_data[3] __attribute__((at(0x2000FFD4))); 282 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 283 | uint32_t SystemCoreClock __attribute__((section(".bss.ARM.__at_0x2000FFC0"))); 284 | uint8_t g_chipid[16] __attribute__((section(".bss.ARM.__at_0x2000FFC4"))); 285 | uint32_t g_hrpwm_char_data[3] __attribute__((section(".bss.ARM.__at_0x2000FFD4"))); 286 | #elif defined ( __ICCARM__ ) 287 | __no_init uint32_t SystemCoreClock; 288 | __no_init uint8_t g_chipid[16]; 289 | __no_init uint32_t g_hrpwm_char_data[3]; 290 | #elif defined ( __GNUC__ ) 291 | uint32_t SystemCoreClock __attribute__((section(".no_init"))); 292 | uint8_t g_chipid[16] __attribute__((section(".no_init"))); 293 | uint32_t g_hrpwm_char_data[3] __attribute__((section(".no_init"))); 294 | #elif defined ( __TASKING__ ) 295 | uint32_t SystemCoreClock __at( 0x2000FFC0 ); 296 | uint8_t g_chipid[16] __at( 0x2000FFC4 ); 297 | uint32_t g_hrpwm_char_data[3] __at( 0x2000FFD4 ); 298 | #endif 299 | 300 | extern uint32_t __Vectors; 301 | 302 | /******************************************************************************* 303 | * LOCAL FUNCTIONS 304 | *******************************************************************************/ 305 | static void delay(uint32_t cycles) 306 | { 307 | volatile uint32_t i; 308 | 309 | for(i = 0UL; i < cycles ;++i) 310 | { 311 | __NOP(); 312 | } 313 | } 314 | 315 | /******************************************************************************* 316 | * API IMPLEMENTATION 317 | *******************************************************************************/ 318 | 319 | __WEAK void SystemInit(void) 320 | { 321 | memcpy(g_chipid, CHIPID_LOC, 16); 322 | memcpy(g_hrpwm_char_data, HRPWM_CHARDATA_LOC, 12); 323 | 324 | SystemCoreSetup(); 325 | SystemCoreClockSetup(); 326 | } 327 | 328 | __WEAK void SystemCoreSetup(void) 329 | { 330 | uint32_t temp; 331 | 332 | /* relocate vector table */ 333 | __disable_irq(); 334 | SCB->VTOR = (uint32_t)(&__Vectors); 335 | __DSB(); 336 | __enable_irq(); 337 | 338 | /* __FPU_PRESENT = 1 defined in device header file */ 339 | /* __FPU_USED value depends on compiler/linker options. */ 340 | /* __FPU_USED = 0 if -mfloat-abi=soft is selected */ 341 | /* __FPU_USED = 1 if -mfloat-abi=softfp or –mfloat-abi=hard */ 342 | 343 | #if ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) 344 | SCB->CPACR |= ((3UL << 10*2) | /* set CP10 Full Access */ 345 | (3UL << 11*2) ); /* set CP11 Full Access */ 346 | #else 347 | SCB->CPACR = 0; 348 | #endif 349 | 350 | /* Enable unaligned memory access - SCB_CCR.UNALIGN_TRP = 0 */ 351 | SCB->CCR &= ~(SCB_CCR_UNALIGN_TRP_Msk); 352 | 353 | temp = FLASH0->FCON; 354 | temp &= ~FLASH_FCON_WSPFLASH_Msk; 355 | temp |= PMU_FLASH_WS; 356 | FLASH0->FCON = temp; 357 | } 358 | 359 | __WEAK void SystemCoreClockSetup(void) 360 | { 361 | #if FOFI_CALIBRATION_MODE == FOFI_CALIBRATION_MODE_FACTORY 362 | /* Enable factory calibration */ 363 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_FOTR_Msk; 364 | #else 365 | /* Automatic calibration uses the fSTDBY */ 366 | 367 | /* Enable HIB domain */ 368 | /* Power up HIB domain if and only if it is currently powered down */ 369 | if((SCU_POWER->PWRSTAT & SCU_POWER_PWRSTAT_HIBEN_Msk) == 0) 370 | { 371 | SCU_POWER->PWRSET |= SCU_POWER_PWRSET_HIB_Msk; 372 | 373 | while((SCU_POWER->PWRSTAT & SCU_POWER_PWRSTAT_HIBEN_Msk) == 0) 374 | { 375 | /* wait until HIB domain is enabled */ 376 | } 377 | } 378 | 379 | /* Remove the reset only if HIB domain were in a state of reset */ 380 | if((SCU_RESET->RSTSTAT) & SCU_RESET_RSTSTAT_HIBRS_Msk) 381 | { 382 | SCU_RESET->RSTCLR |= SCU_RESET_RSTCLR_HIBRS_Msk; 383 | delay(DELAY_CNT_150US_50MHZ); 384 | } 385 | 386 | #if STDBY_CLOCK_SRC == STDBY_CLOCK_SRC_OSCULP 387 | /* Enable OSC_ULP */ 388 | if ((SCU_HIBERNATE->OSCULCTRL & SCU_HIBERNATE_OSCULCTRL_MODE_Msk) != 0UL) 389 | { 390 | /*enable OSC_ULP*/ 391 | while (SCU_GENERAL->MIRRSTS & SCU_GENERAL_MIRRSTS_OSCULCTRL_Msk) 392 | { 393 | /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */ 394 | } 395 | SCU_HIBERNATE->OSCULCTRL &= ~SCU_HIBERNATE_OSCULCTRL_MODE_Msk; 396 | 397 | /* Check if the clock is OK using OSCULP Oscillator Watchdog*/ 398 | while (SCU_GENERAL->MIRRSTS & SCU_GENERAL_MIRRSTS_HDCR_Msk) 399 | { 400 | /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */ 401 | } 402 | SCU_HIBERNATE->HDCR |= SCU_HIBERNATE_HDCR_ULPWDGEN_Msk; 403 | 404 | /* wait till clock is stable */ 405 | do 406 | { 407 | while (SCU_GENERAL->MIRRSTS & SCU_GENERAL_MIRRSTS_HDCLR_Msk) 408 | { 409 | /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */ 410 | } 411 | SCU_HIBERNATE->HDCLR |= SCU_HIBERNATE_HDCLR_ULPWDG_Msk; 412 | 413 | delay(DELAY_CNT_50US_50MHZ); 414 | 415 | } while ((SCU_HIBERNATE->HDSTAT & SCU_HIBERNATE_HDSTAT_ULPWDG_Msk) != 0UL); 416 | 417 | } 418 | 419 | /* now OSC_ULP is running and can be used*/ 420 | /* Select OSC_ULP as the clock source for RTC and STDBY*/ 421 | while (SCU_GENERAL->MIRRSTS & SCU_GENERAL_MIRRSTS_HDCR_Msk) 422 | { 423 | /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */ 424 | } 425 | SCU_HIBERNATE->HDCR |= SCU_HIBERNATE_HDCR_RCS_Msk | SCU_HIBERNATE_HDCR_STDBYSEL_Msk; 426 | 427 | #endif /* STDBY_CLOCK_SRC == STDBY_CLOCK_SRC_OSCULP */ 428 | 429 | /* Enable automatic calibration of internal fast oscillator */ 430 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_AOTREN_Msk; 431 | #endif /* FOFI_CALIBRATION_MODE == FOFI_CALIBRATION_MODE_AUTOMATIC */ 432 | 433 | delay(DELAY_CNT_150US_50MHZ); 434 | 435 | #if ENABLE_PLL 436 | 437 | /* enable PLL */ 438 | SCU_PLL->PLLCON0 &= ~(SCU_PLL_PLLCON0_VCOPWD_Msk | SCU_PLL_PLLCON0_PLLPWD_Msk); 439 | 440 | #if PLL_CLOCK_SRC != PLL_CLOCK_SRC_OFI 441 | /* enable OSC_HP */ 442 | if ((SCU_OSC->OSCHPCTRL & SCU_OSC_OSCHPCTRL_MODE_Msk) != 0U) 443 | { 444 | SCU_OSC->OSCHPCTRL &= ~(SCU_OSC_OSCHPCTRL_MODE_Msk | SCU_OSC_OSCHPCTRL_OSCVAL_Msk); 445 | SCU_OSC->OSCHPCTRL |= ((OSCHP_GetFrequency() / FOSCREF) - 1UL) << SCU_OSC_OSCHPCTRL_OSCVAL_Pos; 446 | 447 | /* select OSC_HP clock as PLL input */ 448 | SCU_PLL->PLLCON2 &= ~SCU_PLL_PLLCON2_PINSEL_Msk; 449 | 450 | /* restart OSC Watchdog */ 451 | SCU_PLL->PLLCON0 &= ~SCU_PLL_PLLCON0_OSCRES_Msk; 452 | 453 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_OSC_USABLE) != SCU_PLL_PLLSTAT_OSC_USABLE) 454 | { 455 | /* wait till OSC_HP output frequency is usable */ 456 | } 457 | } 458 | #else /* PLL_CLOCK_SRC != PLL_CLOCK_SRC_OFI */ 459 | 460 | /* select backup clock as PLL input */ 461 | SCU_PLL->PLLCON2 |= SCU_PLL_PLLCON2_PINSEL_Msk; 462 | #endif 463 | 464 | /* Go to bypass the Main PLL */ 465 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_VCOBYP_Msk; 466 | 467 | /* disconnect Oscillator from PLL */ 468 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_FINDIS_Msk; 469 | 470 | /* Setup divider settings for main PLL */ 471 | SCU_PLL->PLLCON1 = ((PLL_NDIV << SCU_PLL_PLLCON1_NDIV_Pos) | 472 | (PLL_K2DIV_0 << SCU_PLL_PLLCON1_K2DIV_Pos) | 473 | (PLL_PDIV << SCU_PLL_PLLCON1_PDIV_Pos)); 474 | 475 | /* Set OSCDISCDIS */ 476 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_OSCDISCDIS_Msk; 477 | 478 | /* connect Oscillator to PLL */ 479 | SCU_PLL->PLLCON0 &= ~SCU_PLL_PLLCON0_FINDIS_Msk; 480 | 481 | /* restart PLL Lock detection */ 482 | SCU_PLL->PLLCON0 |= SCU_PLL_PLLCON0_RESLD_Msk; 483 | 484 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOLOCK_Msk) == 0U) 485 | { 486 | /* wait for PLL Lock */ 487 | } 488 | 489 | /* Disable bypass- put PLL clock back */ 490 | SCU_PLL->PLLCON0 &= ~SCU_PLL_PLLCON0_VCOBYP_Msk; 491 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOBYST_Msk) != 0U) 492 | { 493 | /* wait for normal mode */ 494 | } 495 | #endif /* ENABLE_PLL */ 496 | 497 | #if (SYS_CLOCK_SRC == SYS_CLOCK_SRC_PLL) 498 | /* Switch system clock to PLL */ 499 | SCU_CLK->SYSCLKCR |= SCU_CLK_SYSCLKCR_SYSSEL_Msk; 500 | #else 501 | /* Switch system clock to backup clock */ 502 | SCU_CLK->SYSCLKCR &= ~SCU_CLK_SYSCLKCR_SYSSEL_Msk; 503 | #endif 504 | 505 | /* Before scaling to final frequency we need to setup the clock dividers */ 506 | SCU_CLK->PBCLKCR = PBCLKDIV; 507 | SCU_CLK->CPUCLKCR = CPUCLKDIV; 508 | SCU_CLK->CCUCLKCR = CCUCLKDIV; 509 | SCU_CLK->WDTCLKCR = WDTCLKDIV; 510 | SCU_CLK->USBCLKCR = USBCLKDIV; 511 | 512 | #if ENABLE_PLL 513 | /* PLL frequency stepping...*/ 514 | /* Reset OSCDISCDIS */ 515 | SCU_PLL->PLLCON0 &= ~SCU_PLL_PLLCON0_OSCDISCDIS_Msk; 516 | 517 | SCU_PLL->PLLCON1 = ((PLL_NDIV << SCU_PLL_PLLCON1_NDIV_Pos) | 518 | (PLL_K2DIV_1 << SCU_PLL_PLLCON1_K2DIV_Pos) | 519 | (PLL_PDIV << SCU_PLL_PLLCON1_PDIV_Pos)); 520 | 521 | 522 | delay(DELAY_CNT_50US_60MHZ); 523 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOLOCK_Msk) == 0U) 524 | { 525 | /* wait for PLL Lock */ 526 | } 527 | 528 | SCU_PLL->PLLCON1 = ((PLL_NDIV << SCU_PLL_PLLCON1_NDIV_Pos) | 529 | (PLL_K2DIV_2 << SCU_PLL_PLLCON1_K2DIV_Pos) | 530 | (PLL_PDIV << SCU_PLL_PLLCON1_PDIV_Pos)); 531 | 532 | 533 | delay(DELAY_CNT_50US_90MHZ); 534 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOLOCK_Msk) == 0U) 535 | { 536 | /* wait for PLL Lock */ 537 | } 538 | 539 | SCU_PLL->PLLCON1 = ((PLL_NDIV << SCU_PLL_PLLCON1_NDIV_Pos) | 540 | (PLL_K2DIV << SCU_PLL_PLLCON1_K2DIV_Pos) | 541 | (PLL_PDIV << SCU_PLL_PLLCON1_PDIV_Pos)); 542 | 543 | 544 | delay(DELAY_CNT_50US_120MHZ); 545 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOLOCK_Msk) == 0U) 546 | { 547 | /* wait for PLL Lock */ 548 | } 549 | 550 | SCU_TRAP->TRAPCLR = SCU_TRAP_TRAPCLR_SOSCWDGT_Msk | SCU_TRAP_TRAPCLR_SVCOLCKT_Msk; 551 | #endif /* ENABLE_PLL */ 552 | 553 | #if (((ENABLE_SCUCLK & SCU_CLK_CLKSET_USBCEN_Msk) != 0) && ((USBCLKDIV & SCU_CLK_USBCLKCR_USBSEL_Msk) == SCU_CLK_USBCLKCR_USBSEL_USBPLL)) 554 | /* enable USB PLL first */ 555 | SCU_PLL->USBPLLCON &= ~(SCU_PLL_USBPLLCON_VCOPWD_Msk | SCU_PLL_USBPLLCON_PLLPWD_Msk); 556 | 557 | /* USB PLL uses as clock input the OSC_HP */ 558 | /* check and if not already running enable OSC_HP */ 559 | if ((SCU_OSC->OSCHPCTRL & SCU_OSC_OSCHPCTRL_MODE_Msk) != 0U) 560 | { 561 | /* check if Main PLL is switched on for OSC WDG*/ 562 | if ((SCU_PLL->PLLCON0 &(SCU_PLL_PLLCON0_VCOPWD_Msk | SCU_PLL_PLLCON0_PLLPWD_Msk)) != 0UL) 563 | { 564 | /* enable PLL first */ 565 | SCU_PLL->PLLCON0 &= ~(SCU_PLL_PLLCON0_VCOPWD_Msk | SCU_PLL_PLLCON0_PLLPWD_Msk); 566 | } 567 | 568 | SCU_OSC->OSCHPCTRL &= ~(SCU_OSC_OSCHPCTRL_MODE_Msk | SCU_OSC_OSCHPCTRL_OSCVAL_Msk); 569 | SCU_OSC->OSCHPCTRL |= ((OSCHP_GetFrequency() / FOSCREF) - 1UL) << SCU_OSC_OSCHPCTRL_OSCVAL_Pos; 570 | 571 | /* restart OSC Watchdog */ 572 | SCU_PLL->PLLCON0 &= ~SCU_PLL_PLLCON0_OSCRES_Msk; 573 | 574 | while ((SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_OSC_USABLE) != SCU_PLL_PLLSTAT_OSC_USABLE) 575 | { 576 | /* wait till OSC_HP output frequency is usable */ 577 | } 578 | } 579 | 580 | /* Setup USB PLL */ 581 | /* Go to bypass the USB PLL */ 582 | SCU_PLL->USBPLLCON |= SCU_PLL_USBPLLCON_VCOBYP_Msk; 583 | 584 | /* disconnect Oscillator from USB PLL */ 585 | SCU_PLL->USBPLLCON |= SCU_PLL_USBPLLCON_FINDIS_Msk; 586 | 587 | /* Setup Divider settings for USB PLL */ 588 | SCU_PLL->USBPLLCON = ((USB_NDIV << SCU_PLL_USBPLLCON_NDIV_Pos) | 589 | (USB_PDIV << SCU_PLL_USBPLLCON_PDIV_Pos)); 590 | 591 | /* Set OSCDISCDIS */ 592 | SCU_PLL->USBPLLCON |= SCU_PLL_USBPLLCON_OSCDISCDIS_Msk; 593 | 594 | /* connect Oscillator to USB PLL */ 595 | SCU_PLL->USBPLLCON &= ~SCU_PLL_USBPLLCON_FINDIS_Msk; 596 | 597 | /* restart PLL Lock detection */ 598 | SCU_PLL->USBPLLCON |= SCU_PLL_USBPLLCON_RESLD_Msk; 599 | 600 | while ((SCU_PLL->USBPLLSTAT & SCU_PLL_USBPLLSTAT_VCOLOCK_Msk) == 0U) 601 | { 602 | /* wait for PLL Lock */ 603 | } 604 | #endif /* (USBCLKDIV & SCU_CLK_USBCLKCR_USBSEL_Msk) */ 605 | 606 | /* Enable selected clocks */ 607 | SCU_CLK->CLKSET = ENABLE_SCUCLK; 608 | 609 | #if ENABLE_EXTCLK == 1 610 | /* Configure external clock */ 611 | SCU_CLK->EXTCLKCR = EXTCLKDIV; 612 | 613 | #if EXTCLK_PIN == EXTCLK_PIN_P1_15 614 | /* P1.15 */ 615 | PORT1->PDR1 &= ~PORT1_PDR1_PD15_Msk; 616 | PORT1->IOCR12 = (PORT1->IOCR12 & ~PORT0_IOCR12_PC15_Msk) | (0x11U << PORT0_IOCR12_PC15_Pos); 617 | #else 618 | /* P0.8 */ 619 | PORT0->HWSEL &= ~PORT0_HWSEL_HW8_Msk; 620 | PORT0->PDR1 &= ~PORT0_PDR1_PD8_Msk; 621 | PORT0->IOCR8 = (PORT0->IOCR8 & ~PORT0_IOCR8_PC8_Msk) | (0x11U << PORT0_IOCR8_PC8_Pos); 622 | #endif 623 | 624 | #endif /* ENABLE_EXTCLK == 1 */ 625 | 626 | SystemCoreClockUpdate(); 627 | } 628 | 629 | __WEAK void SystemCoreClockUpdate(void) 630 | { 631 | uint32_t pdiv; 632 | uint32_t ndiv; 633 | uint32_t kdiv; 634 | uint32_t temp; 635 | 636 | if (SCU_CLK->SYSCLKCR & SCU_CLK_SYSCLKCR_SYSSEL_Msk) 637 | { 638 | /* fPLL is clock source for fSYS */ 639 | if(SCU_PLL->PLLCON2 & SCU_PLL_PLLCON2_PINSEL_Msk) 640 | { 641 | /* PLL input clock is the backup clock (fOFI) */ 642 | temp = OFI_FREQUENCY; 643 | } 644 | else 645 | { 646 | /* PLL input clock is the high performance osicllator (fOSCHP) */ 647 | temp = OSCHP_GetFrequency(); 648 | } 649 | 650 | /* check if PLL is locked */ 651 | if (SCU_PLL->PLLSTAT & SCU_PLL_PLLSTAT_VCOLOCK_Msk) 652 | { 653 | /* PLL normal mode */ 654 | /* read back divider settings */ 655 | pdiv = ((SCU_PLL->PLLCON1 & SCU_PLL_PLLCON1_PDIV_Msk) >> SCU_PLL_PLLCON1_PDIV_Pos) + 1; 656 | ndiv = ((SCU_PLL->PLLCON1 & SCU_PLL_PLLCON1_NDIV_Msk) >> SCU_PLL_PLLCON1_NDIV_Pos) + 1; 657 | kdiv = ((SCU_PLL->PLLCON1 & SCU_PLL_PLLCON1_K2DIV_Msk) >> SCU_PLL_PLLCON1_K2DIV_Pos) + 1; 658 | 659 | temp = (temp / (pdiv * kdiv)) * ndiv; 660 | } 661 | else 662 | { 663 | /* PLL prescalar mode */ 664 | /* read back divider settings */ 665 | kdiv = ((SCU_PLL->PLLCON1 & SCU_PLL_PLLCON1_K1DIV_Msk) >> SCU_PLL_PLLCON1_K1DIV_Pos) + 1; 666 | 667 | temp = (temp / kdiv); 668 | } 669 | } 670 | else 671 | { 672 | /* fOFI is clock source for fSYS */ 673 | temp = OFI_FREQUENCY; 674 | } 675 | 676 | temp = temp / ((SCU_CLK->SYSCLKCR & SCU_CLK_SYSCLKCR_SYSDIV_Msk) + 1); 677 | temp = temp / ((SCU_CLK->CPUCLKCR & SCU_CLK_CPUCLKCR_CPUDIV_Msk) + 1); 678 | 679 | SystemCoreClock = temp; 680 | } 681 | 682 | __WEAK uint32_t OSCHP_GetFrequency(void) 683 | { 684 | return OSCHP_FREQUENCY; 685 | } 686 | -------------------------------------------------------------------------------- /RTE/_Target_1/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Component Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: 'PMSM_FOC' 7 | * Target: 'Target 1' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "XMC4400.h" 18 | 19 | #define RTE_DEVICE 20 | #define RTE_DEVICE_STARTUP 21 | #define RTE_DEVICE_XMCLIB_DAC 22 | #define RTE_DEVICE_XMCLIB_GPIO 23 | #define RTE_DEVICE_XMCLIB_SCU 24 | #define RTE_DEVICE_XMCLIB_UART 25 | 26 | #endif /* RTE_COMPONENTS_H */ 27 | -------------------------------------------------------------------------------- /Readme/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/Readme/README.txt -------------------------------------------------------------------------------- /SYS_Init/MCU_Initialize.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/SYS_Init/MCU_Initialize.c -------------------------------------------------------------------------------- /SYS_Init/MCU_Initialize.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/SYS_Init/MCU_Initialize.h -------------------------------------------------------------------------------- /SYS_Init/VAR_Initialize.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/SYS_Init/VAR_Initialize.c -------------------------------------------------------------------------------- /SYS_Init/VAR_Initialize.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/SYS_Init/VAR_Initialize.h -------------------------------------------------------------------------------- /Sensorless_Lib/PMSM_FOC.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/Sensorless_Lib/PMSM_FOC.lib -------------------------------------------------------------------------------- /Sensorless_Lib/SVPWM.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NYCParker/sensorless_foc/85254b37fcbc8c9620cbb7ce2c39b7ee86bdd74e/Sensorless_Lib/SVPWM.lib --------------------------------------------------------------------------------