Skip to content

About

vehicle comfort control s32k344

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

NXP Application Code Hub

Vehicle Comfort Control on FRDM-A-S32K344

This demo showcases the control of vehicle comfort motor systems using embedded peripherals. It operates a fan and a stepper motor based on button input conditions, while providing real-time feedback on speed and direction through PWM control and full-step coil sequencing. The example illustrates how automotive motor control principles are applied to key vehicle functions, such as electric window operation (up/down maneuvering) and cooling system regulation, emphasizing directional control and step-mode operation.

Boards: FRDM-A-S32K344

Categories: Touch Sensing

Peripherals: GPIO, PWM

Toolchains: S32 Design Studio IDE

Table of Contents

  1. Software and Tools
  2. Hardware
  3. Setup
  4. Results
  5. Support
  6. Release Notes

1. Software and Tools

This example was developed using the FRDM Automotive Bundle for S32K3 + S32M27. To download and install the complete software and tools ecosystem, use the following link:

2. Hardware

2.1 Required Hardware

  • Personal Computer
  • Type-C USB cable
Boards Images
- FRDM-A-S32K344
- FRDM K64 click shield

- DC Motor2 Click
- H-Bridge Click

- 5V Fan Motor
- Stepper Motor Nema17

2.2 Hardware Connections

FRDM-A-S32K3 Header Pin I/O FRDM Shield Click Board Click Pin Description
PTA13 GPIO J4 pin 5 → A2 H-Bridge I2B Stepper Coil A
PTD0 GPIO J4 pin 1 → A1 H-Bridge I2A Stepper Coil B
PTA3 GPIO J4 pin 6 → D5 H-Bridge I1A Stepper Coil C
PTC10 GPIO J2 pin 17 → D9 H-Bridge I1B Stepper Coil D
PTE1 GPIO J4 pin 7 → A3 DC MOTOR 2 IN2 Data input 2
PTB17 GPIO J2 pin 15 → D10 DC MOTOR 2 IN1 Data input 1
PTD2 GPIO JP4 pin 11 → D2 DC MOTOR 2 SLP Sleep control
PTA1 EMIOS JP4 pin 3 → D6 DC MOTOR 2 PWM PWM control
PTB26 — ← SW2 — — Switch 2 input
PTB19 — ← SW3 — — Switch 3 input
GND JA3 pin 13 → GND DC MOTOR 2 GND Ground
VDD_PERH JA3 pin 7 → 3.3V DC MOTOR 2 3V3 Power Supply
GND JA3 pin 11 → GND H-Bridge GND Ground
VDD_PERH JA3 pin 7 → 3.3V H-Bridge 3V3 Power Supply
  • Connect the 3.4V DC Power Supply to the MikroE Clicks, in order to power the Motors:
    • DC Motor 2 Click:
      • GND -> PGND
      • 3.4V -> VM
      • Fan+ -> Out2
      • Fan- -> Out1
    • H-Bridge Click (move Resistor from SEL to VIN)
      • GND -> GND
      • 3.4V -> VIN
      • 2B -> Black
      • 2A -> Green
      • 1A -> Blue
      • 1B -> Red

2.3 Debugger Connection

  • Connect the Type-C USB cable to PC and FRDM-A-S32K344 board for power and debugging

3. Setup

3.1 Import the Project into S32 Design Studio IDE

  1. Open S32 Design Studio IDE, in the Dashboard Panel, choose Import project from Application Code Hub.

  2. Find the demo you need by searching for the name directly.
    Open the project, click on the GitHub link from this window, S32 Design Studio IDE will automatically retrieve project attributes, then click Next>.

  3. Select main branch and then click Next>.

  4. Select your local path for the repo in Destination->Directory window. The S32 Design Studio IDE will clone the repo into this path, click Next>.

  5. Select Import existing Eclipse projects then click Next>.

  6. Select the project in this repo (only one project in this repo) then click Finish.

3.2 Generating, Building and Running the Example

  1. In Project Explorer, right-click the project and select Update Code and Build Project. This will generate the configuration (Pins, Clocks, Peripherals), update the source code and build the project using the active configuration (e.g. Debug_FLASH). Make sure the build completes successfully and the *.elf file is generated without errors.

    Press Yes in the SDK Component Management pop-up window to continue.

  2. Go to Debug and select Debug Configurations. There will be a debug configuration for this project:

     Configuration Name                  Description
     -------------------------------     -----------------------
     $(example)_debug_flash_pemicro      Debug the FLASH configuration using PEmicro probe
    

    Select the desired debug configuration and click on Debug. Now the perspective will change to the Debug Perspective. Use the controls to control the program flow.

4. Results

