app_timer problem

Muntaek Kim gravatar image

asked 2017-07-17 07:05:51 +0100

joh2 gravatar image

updated 2017-07-17 13:16:05 +0100

Hellow,

I'm using app_timer to play the buzzer.

The default behavior is

1. key in
2. timer start: 8Sec for key action stop check
3. Buzzer on (pwm1)
3. buzzer timer start
4. Buzzer timer stop.
5. buzzer off

The odd thing is 1. Abnormal termination of the timer occurs. - The 8 second timer in process 2 is terminated as soon as it starts. - Due to this phenomenon, abnormal operation of the buzzer makes the overall wrong operation.   Below is a log message. The current issue is being debugged for a few days now. Help is urgently needed.

Thank you.

// *** normal message ***
 0> key in : touch 1
 0> key action : touch 1
 0> *** timer - normal start ***
 0> buzzer start
 0> buzzer timer start : 0
 0> pwm-buzzer uninit error : 0
 0> pwm-buzzer init error : 0
 0> pwm-buzzer enable
 0> pwm-buzzer duty set
 0> *** sleep ***
 0> buzzer timer stop : 0
 0> timer handler
 0> buzzer timer start : 0
 0> pwm-buzzer uninit error : 0
 0> pwm-buzzer init error : 0
 0> pwm-buzzer enable
 0> pwm-buzzer duty set
 0> *** sleep ***
 0> buzzer timer stop : 0
 0> timer handler
 0> buzzer stop
 0> *** sleep ***


// *** abnormal message ***
 0> key in : touch 1
 0> key action : touch 1
 0> *** timer : normal start ***
 0> buzzer start
 0> *** timer : normal end ***      --->>> abnormal timer stop !!!!!!!
 0> buzzer start               
 0> buzzer timer start : 0
 0> pwm-buzzer uninit error : 0
 0> pwm-buzzer init error : 0
 0> pwm-buzzer enable
 0> pwm-buzzer duty set
 0> buzzer timer stop : 0
 0> buzzer timer stop : 0
 0> timer handler
 0> buzzer timer start : 0
 0> pwm-buzzer uninit error : 0
 0> pwm-buzzer init error : 0
 0> pwm-buzzer enable
 0> pwm-buzzer duty set
 0> buzzer timer stop : 0
 0> timer handler
 0> buzzer stop
 0> buzzer timer start : 0
 0> pwm-buzzer uninit error : 0
 0> pwm-buzzer init error : 0
 0> pwm-buzzer enable
 0> pwm-buzzer duty set
 0> *** sleep ***
 0> *** sleep ***

--->>> another buzzer start when time stopped : not acceptable !!!

edit retag flag offensive close delete report spam

Comments

Which SDK version are you using? Can you upload some code, showing timers/button setup and how you start timers and buzzer?

Jørgen Holmefjord ( 2017-07-17 13:18:24 +0100 )editconvert to answer

Hello, I use SDK 12.1.0. My co-worker experienced the same problem in the different project. If you are OK, I want to send my code all via e-mail.

air ( 2017-07-17 13:24:47 +0100 )editconvert to answer

uint32_t initKey(void) { uint32_t err_code;

    if(!nrf_drv_gpiote_is_init())
    {
        err_code = nrf_drv_gpiote_init();
        VERIFY_SUCCESS(err_code);
    }

    // touch int
    nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_HITOLO(false);
    config.pull = NRF_GPIO_PIN_PULLUP;
    err_code = nrf_drv_gpiote_in_init(ADS16_INT_PIN, &config, handler_touchIn);
    VERIFY_SUCCESS(err_code);

/*
    // tact s/w int
    config.pull = NRF_GPIO_PIN_PULLUP;

    err_code = nrf_drv_gpiote_in_init(KEY0_PIN, &config, handler_tactIn);
    VERIFY_SUCCESS(err_code);
    err_code = nrf_drv_gpiote_in_init(KEY1_PIN, &config, handler_tactIn);
    VERIFY_SUCCESS(err_code);
    err_code = nrf_drv_gpiote_in_init(KEY2_PIN, &config, handler_tactIn);
    VERIFY_SUCCESS(err_code);
    err_code = nrf_drv_gpiote_in_init(KEY3_PIN, &config, handler_tactIn);
    VERIFY_SUCCESS(err_code);
    err_code = nrf_drv_gpiote_in_init(KEY4_PIN, &config, handler_tactIn);
    VERIFY_SUCCESS(err_code);
    err_code = nrf_drv_gpiote_in_init(KEY5_PIN, &config, handler_tactIn);
    VERIFY_SUCCESS(err_code);
    err_code = nrf_drv_gpiote_in_init(KEYSTAR_PIN, &config, handler_tactIn);
    VERIFY_SUCCESS(err_code);
*/
    return NRF_SUCCESS;
}

