Initialize and Deinitialize BLE in FRDM KW41Z

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Initialize and Deinitialize BLE in FRDM KW41Z

Jump to solution
2,897 Views
dvdsosa
Contributor II

Dear all,

I took the FreeRTOS Wireless UART BLE example from the SDK as the base for a project. First, instead of starting the system with the "startup_task", I start the system with a task that serves as a command-line interface (CLI) to query the board via UART on PC.

After that, I turn on the BLE with a command by the CLI (this command starts the "startup_task" in the same way as it is in the raw example but with some things commented, like the SerialManager init because it is already initialized, etc.).

Next, I switch BLE off with another command (destroying all tasks, queues, events, etc. and de-initializing the things I see I can do so). The problem comes when I turn BLE on again; the problem is located in the AppMain.c file in the if condition:

/* BLE Host Stack Init */
if (Ble_Initialize(App_GenericCallback) != gBleSuccess_c)
{
panic(0,0,0,0);
return;
}
Instead "gBleSuccess_c" I got "gBleAlreadyInitialized_c" from Ble_Initialize as it is normal because it has been already initialized before. Looking inside Ble_Initialize, the one who returns "gBleAlreadyInitialized_c" is the Ble_HostInitialize function, found in the static library "lib_ble_4-2_host_cm0p.a"
 
Then I think about De-Initialize the Ble but I do not find the other function of Ble_HostInitialize() to undo its initialization.
 
As I have been working a lot of time on this project, I hope someone could help me to correctly switch BLE off, and then back on. 
 
Does anyone know how could I De-Initialize the Ble with an opposite command to Ble_Initialize() or a workaround?
 
Thanks in advance,
David.
Tags (4)
0 Kudos
Reply
1 Solution
2,880 Views
nxf56274
NXP Employee
NXP Employee

Hi,

An easy way is to use the software reset. You needn't care anything using this method. Use the function 'ResetMCU'. This function is in file 'Reset.c'

If your data should be kept whatever the mcu's status is, you can try to save the data into flexnvm. 

 

 

 

 

View solution in original post

3 Replies
2,881 Views
nxf56274
NXP Employee
NXP Employee

Hi,

An easy way is to use the software reset. You needn't care anything using this method. Use the function 'ResetMCU'. This function is in file 'Reset.c'

If your data should be kept whatever the mcu's status is, you can try to save the data into flexnvm. 

 

 

 

 

2,867 Views
dvdsosa
Contributor II

Thanks,

As FRDM KW41Z does not have a FlexNVM or driver in the SDK, I see I have to use the functions available in the fsl_flash.c file (https://community.nxp.com/t5/Wireless-Connectivity/FRDM-KW41Z-d-flash-read-write-FlexNVM/m-p/930780)

Is there any example for the KW41Z in the SDK where data is stored and read in the Flash memory using the functions from fsl_flsh.c file? I can't find any.

If not, could you provide a short example of how to do this? I have seen that the NVM start address is stored at NV_STORAGE_START_ADDRESS_C in the linker file.

0 Kudos
Reply
2,853 Views
nxf56274
NXP Employee
NXP Employee

Hi,

You can refer the kw41's pFlash example. Write your data into the free flash.