# PINMAP STM32G474CEU6

## Source inventory

| Item | Result | Evidence |
|------|--------|----------|
| STM32G474CEU6 Keil `.uvprojx` | UNKNOWN/TODO | No `.uvprojx` found under `F:\set\workspace\setcorp\set506\AD` |
| Candidate STM32G474 Keil `.uvprojx` | FOUND OUTSIDE WRITABLE ROOT | `F:\set\workspace\setcorp\set506\git_project\stm32g474\stm32g474_IHM08M\IHM08M\MDK-ARM\IHM08M.uvprojx` |
| Candidate CubeMX `.ioc` | FOUND OUTSIDE WRITABLE ROOT | `F:\set\workspace\setcorp\set506\git_project\stm32g474\stm32g474_IHM08M\IHM08M\IHM08M.ioc` |
| Candidate target MCU | MISMATCH | `.ioc` and `.uvprojx` use `STM32G474RETx`, board `NUCLEO-G474RE`, package `LQFP64`; requested MCU is `STM32G474CEU6` |
| STM32 HAL/LL init files in current `AD` workspace | UNKNOWN/TODO | No `Core/Src/main.c`, `gpio.c`, `adc.c`, `tim.c`, `stm32g4xx_hal_msp.c` under `AD` before this task |
| Simulink model | FOUND | `Inu_im_1wnd_3lvl/inu_im_1wnd_3lvl.slx`, `Inu_im_1wnd_3lvl/inu_im_1wnd_3lvl_r2021b.slx` |
| Existing embedded reference code | FOUND, non-STM32 | `Inu_im_1wnd_3lvl/Inu/*.c`, target comments and headers reference `TMS320F28335/TMS320F28379D` |

## Verified STM32G474CEU6 pins

No verified STM32G474CEU6 pin assignment is present in the current `AD` workspace. The table is intentionally not populated with guessed CubeMX defaults.

| MCU pin | Port/Pin | Signal name | Direction | Peripheral/AF | Connected block | Source file | Init function | Active level | Notes |
|---------|----------|-------------|-----------|----------------|-----------------|-------------|---------------|--------------|-------|
| UNKNOWN | UNKNOWN | UNKNOWN | UNKNOWN | UNKNOWN | UNKNOWN | TODO: add `.ioc`, `main.h`, `gpio.c`, `stm32g4xx_hal_msp.c`, `.uvprojx` | UNKNOWN | UNKNOWN | STM32G474CEU6 pinout cannot be reconstructed from the files currently present |

## Candidate STM32G474RETx pins found outside `AD`

These rows come from the sibling NUCLEO-G474RE project. They are useful evidence, but they are not a verified `STM32G474CEU6` pinout.

