With Simulink development, how can get S32K MCU into sleep?
As a response for your question we have attached an example that allows the S32K144 to enter the Very-Low-Power Stop (VLPS) mode by using the Model Based Design Toolbox and by inserting some “Custom C code” inside a Simulink S-Function Blocks.
The functionality that we want to achieve is to put the processor in VLPS by pressing the SW3 button and to wake it up by pressing the SW2 button. When the processor will run into the VLPS mode the RGB led will light up red, otherwise it will light up green.
Inside the archive code there are 5 files:
The first two files contains two functions that we need to configure the uC to unlock the low power modes (enable_low_power_modes()) and the other (go_to_sleep()) puts the uC into VLPS mode. The .m file contains the code that will copy the external files into the test_low_power_s32k_mbd_rtw folder.
To run the example attached you need to follow these steps:
For measuring the actual current consumption of the uC, we desoldered the 0 ohm R117 resistor and placed an Ammeter on J15 (you don't need to do that). When the uC is in the RUN mode, the current consumption is about 35mA.
When the uC runs in the VLPS mode, the consumption is about 30 uA.
I hope that this example helps you!
Sorry for delay - originally you placed the query in a different community.
The Model Based Design toolbox does not covers all the "bells and whistles" that NXP S32K is capable of. We have plans to change that and we are currently working in adding additional blocks.
Nonetheless, this is the beauty for Model Based Design - you do not need to have all the blocks available in order to achieve what you want. Matlab and Simulink offers a wide variety of options that can be employed to resolve such use cases.
For your particular use case - i advice you to use the "Custom code". You can implement your our own C-code function to put the S32K in sleep mode by setting up the appropriate registers.
Furthermore - you can potentially use the S32K SDK power management functions to be invoked from Simulink in order to reach your goal.
How to do that? it is relatively simple. Please have a look of these links:
Hope these will help you!
thank you! if i use the s-function builder ,i must need the c-coder,but SDK example, the power management function nested many functions, it is very inconvenient to use, do you have a register version of the example?
We do not have a particular example power management. I think you should start from the example attached in this thread: https://community.nxp.com/thread/452468?commentID=910444#comment-910444 (simulation models) and one you manage to recreate the setup on your PC then we can assist you with guidelines about the C-code.
Hi Marius Andrei:
thank you very much for your answer.it is useful.
Retrieving data ...