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

Porting example about twi and HID keyboard

Hi, all.

I want data read from gyro sensor through i2c, and then send it through bluetooth equipment.(PC or iPhone and so on) My development environment is like below.

  • chip : nRf51822
  • example version : nRF_Example 10.0.0
  • pack version : check the attached file(pack_list.PNG)
  • Applied "RTT source" for debugging. have no uart port on the board. : devzone.nordicsemi.com/.../

At first, i did test like below.

  • [ble_app_hids_keyboard] : operation check completed.
  • [twi_sensor] : operation check completed
  • [twi_master_using_app_twi] operation check completed
  • [ble_app_hids_keyboard + twi_sensor] : operation check completed
  • [ble_app_hids_keyboard + twi_master_using_app_twi] : Error occured => I want this feature.

Source build is ok. But when excute the program, it does not working. I guess the problem is for "rtc_config()" function, but it is not sure.

main function is consist of like below: image description

Plseas kindly comment for resolving this issue.

  • It would be much easier for us to help you if you post your code as text or, even better, your project files. Please at least post the files/code containing your clock and TWI configurations. Have you looked for asserts in your code?

  • Thanks for your comment. Please check attached code and project files. I'm not sure what you want it. ^^; And if you need more information, tell me anytime.

  • By project files I meant all the .c and .h files you use in addition to the files you posted. The reason I want those is that it will make it much easier and faster for me if I can compile your code myself and navigate around your project and debug it. The more information and specific details you can provide the faster you will get help. "Error occured => I want this feature", for example, tells me little to nothing. Especially when I don't have any files to debug on. So:

    1. Why do you suspect rtc_config() is causing the issue?
    2. Can you provide me with more details about the occurring error?
    3. Are you able to debug you code yourself, maybe using the APP_ERROR_CHECK() macro like described here?
    4. Can you provide the rest of you code?
  • Hi, Martin.

    Thanks your reply and understood means about "project files". So attached "project files" all of them.

    1. : When i remove "rtc_config()", my board can connect bluetooth equipment. But can not read data from gyro sensor.
    2. : When excuted my source code, just stop the board. Not operated.
    3. : No, i didn't use it.
    4. : Sure, re-attached files. (file name : ble_app_hids_keyboard_by_GON.zip)
  • I think your problem is similar to this case. Your application is already using the app_timer library and this library uses RTC1. Then you use nrf_drv_rtc to set up your own timer. This driver also use RTC1 and this will cause a conflict and unpredictable behaviour. You might already be aware that the Softdevice blocks the access to RTC0 so you can't set up the driver to use this timer either. Hence I think the best solution for you is to set up additional timers using the app_timer library as well. It is pretty easy, just look at the code in timers_init() and timers_start() in main.c and then create a new timer id variable and use the app_timer_create() and app_timer_create() functions.

Related