| MCU pin | Port/Pin | Signal name | Direction | Peripheral/AF | Connected block | Source file | Init function | Active level | Notes |
|---------|----------|-------------|-----------|----------------|-----------------|-------------|---------------|--------------|-------|
| LQFP64 pin UNKNOWN | PC13 | B1 | Input interrupt | EXTI13 | Blue push button | `IHM08M.ioc`, `Core/Inc/main.h`, `Core/Src/main.c:250` | `MX_GPIO_Init` | Rising edge | Candidate project only |
| LQFP64 pin UNKNOWN | PC14 | RCC_OSC32_IN | Input | LSE oscillator | 32.768 kHz crystal | `IHM08M.ioc`, `Core/Inc/main.h` | RCC/CubeMX | Analog clock | Candidate project only |
| LQFP64 pin UNKNOWN | PC15 | RCC_OSC32_OUT | Output | LSE oscillator | 32.768 kHz crystal | `IHM08M.ioc`, `Core/Inc/main.h` | RCC/CubeMX | Analog clock | Candidate project only |
| LQFP64 pin UNKNOWN | PF0 | RCC_OSC_IN | Input | HSE oscillator | External oscillator | `IHM08M.ioc`, `Core/Inc/main.h` | RCC/CubeMX | Analog clock | Candidate project only |
| LQFP64 pin UNKNOWN | PF1 | RCC_OSC_OUT | Output | HSE oscillator | External oscillator | `IHM08M.ioc`, `Core/Inc/main.h` | RCC/CubeMX | Analog clock | Candidate project only |
| LQFP64 pin UNKNOWN | PA5 | LD2 | Output | GPIO output | Green LED | `IHM08M.ioc`, `Core/Inc/main.h`, `Core/Src/main.c:256` | `MX_GPIO_Init` | Reset by init; Nucleo LED usually active high | Candidate project only |
| LQFP64 pin UNKNOWN | PA7 | TIM1_CH1N | PWM output | AF6 TIM1_CH1N, open-drain AF in MSP | PWM Generation1 CH1N | `IHM08M.ioc`, `Core/Src/stm32g4xx_hal_msp.c:122` | `MX_TIM1_Init`, `HAL_TIM_MspPostInit` | PWM, polarity high | Break disabled, dead-time 0 in `MX_TIM1_Init` |
| LQFP64 pin UNKNOWN | PB0 | UNKNOWN GPIO output | Output | GPIO output | UNKNOWN | `IHM08M.ioc`, `Core/Src/main.c:263` | `MX_GPIO_Init` | Reset by init | Candidate project only |
| LQFP64 pin UNKNOWN | PB1 | UNKNOWN GPIO output | Output | GPIO output | UNKNOWN | `IHM08M.ioc`, `Core/Src/main.c:263` | `MX_GPIO_Init` | Reset by init | Candidate project only |
| LQFP64 pin UNKNOWN | PA8 | UNKNOWN GPIO output | Output | GPIO output | UNKNOWN | `IHM08M.ioc`, `Core/Src/main.c:256` | `MX_GPIO_Init` | Reset by init | Candidate project only |
| LQFP64 pin UNKNOWN | PA9 | UNKNOWN GPIO output | Output | GPIO output | UNKNOWN | `IHM08M.ioc`, `Core/Src/main.c:256` | `MX_GPIO_Init` | Reset by init | Candidate project only |
| LQFP64 pin UNKNOWN | PA10 | UNKNOWN GPIO output | Output | GPIO output | UNKNOWN | `IHM08M.ioc`, `Core/Src/main.c:256` | `MX_GPIO_Init` | Reset by init | Candidate project only |
| LQFP64 pin UNKNOWN | PA13 | T_SWDIO | Debug | SWDIO | SWD | `IHM08M.ioc`, `Core/Inc/main.h` | SYS/CubeMX | Debug | Candidate project only |
| LQFP64 pin UNKNOWN | PA14 | T_SWCLK | Debug | SWCLK | SWD | `IHM08M.ioc`, `Core/Inc/main.h` | SYS/CubeMX | Debug | Candidate project only |
| LQFP64 pin UNKNOWN | PB3 | T_SWO | Debug | SWO | Trace | `IHM08M.ioc`, `Core/Inc/main.h` | SYS/CubeMX | Debug | Candidate project only |

Candidate project peripheral status:

| Peripheral | Status | Evidence |
|------------|--------|----------|
| ADC | Not enabled | `HAL_ADC_MODULE_ENABLED` commented in `Core/Inc/stm32g4xx_hal_conf.h` |
| TIM/PWM | TIM1 PWM CH1N only | `MX_TIM1_Init`, `PA7 TIM1_CH1N` |
| GPIO | PC13, PA5, PA8, PA9, PA10, PB0, PB1 plus debug/osc pins | `.ioc`, `main.c` |
| DMA | HAL DMA source included by project, no configured DMA init found | `.uvprojx`, no `MX_DMA_Init` |
| UART/USART | Not enabled | `HAL_USART_MODULE_ENABLED` commented |
| CAN/FDCAN | Not enabled | `HAL_FDCAN_MODULE_ENABLED` commented |
| SPI/I2C | Not enabled | `HAL_SPI_MODULE_ENABLED`, `HAL_I2C_MODULE_ENABLED` commented |
| OPAMP/COMP | Not enabled | `HAL_OPAMP_MODULE_ENABLED`, `HAL_COMP_MODULE_ENABLED` commented |
| Watchdog/fault inputs | Not configured | No IWDG/WWDG init; TIM1 break disabled |

## Non-STM32 reference signals found in existing code

These rows are not STM32 pins. They are the actual motor-control pin/peripheral evidence found in the available C2000/Simulink source and should be used only as a migration checklist.

