Hello !
In your latest SDK you have configuration flag what "move" peripheral clock control out of driver source code.
For example in case of i2C driver :
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) &FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
/* Enable I2C clock. */
CLOCK_EnableClock(s_i2cClocks[I2C_GetInstance(base)]);
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
What was reason for enable this kind of configuration ?
Can frequent enable/disable if peripherals bring some synchronisation problems or problem with low power modes , LLS3 for example ?
How safe to enable clocks all used peripherals at main() stage and after that only use relevant driver API.
For example in my case I have complex routine for recover I2C master interface ( connection to some important sensor) and it include Deinit/Init API calls of I2C driver. Basically I2C clock can be disabled and enabled again several times.
Whole MCU can go to LLS3 power mode sometimes and it can happens when some clocks is enabled and disabled.
I can see I2C API can enable/disable I2C peripheral itself and it always done together with clock.
So is any dangerous relation between peripheral clock and actual enabling/disabling of peripherals ?
Is any other preconditions should be kept if clock control located out of driver code ?
Regards !
Eugene
Hello Eugene,
This kind of configuration is implemented just in the case the user doesn’t want the clock to be control by the driver. If this flag is set to 1, application should handle clock enable/disable for all the drivers.
From my perspective there is no dangerous relation when disabling driver clock control as long as you make sure you enable the corresponding clock for your application, otherwise you will face drivers not working correctly.
Also, if you are going to enter to a low power mode you will not only need to disable the peripheral but the clock as well. As you will be doing this outside the driver you may need to call some other function to disable unrequired clocks.
I hope you find this helpful.
Have a great day,
Felipe
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------