makerdiary / nrf52840-mdk

An Open-Source, Micro Development Kit for IoT Applications using the nRF52840 SoC
https://wiki.makerdiary.com/nrf52840-mdk/
171 stars 42 forks source link

Unable to use User Button on Mbed #27

Closed manchoz closed 4 years ago

manchoz commented 5 years ago

I'm not able to get the User Button working an any Mbed example which makes use of buttons nor in any new program.

Wherever I substitute BUTTONx in examples with p32 or P0_1 I'm not able to read or detect button status.

User Button works seamless on the other examples, such as nrf5-sdk/ble_app_blinky.

Do you have any clue?

Thanks

manchoz commented 5 years ago

At last, I was able to get the USR_BTN working.

The issue is caused by the ITM Trace support enabled by default for MCU_NRF52840 in MbedOS targets definitions.

On the MakerDiary nRF52840-MDK the USR_BTN is connected to the pin P1.00 which is the default pin TRACEDATA0 for the ITM trace port on the nRF52840 MCUs.

MbedOS enables tracing at system initialization if the ITM support is enabled for the target, configuring the pre-defined pins for SWO tracing thus rendering impossibile using the P1.00 button as DigitalIn.

In order to get USR_BTN working on MbedOS you need either to add "device_has_remove": ["ITM"] in targets/targets.json definition or to add "target.device_has_remove": ["ITM"] in nRF52840-MDK overrides in mbed_app.json for your application.

Up-to-date MbedOS with support for nRF52840-MDK is available at https://github.com/manchoz/mbed-os/tree/manchoz_makerdiary-nrf52840-mdk.

I have added support for the nRF52840-MDK also in mbed-os-tools.

@caizelin I'm planning to issue the pull requests to upstream for both repos: please, let me know if you agree.

caizelin commented 5 years ago

@manchoz Looks good to me! Thanks for your PRs.