| MCU pin | Port/Pin | Signal name | Direction | Peripheral/AF | Connected block | Source file | Init function | Active level | Notes |
|---------|----------|-------------|-----------|----------------|-----------------|-------------|---------------|--------------|-------|
| TMS320 GPIO0 | GPIO0 | EPWM1A | PWM output | ePWM1A | INU phase/control leg | `Inu/init28335.c:177` | `SetupGpio` | PWM | C2000 reference only |
| TMS320 GPIO1 | GPIO1 | EPWM1B | PWM output | ePWM1B | INU phase/control leg | `Inu/init28335.c:178` | `SetupGpio` | PWM | Complementary/dead-band in ePWM |
| TMS320 GPIO2 | GPIO2 | EPWM2A | PWM output | ePWM2A | INU phase/control leg | `Inu/init28335.c:179` | `SetupGpio` | PWM | C2000 reference only |
| TMS320 GPIO3 | GPIO3 | EPWM2B | PWM output | ePWM2B | INU phase/control leg | `Inu/init28335.c:180` | `SetupGpio` | PWM | C2000 reference only |
| TMS320 GPIO4 | GPIO4 | EPWM3A | PWM output | ePWM3A | INU phase/control leg | `Inu/init28335.c:181` | `SetupGpio` | PWM | C2000 reference only |
| TMS320 GPIO5 | GPIO5 | EPWM3B | PWM output | ePWM3B | INU phase/control leg | `Inu/init28335.c:182` | `SetupGpio` | PWM | C2000 reference only |
| TMS320 GPIO6 | GPIO6 | EPWM4A | PWM output | ePWM4A | INU phase/control leg | `Inu/init28335.c:183` | `SetupGpio` | PWM | C2000 reference only |
| TMS320 GPIO7 | GPIO7 | EPWM4B | PWM output | ePWM4B | INU phase/control leg | `Inu/init28335.c:184` | `SetupGpio` | PWM | C2000 reference only |
| TMS320 GPIO8 | GPIO8 | EPWM5A | PWM output | ePWM5A | INU phase/control leg | `Inu/init28335.c:185` | `SetupGpio` | PWM | C2000 reference only |
| TMS320 GPIO9 | GPIO9 | EPWM5B | PWM output | ePWM5B | INU phase/control leg | `Inu/init28335.c:186` | `SetupGpio` | PWM | C2000 reference only |
| TMS320 GPIO10 | GPIO10 | EPWM6A | PWM output | ePWM6A | INU phase/control leg | `Inu/init28335.c:187` | `SetupGpio` | PWM | C2000 reference only |
| TMS320 GPIO11 | GPIO11 | EPWM6B | PWM output | ePWM6B | INU phase/control leg | `Inu/init28335.c:188` | `SetupGpio` | PWM | C2000 reference only |
| TMS320 GPIO22 | GPIO22 | SCITXDB | Output | SCI-B TX | Communication | `Inu/init28335.c:200` | `SetupGpio` | UART idle high | Exact protocol UNKNOWN |
| TMS320 GPIO23 | GPIO23 | SCIRXDB | Input | SCI-B RX | Communication | `Inu/init28335.c:201` | `SetupGpio` | UART idle high | Exact protocol UNKNOWN |
| TMS320 GPIO24 | GPIO24 | EQEP2A | Input | eQEP2A | Speed/position sensor | `Inu/init28335.c:202` | `SetupGpio`, `SetupEqep` | Quadrature | Used by `sens_wm()` |
| TMS320 GPIO25 | GPIO25 | EQEP2B | Input | eQEP2B | Speed/position sensor | `Inu/init28335.c:203` | `SetupGpio`, `SetupEqep` | Quadrature | Used by `sens_wm()` |
| TMS320 GPIO26 | GPIO26 | EQEP2I | Input | eQEP2I | Index sensor | `Inu/init28335.c:204` | `SetupGpio`, `SetupEqep` | Index | Used by eQEP block |
| TMS320 GPIO28 | GPIO28 | SCIRXDA | Input | SCI-A RX | Communication | `Inu/init28335.c:206` | `SetupGpio` | UART idle high | Protocol UNKNOWN |
| TMS320 GPIO29 | GPIO29 | SCITXDA | Output | SCI-A TX | Communication | `Inu/init28335.c:207` | `SetupGpio` | UART idle high | Protocol UNKNOWN |
| TMS320 GPIO32 | GPIO32 | EPWMSYNCI | Input | ePWM sync in | PWM sync | `Inu/init28335.c:211` | `SetupGpio` | Peripheral | C2000 reference only |
| TMS320 GPIO33 | GPIO33 | EPWMSYNCO | Output | ePWM sync out | PWM sync | `Inu/init28335.c:212` | `SetupGpio` | Peripheral | C2000 reference only |
| TMS320 GPIO50 | GPIO50 | DI_24V_SOURCE_FAULT | Input | GPIO | +24 V supply fault | `Inu/def.h:139`, `Inu/isr.c:140` | `SetupGpio` | Active high | FaultNo 7 after debounce |
| TMS320 GPIO54 | GPIO54 | SPISIMOA | Output | SPI-A MOSI | EEPROM or external SPI | `Inu/init28335.c:234` | `SetupGpio` | SPI | Exact device UNKNOWN |
| TMS320 GPIO55 | GPIO55 | SPISOMIA | Input | SPI-A MISO | EEPROM or external SPI | `Inu/init28335.c:235` | `SetupGpio` | SPI | Exact device UNKNOWN |
| TMS320 GPIO56 | GPIO56 | SPICLKA | Output | SPI-A SCK | EEPROM or external SPI | `Inu/init28335.c:236` | `SetupGpio` | SPI | Exact device UNKNOWN |
| TMS320 GPIO57 | GPIO57 | CS | Output | GPIO | EEPROM chip select | `Inu/def.h:180` | `SetupGpio` | Active high by macro `CS_SET` | Verify external device polarity |
| TMS320 GPIO59 | GPIO59 | LED_GREEN1 | Output | GPIO | Ready LED | `Inu/def.h:184` | `SetupGpio` | Active low | `ON` writes GPBCLEAR |
| TMS320 GPIO60 | GPIO60 | LED_GREEN2 | Output | GPIO | Work LED | `Inu/def.h:188` | `SetupGpio` | Active low | `ON` writes GPBCLEAR |
| TMS320 GPIO61 | GPIO61 | LED_RED | Output | GPIO | Fault LED | `Inu/def.h:192` | `SetupGpio` | Active low | `ON` writes GPBCLEAR |
| TMS320 GPIO62 | GPIO62 | SCIRXDC | Input | SCI-C RX | Communication | `Inu/init28335.c:242` | `SetupGpio` | UART idle high | Protocol UNKNOWN |
| TMS320 GPIO63 | GPIO63 | SCITXDC | Output | SCI-C TX | Communication | `Inu/init28335.c:243` | `SetupGpio` | UART idle high | Also has `DO_GPIO63_CLEAR` macro |

