This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Need Help! A problem when using TImer1 capture mode of CC2541 with BLE stack running.

Other Parts Discussed in Thread: CC2541

Dear TI Engineer:


        I have a problem when using Timer1 of CC2541(running BLE stack) to measure a external triangular wave drop from 3.3V to 0V. The external droping time can be controlled and the waveform is OK. I use the Capture Mode of Timer1.

       The Clock of Timer1 is set to 32DIV of the system clock, so it's 1us per clk. Since it's a 16bit timer, the measure range is 0-65535us, that is 65ms.

       When the droping time is about 1ms or below, the measure result is accurate and stable. No matter when I start the measurement in my program, the result is always stable. For example, the Timer1 counter result is between 0x0250-0x0258, the error is below 8 us.

       But when the droping time is about 10ms(maybe 2ms, 3ms... the bound is not clear) or above(<65ms, the Timer is not overflow), the meaure result has a great error. For example, the Timer1 counter result is 0x11XX for 2 times and then 0x19XX for 1 time, unregularly. And the measure result is quiet different if I start the measurement in different place in my program.

       I think the problem is revelant with the BLE stack, because when I run the measurement without BLE stack, the result is always right and stable.

       Is it too high for the Timer to run 10ms and something conflict with the BLE stack?

       WIshing for your reply!

       We've stuck here for several weeks and the product deadline is quite near. We need to fix this problem as quickly as possible, or the boss will be mad!

      Yours sincerely,

Frank

  • Hello Frank,

    When you say "without BLE Stack" is this with the BLE stack initialized and/or in a BLE connection? Are you using any timers in your code that are conflicting with Timer1? If you are in a BLE connection, the RF_Isr may be pushing out the processing of your Timer1 interrupt, thus you are seeing a larger error.

    Best wishes
  • Hi JXS,

         Thank you very much for your reply!

         The Timer1 is not used in other places in my code.

         I have now located the problem. When I disable POWER_SAVING, the measurement result is right and stable. When I enable POWER_SAVING, the measurement reasult is wrong and unstable.

         When I start the Timer1, it starts counting, when the time is too long, the OSAL make the MCU into sleep mode(PM2), and the Timer1 is stopped. That's why the measurement result is wrong and unstable.

         Now I disable POWER_SAVING before measurement and enable it after measurement, the result is allright. But since the measurement takes 10ms or even 50ms, and during this, the MCU is active, so it consume a lot of power.The BLE task only takes 2.7ms, so let the MCU be active for 50ms wastes a lot of power.

         Is that any way that I can let the MCU sleep while the Timer1 is still active? According to the PM2 mode, it seems not possible. 

         Do you have any other advie for power saving for my case?

         Thank you very much!

    Frank

  • No, the MCU can not sleep while Timer1 is active. Please see the power management section of the chip user's guide for more information.

    You need to ensure the device stays awake while the timer is running, then you can put it to sleep afterward using:
    (void)osal_set_event(Hal_TaskID, HAL_PWRMGR_HOLD_EVENT);
    (void)osal_set_event(Hal_TaskID, HAL_PWRMGR_CONSERVE_EVENT);
  • Tim C,

          Got it.

          Thank you very much!

    Frank