execution time is very slow

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

cross mob
Not applicable
Hi All,

I am working with the XMC1300 kit and in Toggling an IO using "DIGITAL_IO_ToggleOutput(&DIGITAL_IO_0);" I noticed that I only achieve a period of approx. 6.5us. This is the only instruction I have in the "while(1U){}" loop.

Why is it this slow? Is it because I am in debugging mode? How do I just build and execute without debugging to check?

Regards
Enigma
0 Likes
3 Replies
chismo
Employee
Employee
First like received
Hello Enigma,

6.5 us for the pulse due to pin toggling is indeed rather slow. I would suggest the following:

1) Ensure that the chip is running at the maximum frequency of 32 MHz
XMC_SCU_CLOCK_SetMCLKFrequency(32000);


2) Use direct register coding instead of through the LLD, for example to toggle pin P0.0:
PORT0->OMR = 0x00010001;


With the above steps, you should be able to get down to a pulse in the nanosecond range.

If further reduction is still required, you can also:
3) Select optimization level 1 in the active project properties (from project tab)

Regards,
Min Wei
0 Likes
Not applicable
Hi Min Wei,

Below is the code I believe you suggested. It does not toggle pin P0.0, can you please point out what I am doing wrong?

#include
#include

int main(void)
{
XMC_SCU_CLOCK_SetMCLKFrequency(32000);

while(1U)
{
PORT0->OMR = 0x00010001;
}
}

Regards
Enigma
0 Likes
Not applicable
Hi again,

Solved the problem. I forgot to set the control register.

Regards
Enigma
0 Likes