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

ble_uart example with custom uart ISR

while the ble_uart example is a great resource of information, i have a need to completely separate the ble nus data in / out from the hw uart code

using sdk 14.2.0

i was able to put my own queue-ing code in between ble nus and hw uart and manage the data transfer control within main just for test purpose

basically the hw uart will get fed by one part of the application whereas the ble nus communication will come from a completely different part of the app

having said this, why do i need to use the s132 softdevice uart code at all including the s132 isr support for it ... my app uses the hw uart just as a data in / out device and i have already very efficient code for it being used in multiple arm based apps for years

the ble nus data portion would be the way the app communicates to the outside world and code for desktop and android devices is already existing and tested

to clarify this : i need the ble nus portion and it works great so far ... however i want to run my own hw uart code with my own uart rcv and xmt isr functs

what i tried so far was to disable the following in app_config.h

#define UART_ENABLED 0
#define UART0_ENABLED 0

#define APP_UART_ENABLED 0

with the result of a hardfault caused in nrf_sdh.c line 232

ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler);

producing an 0x1001 error NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION

what am i missing or what went wrong ???

without any suggestions or assistance i will be completely lost

the whole softdevice and all the supporting code surrounding it are great, but for a, to me simple task, it's impossible to figure out what's wrong and how to proceed

what's the proper way to disable or take out the hw uart portion from the softdevice support and use custom hw uart code with isr support

  • Hi,

    I tried to walk in your footsteps and disabled the UART0 from the ble_app_uart example and removed everything UART HW related. It seemed to work fine for me.

    Have you seen the documentation for sd_softdevice_enable()?

    NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION:

    SoftDevice interrupt is already enabled, or an enabled interrupt has an illegal priority level.

    Have you made sure to use legal interrupt priority levels in your custom UART driver?

  • thanks Martin :

    i have some issues with the way i ripped the main.c apart and split it into a simple main.cpp/h and ble.cpp/h ... still trying to figure out what's wrong with my code

    i was able to confirm your observation

    i use a managed eclipse project where i put the necessary sdk files into a static lib i link to, which works, since all i needed to do was replacing my Main.cpp/h and Ble.cpp/h with the original example main.c

    had more time to dig through my code and it turns out that i do some hw inits in my uart ctor and since the ctors are all being called before the code in the softdevice, it didn't like it

    to be more precise ... it was setting up the nvic for the uart in the ctor was the issue

    thanks for your answer

Related