Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 9 months ago.
Disabling UART Instance at compile time.
Is there a configuration setting for the NRF52 in the targets folder or targets.json, where I can disable the UART interface at compile time. i,e, when I build my application using mbed-cli can I turn off this feature. Currently in my application I do call a method to disable the UART, however I am not sure if this takes effect, once the application is running even though its the very first line of code, in my application.
disabling UART
#include "nrf_uart.h" #define UART_INSTANCE NRF_UART0 int main() { nrf_uart_disable(UART_INSTANCE); ....... }
Thanks, Ajay.
Question relating to:
1 Answer
5 years, 9 months ago.
Hi Ajay,
You shouldn't have to manually disable the UART, but if you do want to remove the UART capability you can modify the targets.json file for the MCU_NRF52832 target. You will want to remove the following from the "device_has" list:
- "SERIAL",
- "SERIAL_ASYNCH",
- "SERIAL_FC",
We haven't tested that ourselves so hopefully that won't cause a problem.
Additional information on target configuration is available here:
Regards,
Ralph, Team Mbed
Thanks a lot Ralph for taking the time to respond. I will give what you have suggested a shot.
After looking at the mbed-os 5.5.4 I noticed that in the file mbed-os\targets\TARGET_NORDIC\TARGET_NRF5\TARGET_MCU_NRF52832\sdk\nrf_drv_config.h has the following #define
- define UART0_ENABLED 1
would setting that to 0 disable the UART0 instance?
Thanks, Ajay
posted by 27 Jul 2018Hi Ajay,
Newer SDKs don't have nrf_drv_config.h but I revisited Mbed OS 5.5.4 and defining UART0_ENABLED to 0 will prevent Mbed from building. Likewise, removing the three features from targets.json we called out above also will prevent Mbed from building due to some test infrastructure that utilizes the serial interface. Unless you are enabling the UART or using the serial console for printf() the UART will be disabled.
posted by 31 Jul 2018