void handler_touchIn(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    bool err_code = true;
    uint8_t writeBuf[1];

//  UNUSED_PARAMETER(p_context);
    NVIC_ClearPendingIRQ(GPIOTE_IRQn);

//  holdTouch(HOLD_TOUCH);
//  ENABLE_TWI;
    __NOP;
    __NOP;
    __NOP;
    __NOP;
    __NOP;

    // touch data read
    if(!nrf_gpio_pin_read(ADS16_INT_PIN))               // int recheck
    {
//      accessTouch(STOP);
//      timerScanTouch(START);

        writeBuf[0] = 0x10;                                 // touch data start address
        err_code &= twi_master_transfer(ADS16_WRITE_ADDR, writeBuf, 1, TWI_ISSUE_STOP);
        err_code &= twi_master_transfer(ADS16_READ_ADDR, touchVal, 4, TWI_ISSUE_STOP);

        // error check
        if(err_code == true)
        {
            fkeyScanNeed = 1;
            fkeyInType = TOUCH_IN;
        }
    }
//  DISABLE_TWI ...
(more)
air ( 2017-07-17 13:28:34 +0100 )editconvert to answer

Could you try updating to SDK 13.0.0? There was a bug in app_timer, which should be fixed in the latest SDK. If you do not want to share your code in public, you can create a private case on MyPage, with a link to this thread. The information on MyPage is threated confidentially.

Jørgen Holmefjord ( 2017-07-17 13:32:48 +0100 )editconvert to answer

I can't log in. I don't know why? I wonder if there is any other way to send the my code. Also, in SDK13.0.0, I wonder if I can modify only the app_timer related part or not. It is because there is not enough time to fix it all.

Thanks.

air ( 2017-07-17 14:01:01 +0100 )editconvert to answer

Do you get an error? You should be able to use app_timer from SDK 13 in SDK 12.1, but it will require some modifications to get it working, as there are some changes related to configuration etc.

Jørgen Holmefjord ( 2017-07-17 15:21:52 +0100 )editconvert to answer

I tried SDK13.0.0 app_timer in my project(SDK 12.1.0). The result was same. I use nrf51822. SDK13.0.0 cannot be used fully. I want to know what the bug is specifically. Would you let me know where to modify in SDK 13.0.0 app_timer?

air ( 2017-07-18 03:44:01 +0100 )editconvert to answer

The bug is described in the link I provided above. It can cause timers to be stopped and restarted at wrong time. You can also try the app_timer.c in the link, as this is changed for SDK 12.2.

Jørgen Holmefjord ( 2017-07-19 13:27:30 +0100 )editconvert to answer

I tested my code with SDK 12.3.0. The results were the same. It shows abnormal symptoms when APP_TIMER_PRESCALER is set to 0. But, Setting APP_TIMER_PRESCALER to 15 seems to be fine now. This does not seem to be a fundamental solution. I am always worried about this problem because I am confused with other problems.

air ( 2017-07-22 08:38:42 +0100 )editconvert to answer

Unfortunately SDK 12.3.0 does not include the app_timer bug fix.

Jørgen Holmefjord ( 2017-07-25 16:25:07 +0100 )editconvert to answer