The H-Bridge Click board and DC Motor Click board are controlled by the S32K344 microcontroller to simulate a complete vehicle comfort motor control system. Upon startup, both motors perform a self-test sequence — the Fan motor executes a slow-to-fast acceleration ramp followed by a smooth deceleration to stop, and the Stepper motor runs a fast burst forward, decelerates to a crawl, then mirrors the sequence in reverse — verifying proper functionality of both motor drivers before entering normal operation.

During normal operation, two push buttons (SW2 and SW3) control either the Fan motor or the Stepper motor depending on the currently active mode. The system supports runtime mode switching by pressing both buttons simultaneously. In DC motor mode, button presses step the PWM duty cycle up or down in 33% increments (0% → 33% → 67% → 100%), with the TB6593FNG driver automatically enabled on start and put to sleep on stop to prevent winding current waste. In stepper motor mode, SW2 drives the motor forward one full step per press and SW3 drives it in reverse, with all coils de-energised when no button is held to prevent overheating.

By pressing the buttons on the evaluation board, the motors will respond in the following specific way:


Button SW2 + SW3 (simultaneous): Mode Toggle

  • Function: Switches between DC Motor Mode and Stepper Motor Mode
  • Debounce: 200 ms
  • Notes: Fan motor continues running at its current duty cycle when switching to stepper mode. Stepper coils are turned off when switching back to DC mode. Both buttons must be released before normal operation resumes.

FAN Control Motor Mode

Button SW2: Speed Increase

  • Function: Increases FAN motor speed by one step (+33% duty cycle)
  • Speed Steps:
Step Duty Counts Duty %
0 0 0% (stopped)
1 6667 33%
2 13333 67%
3 20000 100%
  • Notes: Automatically sets motor direction to FORWARD and wakes the TB6593FNG driver from sleep when starting from a stopped state. Clamps at 100%.

Button SW3: Speed Decrease

  • Function: Decreases FAN motor speed by one step (−33% duty cycle)
  • Notes: Clamps at 0% (stopped). Automatically sets motor to COAST state and puts the driver into low-power sleep mode when fully stopped to prevent wasted current through the windings.

Stepper Motor Mode

Button SW2: Step Forward

  • Function: Advances the stepper motor one full step in the forward direction
  • Step Delay: 3 ms per step (maximum hardware speed)
  • Sequence: Full-step dual-coil drive — AC → BC → BD → AD (positions 0 → 1 → 2 → 3 → wrap)
  • Notes: Coil pair remains energised while button is held, advancing one step per loop iteration.

Button SW3: Step Reverse

  • Function: Advances the stepper motor one full step in the reverse direction
  • Step Delay: 3 ms per step
  • Sequence: Reverse of forward sequence — AD → BD → BC → AC (positions 3 → 2 → 1 → 0 → wrap)
  • Notes: Coil pair remains energised while button is held.

No Button Pressed (Stepper Mode)

  • Function: All stepper coils de-energised — motor holds last mechanical position passively
  • Notes: 10 ms idle delay per loop iteration. Prevents motor winding overheating during idle periods.

Power-On Self-Test Sequence

DC Motor Self-Test

  1. Ramp UP — 100 PWM steps, delay decreases from 100 ms → 5 ms (slow start accelerating to full speed)
  2. Hold at 100% duty for 300 ms
  3. Ramp DOWN — 100 PWM steps, delay increases from 5 ms → 100 ms (smooth deceleration to stop)

Stepper Motor Self-Test

  1. Ultra-fast burst forward — 32 steps at 3 ms/step (maximum hardware rate)
  2. Decelerate forward — 32 steps, delay linearly increases 3 ms → 50 ms
  3. Slow crawl forward — 8 steps at 50 ms/step (each step clearly visible)
  4. Ultra-fast burst reverse — 32 steps at 3 ms/step
  5. Decelerate reverse — 32 steps, delay linearly increases 3 ms → 50 ms
  6. Slow crawl reverse — 8 steps at 50 ms/step
  7. All coils off — self-test complete

5. Support

For general technical questions related to NXP microcontrollers, please visit the NXP Community Forum.

Project Metadata

Board badge

Category badge

Peripheral badge Peripheral badge

Toolchain badge

Questions regarding the content/correctness of this example can be entered as Issues within this GitHub repository.

Warning: For more general technical questions regarding NXP Microcontrollers and the difference in expected functionality, enter your questions on the NXP Community Forum

Follow us on Youtube Follow us on LinkedIn Follow us on Facebook Follow us on Twitter

6. Release Notes

Version Description / Update Date
1.0 Initial release on Application Code Hub May 29th 2026
1.1 Updated to FRDM Automotive S32K3 + S32M27 (RTD 7.0.1) August 25th 2026

About

vehicle comfort control s32k344

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages