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

  • 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

  • OK that works so output to the terminal is OK.
    ... and strangely input is now working too.  I must have been mistaken when I first tried this or the port got stuck somehow.

    So we're almost there.  I just need to port this back or, better, my main body of code forward from SDK 12_2.

    What's the best way to review what changes are going to be necessary?

    Many thx.

    Regards, Paul

  • Can you please try the application with another UART terminal? Maybe if you have access to a windows computer, can you try to use the Termite terminal? I also see some weird behavior on Putty, but I am not familiar with the settings in this terminal.

     

    The project is working. If you want confirmation, you can try to connect the UART to something else, like another DK, (pin P0.06 and P0.08), 

    BR,

    Edvin

Reply
  • Can you please try the application with another UART terminal? Maybe if you have access to a windows computer, can you try to use the Termite terminal? I also see some weird behavior on Putty, but I am not familiar with the settings in this terminal.

     

    The project is working. If you want confirmation, you can try to connect the UART to something else, like another DK, (pin P0.06 and P0.08), 

    BR,

    Edvin

Children
Related