## ADC evidence in existing code

| ADC result | Signal | Source file | Init function | Notes |
|------------|--------|-------------|---------------|-------|
| ADCRESULT0 | `udc1` | `Inu/isr.c:37`, `Inu/controller.c:340` | `SetupAdc` | DC-link voltage, offset `offset.Udc1` |
| ADCRESULT2 | `ic1` | `Inu/isr.c:38`, `Inu/controller.c:347` | `SetupAdc` | Phase/current channel C, offset `offset.Ic1` |
| ADCRESULT4 | `ia1` | `Inu/isr.c:39`, `Inu/controller.c:356` | `SetupAdc` | Phase/current channel A, offset `offset.Ia1` |
| ADCRESULT6 | `ib1` | `Inu/isr.c:40`, `Inu/controller.c:363` | `SetupAdc` | Phase/current channel B, offset `offset.Ib1` |

## TODO for STM32G474CEU6 migration

Add the real STM32 project files, then regenerate this document from:

- `.ioc`: pin names, peripherals, AF selections, ADC channels, DMA, timers.
- `Core/Inc/main.h`: GPIO aliases and active-level macros.
- `Core/Src/gpio.c`, `adc.c`, `tim.c`, `usart.c`, `fdcan.c`, `spi.c`, `i2c.c`: init functions.
- `Core/Src/stm32g4xx_hal_msp.c`: MSP GPIO AF and DMA binding.
- `.uvprojx`: included source tree and target device.
