Select active apps while running

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

cross mob
Not applicable
Hi,

I'm using the XMC4500 Relax Lite Kit to implement a modular Charging station. One controller controls one module. The modules communicate via I2C.
My question is if I can load the same software on each controller and it decides if it will be a master or slave. (Set via jumper)
I'd like to use the apps I2C_MASTER and I2C_SLAVE.

Is it possible to prevent the initialization of these apps and do them myself later?

Thanks
0 Likes
2 Replies
DRubeša
Employee
Employee
First solution authored First like received
Hi,

so my advice on the topic. Is it possible? Yes, it is...but I cannot predict how big the effort will be to make everything work. As you can see, for every DAVE CE project there is DAVE_Init() function. So there is where initialization of the APPs happen. They are initialized at run-time whenever and wherever you like or prefer. However, the configurations of those apps (for example that "I2C_MASTER_0" structure) is generated when you press "Generate Code" icon. Also, all APP relevant functions are generated before run-time. So, my advice to quickly see how everything behaves is add one I2C MASTER and one I2C SLAVE APP to a new project. Then inside DAVE_Init() function swap parameters for Init functions, something like this:

	 
init_status = (DAVE_STATUS_t)I2C_MASTER_Init(&I2C_SLAVE_0);
init_status = (DAVE_STATUS_t)I2C_SLAVE_Init(&I2C_MASTER_0);


Notice that I passed to the "Master_init" function slave configuration struct and vice versa. I get you´ll get some issues like pins, or USIC channel don´t match anymore. OK, that means you will need to change the structure values on the fly during run-time and so on. As you can see it´s hard to say how big effort will be. Also, try to make APP configuration as simple as possible; try maybe with Direct transmission mode rather then Interrupt based while there you also need to handle service routines which will make modifications even harder.
Additionally you may try I2C_CONFIG APP; as you can see that one is like plain I2C configuration APP so you can set the slave or master on the fly...however, it may not work out-of-the-box.

At the end, if all proves to be very hard to manage, you can always use XMCLibs and define two configuration structures, one for master device, one for slave, and then dynamically assign them to a pointer which you use however you need.

Good luck and best regards 🙂
Deni
0 Likes
Not applicable
Thanks for your reply, Deni!

That is unfortunate, I was hoping I could cut some parts from the DAVE.h file and then use them in my code to get the desired effect.

How would one use XMCLibs to define two different config structs?
That sounds like a good alternative solution.
0 Likes