BCM20737S HW timer problem

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
huangj
Level 4
Level 4
Welcome! 25 replies posted 10 replies posted

Hi BRCM FAE,

I tried to implement the hw timer in mybeacon sample code.I have already read the thread:Hardware Timer (hw_timer.h) usage  & How to use 100us interval timer?

I modify the mybeacon like this:

1.include "hw_timer.h"

2.register callback in the mybeacon_create

void mybeacon_create(void){

          hw_timer_register_timer_expired_callback((HW_TIMER_EXPIRED_CALLBACK_FN)timer2_timeoutCallback);     

          hw_timer_start(100000);                                   

}

3.add callback function

void timer2_timeoutCallback(void){

          puart_print("A");                         //debug trace

          hw_timer_start(100000);

}

4.add APP_PATCHES_AND_LIBS += hw_timer.a to my makefile

5. disable sleep => modify BCM20737A1.cgs

ENTRY "Sleep Mode Configuration"

{

    "Sleep mode" = "HIDD"

    "Sleep enable" = 0

}

The callback is not called,and I can't see any debug trace in the PUAT.

Can anyone verify if I am doing something wrong here?

Any help is appreciated.

Thank you.

Jack

0 Likes
1 Solution
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Got it working on my end. Your original method of disabling sleep is perfectly fine, but pay attention to those make targets.

The problem was in your callback. In addition to the steps you've outlined above, declare:

     extern void hw_timer_int_handler(void);

And use it as you callback:

     hw_timer_register_timer_expired_callback((HW_TIMER_EXPIRED_CALLBACK_FN)hw_timer_int_handler);

    

     void hw_timer_int_handler(void){

          ble_trace0("timer fire");

          hw_timer_start(100000);

     }

Jacob

View solution in original post

6 Replies
BoonT_56
Employee
Employee
500 likes received 250 likes received 100 likes received

i recalled reading somewhere that the sleep must be disabled in order for the hw timer to work. can you try it out?

0 Likes

Hi boont

Thank you for your comment.

I have already disabled sleep.

1.disable sleep => /Platforms/BCM920737TAG_Q32/BCM20737A1.cgs

ENTRY "Sleep Mode Configuration"

{

    "Sleep mode" = "HIDD"

    "Sleep enable" = 0          // =>change to 0,it mean disabled sleep.

}

2.And I also comment this line in mybeacon_create:

//bleapputils_changeLPOSource(LPO_MIA_LPO, FALSE, 500);

But the timer callback still not trigger.

I have another question. Does the hw timer need 32KHz oscillator?

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

What make target are you using to build? If you only changed the cgs of BCM20737A1 but then build using BCM920736TAG_Q32 as the target, the final application-specific cgs will not be changed. You can go into the build folder afterward and check the cgs that the device actually received.

I've never personally used the cgs method to disable sleep, so I can't speak on it's behavior, but you can try the other methods outlined in this post to disable sleep at runtime (which is what most implementations use):

Sleep Deep_Sleep Explanation and Techniques

Jacob

0 Likes

Hi Jacob,

Thanks for ur response.

Here is my target:

mybeacon-BCM920737TAG_Q32 download  BT_DEVICE_ADDRESS=123456DD00FF UART=COM38

I also check the cgs files in the build folder (build\mybeacon-BCM920737TAG_Q32-rom-ram-Wiced-release\A_20737A1-mybeacon-rom-ram-spar.cgs, and the sleep is disabled.

but you can try the other methods outlined in this post to disable sleep at runtime

>I add this function to mybeacon, but the hw timer is still not trigger.

UINT32 ws_upgrade_uart_device_lpm_queriable(LowPowerModePollType type, UINT32 context){

     return 0;

}

Jack

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Got it working on my end. Your original method of disabling sleep is perfectly fine, but pay attention to those make targets.

The problem was in your callback. In addition to the steps you've outlined above, declare:

     extern void hw_timer_int_handler(void);

And use it as you callback:

     hw_timer_register_timer_expired_callback((HW_TIMER_EXPIRED_CALLBACK_FN)hw_timer_int_handler);

    

     void hw_timer_int_handler(void){

          ble_trace0("timer fire");

          hw_timer_start(100000);

     }

Jacob

Hi Jacob,

I tried using your methods, and the hw timer work fine.

Thanks for your help.

Jack