Slow Pin toggling using Dave App Method

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Markus_S
Level 2
Level 2
First like received 10 sign-ins 5 questions asked
I was wondering about how fast a pin is toggled using the XMC2Go Kit and the Digital-IO App Methods.
The Clock configuration is 32MHz MCLK.

The code is simply:

while(1U){
DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_1);
DIGITAL_IO_SetOutputLow(&DIGITAL_IO_1);
}

It takes up to 7.5us to execute one loop!
And the jitter is in the range of 1us (see Picture: https://drive.google.com/open?id=11lC_dxhH07zhpNbUA6kphS3aPlF9UOCF).

I find this behaviour strange: The loop executes extremely slow in my opinion (given the Clock speed), and I can't really explain
where this jitter comes from.

Could anyone advise me?

Many Thanks in Advance!
0 Likes
3 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

It is about compiler optimization. The default compiler optimization for a new project is none, i.e. -O0. In the project settings (Alt+Enter) you can change the compiler optimization. If you enable -O2 and look into the listing file in the Debug folder you will see a quite reduced while loop generated compared to the one generated using no optimization

__STATIC_INLINE void XMC_GPIO_SetOutputHigh(XMC_GPIO_PORT_t *const port, const uint8_t pin)
{
XMC_ASSERT("XMC_GPIO_SetOutputHigh: Invalid port", XMC_GPIO_CHECK_OUTPUT_PORT(port));

port->OMR = (uint32_t)0x1U << pin;
10001232: 6059 str r1, [r3, #4]

__STATIC_INLINE void XMC_GPIO_SetOutputLow(XMC_GPIO_PORT_t *const port, const uint8_t pin)
{
XMC_ASSERT("XMC_GPIO_SetOutputLow: Invalid port", XMC_GPIO_CHECK_OUTPUT_PORT(port));

port->OMR = 0x10000U << pin;
10001234: 605a str r2, [r3, #4]
10001236: e7fc b.n 10001232




Regarding the jitter you mention, which version of the system_XMC1100.c are you using? Since version v1.9 the flash wait states setting is changed from adaptiv to a fixed value of 1.
See https://www.infineon.com/dgdl/Infineon-XMC1000_Datasheet_Addendum-DS-v01_00-EN.pdf?fileId=5546d46253...

Regards,
Jesus
0 Likes
Markus_S
Level 2
Level 2
First like received 10 sign-ins 5 questions asked
Hello,

thank you very much for this explanation. With optimization level chaned it looks good.
I use Version V1.12 of system_XMC1100.c in this project.
How should I update the projet setting to use newest version?

Regards,
Markus
0 Likes
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

The v1.12 from 29 Oct 2018 is the lastest version.

Regards,
Jesus
0 Likes