Thursday 15 May 2014

XMC 2Go tutorial: PWM pong by C/D

Our first tutorial and touch of XMC 2Go. Let's start typing!

First of all some considerations. When you plug-in the micro-USB into your XMC 2Go for first time, the factory default program loaded into board it starts and you can see an infinite loop of alternate on-off between the two leds onboard.

At first touch we notice an overheating near the micro-USB plug from voltage regulator IFX54211 MBV33 (in picture we touch the section on bottom...), a possible reason could be a current source drain.

This could be a problem in future, because it could exercise an excessive battery drain on a battery connected to device. Current drain declared from Infineon is 75 mA:
"Out of the box with the pre-programmed application and the on-board debugger in operation the XMC 2Go typically draws about 75 mA."
It's a good news for a mobile project, but it doesn't explain the extra-heating noticed!

So any way, open our DAVE compiler to write this first tutorial.

DAVE™ Bench is a free and easy to use development tool standalone with automatic code generation modules. It's suited to develop software drivers for Infineon microcontrollers and it aids the developer with automatically created C-level templates. DAVE was developed by Infineon Technologies so, the code generated with it supports only Infineon microcontrollers.
We don't known other compilers that support this microcontroller under Linux; if you have any suggestion, please leave this information in comments!

To start our new project, you have to click on File -> New -> DAVE Project and the compiler will show the window below.
You have to type the Project Name, select DAVE CE Project and click Next.

Now you select the MCU controller in XMC1100 series, XMC1100-T038F0064, and click Next.

We charge "PWMSP001" in textfield of Search Filter, it will report all results in according to the research in Category Based Tree, the app we're going to insert in our project will be PWMSP001 [1.0.31].

We're going to instantiate PWMSP001 App and NVIC002 App (with the same process of research for NVIC002 [1.0.26]) from App Selection View, simply with a double click on label app wanted.

For PWMSP001 App, you need to instanziate a second one by another doble click on App Selection View; then the compiler will ask you to define the connection with the dependencies of first one, the sharability, you have to select the existing app as shown below and click OK.

Now, double click on both PWMSP001 apps and you sets all configurations as shown below, then click on Enable at initialization on Period Match section.

You have to repeat the same method for NVIC002 App as showed below, then type "PWM_Period_Interrupt" under interrupt handler to define the function called back from the interrupt.

Now, you have to set manually every pin to every PWMSP001 apps. For XMC 2Go, the LEDs pinout on board is correspondent to P1.0 and P1.1 pins, as shown.

The last operation, before code writing, it's to assign the Signal Connections from PWMSP001 apps to NVIC002 App, as shown below.

Now, typing our code and we explore it.
As you can see, into main we start with this two lines:
These function declarations start a Single Phase PWM which will in turn start CCU4_CCy slice timer to generate PWM. It also enables the interrupt and clears the IDLE mode of the CCU.

Then the main interrupt control.
It's used by top level Apps to define interrupt handler to be reassigned to the actual mapped interrupt node (that is Period Match Interrupt).
The if statement defined,
if (state%10 == 0)
it controls the counter state to create an ongoing loop fixed to condition of decade crossing, when it happen the two Status objects increase (and decrease) the duty cycle rate of PWM signal to LEDs.

Status0 = PWMSP001_SetDutyCycle((PWMSP001_HandleType*)
&PWMSP001_Handle0, rate);
Status1 = PWMSP001_SetDutyCycle((PWMSP001_HandleType*)
&PWMSP001_Handle1, 100-rate);

We can continue with typing; click on Debug button on main DAVE window and start the debugging (after that you will have set up all about TASKING C/C++ Debugger in Debug Configuration), as shown.


The result of all our struggles is shown in the video below, we leave you to view it and we suggest you to keep in touch for future release of tutorials.

See you next time!

GitHub files

No comments:

Post a Comment

Hi at all, leave me a feedback for this post. Thx