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.

How to ensure the Timer3 ISR executed in time(RF ISR prior to it, CC2541 )?

Other Parts Discussed in Thread: CC2541

hi everyone,

    I'm trouble with this simple problem:(CC2541)

    I'm using the Timer3 to generate 50ms event ( toggle an IO for test) (osal_start_timerEx have about 10ms error, abandon it)

    In fact, it toggle every ~200ms, and in the oscilloscope, it is not periodic at all.

    And then, I increase Timer3 ISR's priority, just let it prior to RF ISR:  

        IP0 |= BV(3);
        IP1 |= BV(3);

    And it toggled accurate every 50ms.

    While the new problem come:

    As I increase Timer3 ISR's priority prior to RF ISR, the RF function(Observer) is affected:

        CC2541 may can't hear anything after power on.(probability is about 1/50, I have 64 nodes to test it)

        It didn't happened before I increase Timer3 ISR's priority.

   Both of 50ms event and Observer function is important in my application, and how to solve this dilemma?

  • Hello,

    If you are conflicting with the RF_ISR, then you will expect to see incorrect BLE stack behavior. Are you running Timer3 ISR at or higher priority than RF_ISR?

    Best wishes
  • hi, JXS, in brief, my problem is :
    1. If T3_ISR < RF_ISR, 50ms event isn't accurate
    2. If T3_ISR > RF_ISR, Observer function will failure with a small probability(~1/50)
    3. Both of 50ms event and Observer function is necessary
    How to solve this dilemma?
  • If you require time critical output toggling, I would suggest using the PWM function of the timer with the output CCP pin if possible. This should avoid ISR conflicts.

  • Hi, CM2015,
    toggling IO is just a simple test, and I need to do a series of operations every 50ms(accurate 50ms).
  • Hi Caize,

    this might be difficult on the cc2541 while the radio is active since it appears that the stack stops the mcu and adjusts the clock divider ratio periodically.. See this thread: The cc26xx devices may be more suited to your purpose but I'd wait for a TI employee to come say for sure. 

  • In fact, if RF_ISR > T3_ISR, IO toggles every 50~200ms , it means RF_ISR takes more than 1ms(T3 int@1ms)?
    Is it means CC2541 is not suitable for real time application?
  • push up..........
  • Hi,

    If the timing is important you should definitively disable HaltOnRf, as CM2015 mentions, otherwise the tick generation could be all over the place.

    However, with multiple ISR's firing off at any one time, it may not be suitable to use ISR for toggling the GPIO because there's going to be jitter or disturbances either way. Although if Timer 3 has higher priority than RF and the T3 ISR is short I don't see why there should be a problem, because the RF isr timing isn't _that_ critical. Of course, you also increase the UART interrupt priority so that could be a problem.

    If the only thing you need is a 50ms toggle, you can look into using PWM output from Timer 1. If you select clock divider 128, the timer gets a tick every 4 us. There are 12,500 4us periods in 50ms. So that should work.

    BR,
    Aslak
  • I have already disable HaltOnRf, otherwise even PWM will be affected.
    I will test disable UART to make sure if UART_ISR have some thing to do with this problem.
    Toggle IO is just a test, I need update some parameters every 50ms, so it's nothing to do with PWM output.
    Thank you all the same.