element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
RoadTests & Reviews
  • Products
  • More
RoadTests & Reviews
Review Blogs Infineon Gate Driver with Truly Differential Input: Custom Firmware to Control Duty Cycle
  • Blogs
  • RoadTest Forum
  • Documents
  • RoadTests
  • Reviews
  • Polls
  • Files
  • Members
  • Sub-Groups
  • More
  • Cancel
  • New
Join RoadTests & Reviews to participate - click to join for free!
  • Share
  • More
  • Cancel
  • Author Author: Jan Cumps
  • Date Created: 12 May 2019 5:02 PM Date Created
  • Views 1281 views
  • Likes 3 likes
  • Comments 3 comments
Related
Recommended
  • RoadTest
  • infineon
  • xmc1100
  • xmc 2 go

Infineon Gate Driver with Truly Differential Input: Custom Firmware to Control Duty Cycle

Jan Cumps
Jan Cumps
12 May 2019

I'm road testing the Infineon Gate Driver with Truly Differential Input. It's a half bridge driven by a PWM signal.

The firmware that comes with this kit always drives the half-bridge to 50%.

I've changed it, so that you can control the duty cycle from 5 to 95 % with a potentiometer.

image

 

 

I've started from the example that comes with the kit, and mixed the Dave ADC_MEASUREMENT_EXAMPLE_xxx with it.

The ADC example (downsized to only take one measurement) checks the value at pin P2.0.

I've connected a potentiometer to the XMC 2 Go controller board, one side to 3V3, one to GND and the wiper to P2.0

 

image

 

The ADC example works based on an interrupt and stores the measured voltage at P2.0. That represents the position of the potentiometer.

In the firmware, I calculate a % out of that position ( turned off being 0%, completely to the right = 100%).

The PWM settings (that are defined by constant values in the original example) is in my version calculated based on that potentiometer position.

I've attached the firmware to this post.

 

Working with the DAVE IDE

 

You can customise your firmware with DAVE APPS. An ADC and a PWM are example of such apps.

 

PWM

 

The standard program comes with 2 PWM apps. One for the high side and one for te low side signal.

They are linked., so that the second PWM fires when the first one's falling edge.

image

Here's how the standard program controls the PWM behaviour:

 

  // PARAMETERS TO SET: FSW, D, T_D
#define CLOCK_F 64000000.0
#define FSW 100000                               // SET the PWM frequency FSW (Hz);
#define FREQ (uint32_t)(CLOCK_F / FSW)
#define D 0.50                                  // SET the duty cycle D for the PWM LS (Express D in [0,1] );
//#define D 0.08                                  // SET the duty cycle D for the PWM LS (Express D in [0,1] );
#define DUTY (uint32_t)((1-D)*FREQ)
#define T_D 109                              // SET the dead time T_D between the PWM LS and HS (Express T_D in ns)
#define DEAD_TIME (uint32_t)((T_D*CLOCK_F*0.000000001)+0.5)

  PWM_CCU4_0.ccu4_slice_ptr->CRS = DUTY; // Duty cycle (PR-CRS)
  PWM_CCU4_0.ccu4_slice_ptr->PRS = FREQ; //Operating frequency

  PWM_CCU4_1.ccu4_slice_ptr->CRS = DEAD_TIME-5; //Dead time
  PWM_CCU4_1.ccu4_slice_ptr->PRS = DUTY-DEAD_TIME-5; //Duty-Dead time

  PWM_CCU4_0.ccu4_module_ptr->GCSS = PWM_CCU4_0.shadow_txfr_msk | PWM_CCU4_1.shadow_txfr_msk;

 

 

In my program, D is not a constant, but a function getDuty():that returns a value between 0 and 1 based on the sampled wiper position:

 

volatile uint32_t result_potentiometer = 0u;

uint32_t getDuty() {
  float retval = ((4096 - result_potentiometer) * 1.0);
  retval /= 4096;
  retval = retval > 0.95? 0.95 : retval;
  retval = retval < 0.05? 0.05 : retval;
  retval *= FREQ;
  return (uint32_t) retval;
}

 

This only slightly changes the PWM logic.

 

ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
PWM_CCU4_0.ccu4_slice_ptr->PRS = FREQ; //Operating frequency

PWM_CCU4_1.ccu4_slice_ptr->CRS = DEAD_TIME - 5; //Dead time

while (1U) {
  // PARAMETERS TO SET: FSW, D, T_D
  uint32_t duty = getDuty();
  PWM_CCU4_0.ccu4_slice_ptr->CRS = duty; // Duty cycle (PR-CRS)
  PWM_CCU4_1.ccu4_slice_ptr->PRS = duty - DEAD_TIME - 5; //Duty-Dead time

  PWM_CCU4_0.ccu4_module_ptr->GCSS = PWM_CCU4_0.shadow_txfr_msk
    | PWM_CCU4_1.shadow_txfr_msk;
}

 

ADC

 

I borrowed from the ADC_MEASUREMENT example available from Infineon. The example samples two pins and I only need P2.0, so I slimmed it down.

You can assign the pin used to sample via the Manual Pin Allocator:

 

image

 

 

In my code above, you can see that I declared the variable to hold the sampled wiper value as a global volatile one:

 

volatile uint32_t result_potentiometer = 0u;

 

In the ADC app, I declared the interrupt handler:

 

image

 

The handler is implemented in the firmware:

 

void Adc_Measurement_Handler(void) {
  /*Read out conversion results*/
  result_potentiometer = ADC_MEASUREMENT_GetResult(
    &ADC_MEASUREMENT_Potentiometer_handle);

  /*Re-trigger conversion sequence*/
  ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
}

 

It samples, stores that value in the global variable, then re-arms the trigger.

 

Because the PWM loop runs forever (like an Arduino loop(), it picks up the last sample and adapts the PWM duty cycle.

The photo below shows the setup in action, at 66.5% duty cycle.

image

 

Turning the potentiometer from left to right regulates the bridge from low to high output.

A nice bonus is that on the Infineon evaluation board, the LEDs for both channels (both the input and power ones) dim and brighten along.

 

image

Attachments:
ADC_20190512-3.zip
  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps over 6 years ago +2
    I've made a little plugin board for the duty cycle control:
  • DAB
    DAB over 6 years ago +1
    Looks like you are getting ringing or cross over spikes during the switching. DAB
  • Jan Cumps
    Jan Cumps over 6 years ago in reply to DAB +1
    Looks like you are getting ringing or cross over spikes during the switching. DAB Yes. I’m using jumper wires to tap off the PWM signals and the crocodile type probe ground attachments. They impact the…
  • Jan Cumps
    Jan Cumps over 6 years ago

    I've made a little plugin board for the duty cycle control:

    image

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 6 years ago in reply to DAB

     

    Looks like you are getting ringing or cross over spikes during the switching.

     

    DAB

     

    Yes. I’m using jumper wires to tap off the PWM signals and the crocodile type probe ground attachments.

    They impact the signal integrity.

    All is OK though.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 6 years ago

    Looks like you are getting ringing or cross over spikes during the switching.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube