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

APP_UART_FIFO_INIT returns NRF_ERROR_INVALID_STATE (error 0x00000008

I have been looking into the ble UART example a bunch trying to incorporate it into the ble blinky example.

I keep getting an NRF_ERROR_INVALID_STATE error when calling APP_UART_FIFO_INIT.

I have looked at a couple examples:

https://devzone.nordicsemi.com/f/nordic-q-a/19767/app_uart_fifo_init-crashes

https://devzone.nordicsemi.com/f/nordic-q-a/4399/sending-via-uart

I believe I have the app_uart_fifo.c file linked correctly as this is the file that is called when debugging (see the second link).

The first link was interesting because it suggests that it's possible for the code to execute twice. I don't know where or how this would be the case.

I can trace the call stack all the way to where I am getting the error but I am a little uncertain as to what I can do once I am there.

Where the error code is coming from:

p_cb->state says it is already set to NRFX_DRV_STATE_INITIALIZED

Call stack:

The documentation says that if NRFX_ERROR_INVALID_STATE is returned then the "driver is already initialized". I don't get how this can be unless it has already been called thus asking the question of how it could be called multiple times. 

Any thoughts would be helpful.

Thanks!

documentation: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Fgroup__nrfx__uarte.html

  • how it could be called multiple times

    What IDE are you using? Does it have a 'Show References' feature?

    Or just do a plain text search through your project.

    Or set a breakpoint in the function, and see where it returns to ...

    EDIT

    Or, why not just treat this as a SUCCESS case? 

    You wanted it initialised; the return code tells you that it is initialised  - QEF!

  • Awneil,

    So your answer led me to the fix it seems. When I did a global search for APP_UART_FIFO_INIT only one came up, but I noticed that when I searched for uart_init that it came up several times. It seemed to be used a lot within nrf_log_backend_uart.c and is eventually calling the same function that was breaking the code at runtime. This eventually led me to comment out NRF_LOG_DEFAULT_BACKENDS_INIT within my log_init function as I don't really need that.

    I might look into why that is happening as it was kind of a helpful function to have but it's not mission critical. 

    Looking at the ble uart example in v15 it looks like they are using both and it is working just fine. I haven't spent the time looking at this part yet to see why they both work in the example and not my project but if you have an idea as to why this might be the case I would be interested to hear.

    I am currently using Segger Embedded Studio.

    Thanks for your help!

  • Again, if you want it enabled, then the NRFX_ERROR_INVALID_STATE result is not an error - it just indicates that it is already in the state that you wanted!

    QEF.

Related