XMC 2Go: WS2812B communication protocol and CPU speed

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

cross mob
Not applicable
Hi,

I wrote some line of code to drive a LED WS2812B.
I took inspiration from the approach of cpldcpu that has wrote something like this for another ARM microcontroller, but I have serious problems with timing of my board (XMC 2Go).
I evaluated the basic times for high and low datas, plus for NOP instruction; and I found this timing:

- High data about 2.7 - 3.47 us (with an error of 0.77 us)
- Low data about 1.93 - 5.47 us (with an error of 3.54 us, but you have to bear in mind the "while statement")
- NOP time about 11.8 - 11.2 us
- Max frequency generated with direct initialization (without NOP) port about 569 kHz

(all evaluated with a DSO Quad in "none mode"!)

Obviously with this times it's impossible to control a period of 1.25 us!

The basic code that I used for it was:


int main(void)
{
// status_t status; // Declaration of return variable for DAVE3 APIs (toggle comment if required)

DAVE_Init(); // Initialization of DAVE Apps

while(1)
{
//__NOP();
PORT0->OMR = 0x00000001UL;
//__NOP();
PORT0->OMR = 0x00010000UL;
//__NOP();
PORT0->OMR = 0x00000001UL;
//__NOP();
PORT0->OMR = 0x00010000UL;

}
return 0;
}


Obviously with and without "nop comments".

I think that the problem could be in this message:
"Warning: CPU is running at low speed (6238 kHz)."
That it has been discussed into a precedent post.

I'm new in Cortex M0, so I don't know if the DAVE compiler have some compiling problem :confused: or if it's a problem of initialization :confused:.

Could you help me?
0 Likes
3 Replies
Not applicable
Have someone an answer ?!
0 Likes
Not applicable
Hi cosmok82,

I'm not familiar with WS2812B so I'm not really sure what you trying to do.
Perhaps you can give some details on what you try to achieve here?
And what is the MCLK you have set in your project?

As for the warning, is really has nothing to do with the CPU speed.
0 Likes
fly
Employee
Employee
Do a release build by switching the active build configuration to "Release" and make sure the debug configuration is also using the binary you get from the release build and the operations will run at full speed.
0 Likes