Changing walktime in XMC1202 on the Arduino shield to low values

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

cross mob
Not applicable
Hello, I have one question regarding the Infineon Arduino Shield shield with an XMC1202, KITLEDXMC1202AS01TOBO1

Does anyone know why it is not possible to set WALKTIME lower than 15?

This code:

I2CWRITE2BYTES (ADDRESS, WALKTIME, 25);
works fine, while this code:

I2CWRITE2BYTES (ADDRESS, WALKTIME, 5)
sets the walktime to 15.

I suppose there is some coding in the XMC1202 itself?
I need to switch off the walktime entirely, so any help would be appreciated very much.

Thanks a lot!
0 Likes
12 Replies
DRubeša
Employee
Employee
First solution authored First like received
Hi,

can you please let me know what example/library are you using? I mean where did you find "I2CWRITE2BYTES()" function definition? I do not have direct exposure to Arduino but I can take a look at least and maybe ask someone more competent to reply to your question.

Best regards,
Deni
0 Likes
Not applicable
Hello, Deni

thanks for your reply.

The function I2CWRITE2BYTES is part of Infineons example Arduino Sketch and is also mentioned in the shields board manual, eg, on page 25 when explaining the WALKTIME funtion of the board.

Have a look in this manual at page 25, please.

The problem is, that when it is not possible to set the walktime to 0 one cannot make the led immeditely change the color, instead it will always fade (or "walk"). I need to make the colors change as fast as possible eg from red to green to blue and so on. Now they always fade at a speed of 15, the lowest possible value.

Thanks a lot for your help!

Martin...
0 Likes
DRubeša
Employee
Employee
First solution authored First like received
Hi Martin,

so after certain investigation, I want to tell to what conclusions I have come out.
You cannot set WALKTIME value to anything lower than 15 because of the following lines:
else if(Command == WALKTIME) /* Change Walk Time */
{
DataTotal &= 0x03FF; /* Mask data. Walktime is 10 bit, not 12 bit information */
if(DataTotal < 0xF)
{
DataTotal = 0xF;
}
PDM_BCCU_SetLinearWalk(&R_PDM, DataTotal); /* Red channel */
PDM_BCCU_SetLinearWalk(&G_PDM, DataTotal); /* Green channel */
PDM_BCCU_SetLinearWalk(&B_PDM, DataTotal); /* Blue channel */
DCDC_BUCK.linearwalk_prescaler = DataTotal; /* change linear walk in lamphandle enum */
byteCount = 0;
flashBuffer[19] = DataTotal;
}


As you can see, any value lower than 15 will be saturated to value 15. I´ve sent email to some colleagues for an explanation while we define lower limit for this application. I can tell you tell if you would be using DAVE/Keil/IAR (something that has XMCLIbs on disposal), you would be able to set the value to 0. Function "XMC_BCCU_CH_SetLinearWalkPrescaler()" accepts also value "0" as prescaler argument. You can also see the excerpt from a Reference Manual stating this:

If BCCU_CHCONFIGy (y=0-8).LINPRES is 0, the intensity level will be the same as the target intensity level on shadow transfer, which means that the linear walker is effectively bypassed.


