KW45 Timer Manager issue on BLE beacon example

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

KW45 Timer Manager issue on BLE beacon example

554件の閲覧回数
mattia-morabito
Contributor I

Hi, first some background, i'm using the KW45B41Z Eval Board with SDK version 24.12.00. With this configuration i'm trying to modify the beacon app, in this case by adding a periodic timer.

However i'm having some issues where the timer callback does not trigger and by debugging the application i can see that the program goes into panic for the gAdvertisingCommandFailed_c or the gInternalError_c reason.

The BLE stack has not been modified, the timer initialization is the default one in the PLATFORM_InitTimerManager function (No issues detected there). Afater this in the main i have the following configuration:

// Define the timer manager handle
uint32_t timerHandle[((TIMER_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))];
//support variable to toggle the timer
static bool ledState = true;
// Define a callback for time
void my_timer_callback(void *param) {
    (void)param;  // Explicitly ignore unused parameter
	if (ledState == true) GPIO_PinWrite(GPIOA, 19U, 0);
	else GPIO_PinWrite(GPIOA, 19U, 1);
	ledState = !ledState;
}
...
int main(void)
{
...
    GPIO_PinWrite(GPIOA, 19U, 1);
    /* Start Host stack */
    BluetoothLEHost_AppInit();
    
    timer_status_t checkTM = TM_Open(timerHandle);
    if (checkTM =! kStatus_TimerSuccess){
    	//TODO, Do something if timer manager does not open
    };
    checkTM = TM_InstallCallback(timerHandle,(timer_callback_t) my_timer_callback,NULL);
    if (checkTM =! kStatus_TimerSuccess){
       	//TODO, Do something if timer manager does not open
    };
    my_timer_callback(NULL);
    checkTM = TM_Start(timerHandle,kTimerModeIntervalTimer,1000);
    if (checkTM =! kStatus_TimerSuccess){
        	//TODO, Do something if timer manager does not open
     };

    BleApp_Start();
uint8_t check =  TM_IsTimerActive(timerHandle);
    if (checkTM =! 1){
       //TODO, Do something if timer manager does not open
	 };
...

Here i have omitted the unmodified section of code that are in the beacon example. As far i can tell by following the SDK documentation the timer configuration should be correct so i'm having some issue fixing the error.

Thank you in advance.

0 件の賞賛
返信
3 返答(返信)

528件の閲覧回数
luis_maravilla
NXP Employee
NXP Employee

Hi

 

gAdvertisingCommandFailed_c event is received when advertising could not be enabled or disabled. Reason should be contained in gapAdvertisingEvent_t.eventData.failReason.

 

For the control of Timers Manager and Callback, I will strongly recommend you to check the Connectivity Framework Reference Manual Chapter 3.4

Here is a link for it-> Connectivity Framework Reference Manual

 

Best Regards

0 件の賞賛
返信

507件の閲覧回数
mattia-morabito
Contributor I

Hi!

Thanks for the documentation but it does not reflect the current API, it also lacks any example code. 

It would be great if i could get a feedback on the timer creation and enabling procedure, and if any additional action is required to make the callback work within the OSA Context.

As per the fail reason the reported error is gInternalError_c. however the app still transmit fine. I would also like to add that without starting the BLE app the timer works fine.

Thank you in advance,
Mattia

0 件の賞賛
返信

431件の閲覧回数
luis_maravilla
NXP Employee
NXP Employee

Hi Mattia

 

Sorry for the late response

 

Some recommendations and comments for creating a timer that update with periodic time would be:

-Create a handle using the TIMER_MANAGER_HANDLE_DEFINE and declare and define a timer callback.

-Install Callback (TM_InstallCallback)

-Allocate timer (TM_Open)

-Timer can be started by using TM_Starter

-Review the gAdvertisignStateChanged_c for debug if the device is not advertising.

 

Also, I would strongly recommend using fsl_component_timer_manager.h library implemented in app_advertiser.c and cheking the APIs in \kw45b41zevk_beacon_bm\component\timer_manager\fsl_component_timer_manager

 

For working with OSA context, I would recommend moving to FreeRTOS beacon Example.

 

Best Regards

Luis

0 件の賞賛
返信