Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART and Timer conflict

I am using SDK12 with nrf52832.  UART working fine (with FIFO)  and Timer1 also works.

I wanted to set a 1 minute timeout around the UART dialog to handle disconnection etc. 

However, if I enable Timer1 when waiting for a response from the UART the timer responds as expected but the responses from the UART no longer occur.  Specifically, the UART's event handler is no longer called.

This looks like some kind of a conflict but I'm not sure where and why?

Thx.

Parents
  • Hello,

    What SDK version do you use? Is the problem that the event handler does not get called? If you could attach the project, I could take a look at it.

     

    Best regards,

    Edvin

  • Could you please check the file I added for ?

    If not, could you specify the issue? 

     

    BR,

    Edvin

  • Thx @Edvin and sorry for my delay in replying.

    OK. Finally got some time to look into this but having issues with compilation.

    I put your code in a copy of examples/uart.

    Using SDK14 for pca10040.

    I took the config from examples/uart
    + added to Makefile: $(SDK_ROOT)/components/drivers_nrf/timer/nrf_drv_timer.c \

    I get...

    In file included from ../../../../../../components/libraries/util/app_error.h:58:0,
    from ../../../main.c:26:
    ../../../../../../components/libraries/experimental_log/src/nrf_log_internal.h:105:38: error: pasting "m_nrf_log_" and ""APP"" does not give a valid preprocessing token
    #define NRF_LOG_MODULE_DATA CONCAT_3(m_nrf_log_,NRF_LOG_MODULE_NAME,_logs_data)
    ^
    ../../../../../../components/libraries/util/nordic_common.h:133:31: note: in definition of macro 'CONCAT_3_'
    #define CONCAT_3_(p1, p2, p3) p1##p2##p3

    Presumably there are other things i need to do to my config?

    May I have a copy of the config file you are using pls and anything else I need to change.

  • Did you include the path to the nrf_drv_timer.h file? Also, did you enable the timer in sdk_config.h?

    There are many things that are changed between SDK12 and SDK14, so I don't think you will be able to run the main.c code here in SDK14. I changed some parts (removed the SPI) and changed sdk_config.h, which decides what peripherals that are activated.

    uart+timer.zip

    Try to unzip the attached project so that you get the path:

    SDK14.0.0\examples\peripheral\timer+uart\pca10040\armgcc\makefile

    Then run cmd from the armgcc folder, and run:

    "make clean && make -j3 && nrfjprog -e && nrfjprog --program _build\nrf52832_xxaa.hex --verify && nrfjprog --reset"

    When the DK is connected. You should see that LED1 starts blinking, and it should echo everything it receives on UART (using the USB and a UART terminal).

  • Thx Edvin,

    (I did include the path to nrf_drv_timer.h but never mind)

    I am now using your latest setup.

    It compiles OK and the timer is working

    However, for some reason the terminal is not echoing.  I'm using macos screen at 115200.

    (I have wondered in the past whether this a reasonable way to work with the pca10040 uart?)

    So I commented out timer_int() and then the terminal works.

    This is telling me that the timer/uart conflict remains

    Regards, Paul

  • do you have any settings on your terminal?

    In my UART terminal, I have:

    115200 Baudrate,

    8 data bits,

    1 stop bit,

    parity none,

    flow control none

    Append LF (this one shouldn't matter)

     

     

    If you try to change the timeout handler to this, will you see the '1's printed on the terminal then?

            case NRF_TIMER_EVENT_COMPARE0:
                NRF_TIMER4->EVENTS_COMPARE[0] = 0;
                nrf_gpio_pin_toggle(US_TSET_PIN);
    			uint8_t cr = '1';
    			while (app_uart_put(cr) != NRF_SUCCESS);
                break;

     

    BR,

    Edvin

Reply
  • do you have any settings on your terminal?

    In my UART terminal, I have:

    115200 Baudrate,

    8 data bits,

    1 stop bit,

    parity none,

    flow control none

    Append LF (this one shouldn't matter)

     

     

    If you try to change the timeout handler to this, will you see the '1's printed on the terminal then?

            case NRF_TIMER_EVENT_COMPARE0:
                NRF_TIMER4->EVENTS_COMPARE[0] = 0;
                nrf_gpio_pin_toggle(US_TSET_PIN);
    			uint8_t cr = '1';
    			while (app_uart_put(cr) != NRF_SUCCESS);
                break;

     

    BR,

    Edvin

Children
Related