As I said before, I never tried working with Sketch (at least not with Infineon Shields, I had my time with Duemilanove during studies though ;)) so I cannot tell you how much you can change, BUT if you´re trying to run following example (http://www.infineon.com/dgdl/Infineon-RGB_LED_Lighting_Shield_XMC1202_Source_Code-SW-v06_00-EN.zip?f...) then you can simply in the "main.c" file remove that lower limit and allow that even value "0" is a valid parameter for the "I2CWRITE2BYTES" function.

Best regards,
Deni
0 Likes
Not applicable
Deni, you are my king! Really, this is so great, you really digged into such a rare topic!

Okay, this for sure is the reason why not being able to set values lower than 15. Now I wonder why it was done!? Maybe there is a hardware limitation so I could destroy the board when setting lower values? Just asking, because there MUST have been a reason for saturating the value. All values that address other functions like the dimming level or the intensity accept 0 as a valid parmeter.
So I really felt more comfortable knowing the reason before changing it.

And also: I never did anything with DAVE or so, I do not even know what it is. How do I change the code, then compile it and how do I upload it to the shield? It does not even have an USB port. Will I have to connect to the "DEBUG" pins? Could you give me any hint for that? Thank you so much!

Best regards! Martin.
0 Likes
Not applicable
Okay, having a look into the manual I found on page 12:

The on-board XMC1202 microcontroller can be programmed over SWD via the debug interfaces
using a J-Link debug probe from Segger that supports ARM® Cortex™-M0 (Figure 3).
Flash content can be updated over SWD using the TASKING debugger integrated in DAVE™.

Now googling the Segger J-Link debug probe I found out it is a peace of hardware! Woooo, will I really have to buy hardware just to make the RGB-shield change the colors without delay? Hope thats not true! 🙂
However, if it is: you might consider commenting out the lines for the boards you ship in future. I think that also other users need to change colors without delay, no?

Would it maybe be possible to change the value directly by writing into a specifi address? In the example there is a function:

void I2CWRITE_DIRECTACCESS (unsigned int Address, unsigned int Command, unsigned long registerAddress, unsigned long Data) // For accessing registers directly

Is this maybe meant to directly write values into the XMC1200?

Thank you very much so far!
0 Likes
DRubeša
Employee
Employee
First solution authored First like received
Hi Martin,

so let´s go step by step 🙂 first to answer on your first message. I´ve already sent an email to colleagues who developed the examples and libraries for Lighting Shield so let´s see what is the reason to limit the value to 15.
OK, so I guess that this board comes already with the code flashed on it and this board does not come with on-board debugger meaning that only way to flash a new code would be to use XMC Link (http://www.infineon.com/cms/en/product/evaluation-boards/KIT_XMC_LINK_SEGGER_V1/productType.html?pro...) or probe that you mentioned. And of course, we want to avoid any additional costs so let´s try to work with the functions that are available to us.

The function that you mentioned looks like a solution. With this you have direct control over CHCONFIG register that controls the linear walk time. The problem is that code that is flashed by default sets the value of the walk time to 160ms. You can see on the following figure how the settings look like:
3030.attach

So you need to "override" that value by writing value "0" to the CHCONFIG.LINPRES bitfield.
Try using the function that you mentioned and let me know how it went and I will try to find out why the lower limit is set to 15.

Best regards,
Deni
0 Likes
Not applicable
Hello Deni,

thanks a lot again. Could you give me a hint which address to use to set the CHCONFIG.LINPRES bitfield to 0:

I tried:

I2CWRITE_DIRECTACCESS (ADDRESS, DIRECTACCESS_MOVE, CHCONFIG.LINPRES, 0);

but CHCONFIG.LINPRES is not defined.

Probably I could find out here, but I never dealt with masks, so I am not sure what to do.


Thanks! Martin
0 Likes
DRubeša
Employee
Employee
First solution authored First like received
HI Martin,

so address you can find in that file that you attached to your previous post:
CHCONFIG - 0x50030044. However this is a base address of the mentioned register....there are in total 9 channels and every channel has it´s own CHCONFIG register for controlling linear walk time. And if I read the data correctly, the channels that are used are channel 5 (RED), channel 4 (GREEN), and channel 3 (BLUE). So the address is then 0x50030044 + channel_number * 0x14.

I would suggest to use DIRECTACCESS_AND instead of DIRECTACCESS_MOVE. We need to set the CHCONFIG.LINPRES bitfield to 0 but we also want to preserve the content of other bitfields in the CHCONFIG register. If you use MOVE and 0 you would destroy the content of register which could probably cause erroneous behavior. For this reason you want to write something like: 0xFC00FFFF .

So, imagine that we have register whose content we can describe as 0xXXXXXXXX. If we do AND with this register and our previously defined mask we will get: 0xXXXXXXXX AND 0xFC00FFFF = xxxx xx00 0000 0000 xxxx xxxx xxxx xxxx (this is in binary and you can see that we preserve the original content of a register and we (re)set the LINPRES bitfield (bitrange [25-16]) to "0").

At the end, I guess the function calls should look like this:

I2CWRITE_DIRECTACCESS (ADDRESS, DIRECTACCESS_AND, 0x500300A8, 0xFC00FFFF); // RED LED
I2CWRITE_DIRECTACCESS (ADDRESS, DIRECTACCESS_AND, 0x50030094, 0xFC00FFFF); // GREEN LED
I2CWRITE_DIRECTACCESS (ADDRESS, DIRECTACCESS_AND, 0x50030080, 0xFC00FFFF); // BLUE LED

Best regards,
Deni
0 Likes
Not applicable
Hallo Deni,

once again thank you so much for your help. Sorry for being off a little.

I am sure these are beginners issues, but I don't really understand your post. Looking at the image you posted, WALKTIME is a parameter set for the shield, not for the colors, no?

So I don't understand why to set WALKTIME for the colors now. And what 9 channels are you talking about? I don't know if I ever will understand this "mask" thing. I am really unsure what to do, especially as you write I could destroy the content of the other fields.

Assuming setting the WALKTIME to 0 as you set:

I2CWRITE_DIRECTACCESS (ADDRESS, DIRECTACCESS_AND, 0x500300A8, 0xFC00FFFF); // RED LED
I2CWRITE_DIRECTACCESS (ADDRESS, DIRECTACCESS_AND, 0x50030094, 0xFC00FFFF); // GREEN LED
I2CWRITE_DIRECTACCESS (ADDRESS, DIRECTACCESS_AND, 0x50030080, 0xFC00FFFF); // BLUE LED

how would I set the WALKTIME to 15 or any other value? I mean, where the hell is the actual value in the code above?

Would you mind checking my code until I have a secure function made from it?

This is what I needed in the end:


void SetWalktime(int iWalktime)
{

int valueMasked = ? 😮

I2CWRITE_DIRECTACCESS (ADDRESS, DIRECTACCESS_AND, 0x500300A8, valueMasked ); // RED LED
I2CWRITE_DIRECTACCESS (ADDRESS, DIRECTACCESS_AND, 0x50030094, valueMasked ); // GREEN LED
I2CWRITE_DIRECTACCESS (ADDRESS, DIRECTACCESS_AND, 0x50030080, valueMasked ); // BLUE LED
}


And also, would you mind checking the addresses? Are these really the right ones? I only have one shield and I don't want to miss it! :rolleyes:

Thanks a lot... Martin
0 Likes
Not applicable
Hello Deni,

I suppose you are in holiday, right? I am still waiting to implement the "I2CWRITE_DIRECTACCESS -hack" because I unsure what to do. Don't want to damage the shield.

So Im am hoping you find the time to once again help a little more until I have the shield running...

Thanks. Martin.
0 Likes
DRubeša
Employee
Employee
First solution authored First like received
Hi Martin,

I´m still not on a vacation (finally from Friday :p) but I changed my work position so I don´t have much time as before to devoted to our beloved forum. I sometimes reply on some questions that I can clarify in some minutes. Unfortunately, you need pretty long reply while you asked me so many things :D.
Still, I will send you an answer as a Christmas present :cool:

And, please feel free to use my suggestion; microcontrollers are not so sensitive things that one wrong look will damage them. After all,
"Only while using the code and playing with it, you will learn something."

Unknown wise software developer


At the end, I will write you some ideas, explanations and/or suggestions, not whole, production-ready function. I don´t want to be guilty if your lab assignment or master thesis is not working 😉

Best regards and expect Santa Claus soon,
Deni
0 Likes
Not applicable
Hello Dani and Martin,

I interest in what you doing, now I have a project to make flicker simulation on LED.
I try to make current waveform with changing variable CURRENT_RED.
I try to make a square wave but it was not a perfect waveform.
Infineon board needs time to reach maximum current. form 0-100% Current, it needs around 82ms.
I already read infineon manual board page 31, that changing brightness from 0 to Max needs 20479 clock, where clock frequency is 292.237kHz, so it took around 70ms changing the current from 0 to maximum. Is there any way to make it faster? can I change parameter with DIRECTACCESS ?
3029.attach3030.attach

Best regards,
Eko Purwanto
0 Likes