Hi João Paulo,
I will try to explain the way you can select brake and modes in your stand alone program (running without KMS GUI). Please ask any question you want about it.
The best way to run a example out of KMS is following "Kinetis Motor Suite Lab Guide.pdf"
In KMS, open VIEW menu and clock on Documents. Select KMS Lab Guide (as in picture below) and click ok.

Follow Labs, specially 3.1.7 and 3.1.8 section.
After that, as demo of how to Run and Brake, you can can create a new button command, just after SW2 GPIO done in LAB Guide, like:
//Adding State switch between BRAKE and RUN
/* Switch is active Low but we want active high logic */
if (GPIO_DRV_ReadPinInput(kGpioSW3) == 0)
{
if (user.state==0x08)
{
user.state=USER_BRAKE;
}
else
{
user.state=USER_RUN_PLAN;
}
}
Remember (as showed in LAB Guide) to add extern USER_t user;
Now using SW3, you can switch from Run to Brake and then Run again (don't forget to press sw2 to spin it again).
In order to change how KMS will brake motor, you need to declare a new variable (main or global, depends upon your code), like:
BRAKE_config_t newbrakeCfg;
And in your code, do the selection of brake method you want to use:
newbrakeCfg = flashSysParamsHeader.brakeCfg; //Load the default values to your config variable
newbrakeCfg.brakingType = BRAKE_REGEN; // Change the Brake method as you desire
USER_cfgBrake(&newbrakeCfg); // Update brake configuration
brakingType can be any of following enum values (from brake.h):
typedef enum
{
BRAKE_ZERO_VECTOR = 0, /**< Zero Vector braking (High sides OFF, Low side ON) (default) */
BRAKE_REGEN, /**< Regenerative (FOC) braking */
BRAKE_COAST, /**< Coast to stop braking (all PWM's disabled) */
BRAKE_DC_INJECTION, /**< DC Injection braking */
} BRAKE_type_e;
I believe it is all you need to Spin (and now Brake) your motor using KMS in stand alone application.
Let me know if you have any comment.
Best Regards,
Renato Kiss