This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problem with connection

Hi, I created firmware to nRF51822 Development Kit but I have a problem with connection. PCA10004 board is programmed to advertising packets whole the time and measure battery voltage level every hour (APP_TIMER_PRESCALER 8, BATTERY_LEVEL_MEAS_INTERVAL APP_TIMER_TICKS(3600000, APP_TIMER_PRESCALER)) but from time to time I am connecting with it by USB dongle to read values from services. Everything works fine in short period after flash programing, but there is a problem after few hours or when I leave board to next day because I can't connect with it then. From Master Control Panel i am getting this logs:

[14:58:19.8] ConnectToDevice() [14:58:20.4] ---------------------------- [14:58:20.4] Received Connection Parameter Update Request [14:58:20.4] Connected to device [14:58:20.4] Role: 0 [14:58:20.4] PeerAddressType: 1 [14:58:20.4] PeerAddress (MSB): D2C54EA47F0C [14:58:20.4] Connection Interval: 20.0ms [14:58:20.4] Connection Latency: 0 [14:58:20.4] Supervision Timeout: 3000ms [14:58:20.4] Clock Accuracy: (1) [14:58:20.4] ---------------------------- [14:58:20.4] Connected to D2C54EA47F0C [14:58:20.4] Lost connection to device. Reason: BTLE_REMOTE_USER_TERMINATED_CONNECTION [14:58:20.4] ConnectionParameterUpdateResponse sent with ACCEPTED response [14:58:20.4] Connection Parameters Update sent. ConnInterval:40.0ms, SlaveLatency:0, SupervisionTimeout:4000.0ms [14:58:20.4] SERVER: Received packet <HciEvent: eventCode=0x0A> - <HciEvent: eventCode=0x0A> [14:58:20.4] SERVER: Received Link Loss

I have to make power reset and then everything works fine but after some time the whole situation has repeated. Do you have any idea whan can cause this problem?

Best regards,

P.S. I'm using softdevice 6.0 with SDK 5.1.

  • Hi,

    For the timer issue, you might want to try an change the pre-scaler value.

    The timer resolution with a pre-scaler value of 8 is: (pre-scaler + 1) / 32768 kHz * 1000^2 = x us. (8 + 1) / 32768 kHz * 1000^2 = 274 us.

    The Max RTC overflows at 0x00FFFFFF (0d16777215), thus maximum expiration time that is supported is: 274 us * 16777215 = 4608 seconds

    1 hour = 3600 seconds.

    We have seen an issue where timer has misbehaved when timeout value is > half the Max RTC, in this case > 2304 seconds.

    Try to change the pre-scaler to 14, which will give a timer resolution of: (14 + 1) / 32768 kHz * 1000^2 = 458 us.

    And max timer at: 458 us * 16777215 = 7680 seconds.

    The next SDK release will contain a fix for the app_timer related to start and stopping of the timer and this might fix your issue.

    To identify and reproduce your exact problem we would need more detailed information on how you set up the timers, when they are running and how often they are started and stopped.

    I have also attached an updated app_timer.c file that can be used and which might fix your issue when using timeout value > half max RTC.

    Cheers

    Torsten

    app_timer.c

  • Further information on the RTC Counter, resolution, pre-scaler, and overflow can be found in the nRF51 Series Reference Manual v2.1, section 18.1.2, page 101-102.

    Cheers

    Torsten

  • Hi Torsten,

    Sorry that I reply so late but I had a lot of work. I changed timer prescaler to 4 and decrease timeout value to 20 minutes and everything works fine now. I will also check in free time file which you attachted.

    Thanks for help.

    Cheers Martin

Related