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

libuarte: Connection between NRF9160dk and NRF52840

Hi,

If there is already a FAQ, Code or support ticket that I missed, I am more than happy to read it.  I have done a number of searches but cant quite get to what I am looking for.

Setup:
I am trying to get communications between the52840 and 9160 on the 9160DK, using libuarte.  I am using zephyr on the 9160 side an the  nrf-sdk on the 52840 side (as I need ANT+).

A few articles I read were using uart1 for this type of communications, so I cut/paste what was in there.  From what I could gather, a way to do this was to use the MCU_IF with pins 17/18 (9160) => 17/20 (52840)

9160 (.overlay file):

&uart1 {
compatible = "nordic,nrf-uarte";
status = "okay";
current-speed = <115200>;
hw-flow-control;
rx-pin = <17>; /* <&interface_to_nrf52840 0 0>; */
tx-pin = <18>; /* <&interface_to_nrf52840 1 0>; */
cts-pin = <19>; /* <&interface_to_nrf52840 2 0>; */
rts-pin = <21>; /* <&interface_to_nrf52840 3 0>; */
};
9160 (main.c)
Device binding is to UART_1:
struct device *uart = device_get_binding("UART_1");

52840 (main.c)

nrf_libuarte_async_config_t nrf_libuarte_async_config = {
        .tx_pin = 17,
        .rx_pin = 20,
        .baudrate = NRF_UARTE_BAUDRATE_115200,
        .parity = NRF_UARTE_PARITY_EXCLUDED,
        .hwfc = NRF_UARTE_HWFC_DISABLED,
        .timeout_us = 100,
        .int_prio = APP_IRQ_PRIORITY_LOW};

Question:

I can get all of this to work (or appears to) when I;
* start the 9160
* move sw to nRF52
* build->debug from SES
 -> click the green run button

* This appears to do everything correctly, receives ANT+, transmits from 52840 to 9160 and I can see it display on the 9160 tty port (using screen).

If I do it any other way, its as if the code on the 52840 is not running, or there is a problem with the connection or a timing issue ?

I added a nrf_delay_ms(5000) at the start of the 52840 code, just in case there was a timing issue between the 9160 and 52840 in that the UART was not ready - but that didnt work.

What am I missing here ?
I feel I have done every possible combination of switches, power and reset, but the only way I can get it to work is if I use SES Build->Debug 

thanks in advance

-brett

Parents
  • Hi Brett,

    On the 52840 side, could you try to call sd_clock_hfclk_request() after enabling the Softdevice? This will make the Softdevice keep the HF crystal oscillator (HFXO) on and in turn increase the accuracy of the UART baudrate generator (it runs off the less accurate HFINT clock by default). I think it's worth trying since you seem to get more stable performance when you keep the chip in debug mode.

    I will try to see if I can replicate it here if the above doesn't help.

    Best regards,

    Vidar

  • Hi Vidar,

    No difference.  It still works in debug mode but fails otherwise.

    -brett

  • Hi Vidar,

    It worked on the nrf9160df_nrf9160, and after I copied the overlay to nrf9160dk_nrf9160ns.overlay it works as well.  (note: I used nrf9160dk_nrf9160ns and not nrf9160dk_nrf9160_ns).

    I will work from this to see if I can work out what the differences are.

    cheers

    -brett

  • Hi Vidar,

    Your code by itself works fine, so I have tried to identify any differences between them.

    Both lots of settings basically the same now (not identical as I have softdevice/ANT+ code) and the same thing happens, I can run the code in SES-Debug mode and all works, but as soon as I just run or power cycle the unit, I dont get the data through.

    Q: I am using the s340 soft device, doest that influence the clock or timers I need to use ?

    Q: Does the SES debug provide clock differently than not using it ?

    The obvious difference I have between the 2 code bases is below, hence the reason for my timer/RTC question.

    Mine:

    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 1, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 4);

    Yours:

    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

    cheers

    -brett

  • Hi Brett,

    Your configuration looks fine. You have to select TIMER1  like you did as TIMER0 is reserved to the Softdevice.

    Brett said:
    Q: I am using the s340 soft device, doest that influence the clock or timers I need to use ?

    The only difference is that you can't use TIMER0 like mentioned above.

    Brett said:
    Q: Does the SES debug provide clock differently than not using it ?

    The HF clock is kept always on while in debug mode, but you will get the same effect by calling sd_clock_hfclk_request()  like I suggested in my initial reply. So I don't think the issue is clock related.

    Have you enabled flow control on the 52840 side like I did in my example? I noticed you only had it on the 9160 in the initial code you posted. In that case, do you get a "busy" error if you try to send data from the 9160?

    Cheers,

    Vidar

  • Hi Vidar,

    For now I am only trying to send data from the 52840 to the 9160 - so the flow-control should not be an issue ?

    I have attached the code that I have, if you are able to try this on your board to see if it works for you, and/or if there is something obvious I have missed.

    Note; This code is a cut/paste from one of the BLE examples which I have not completely cleaned up yet.
    This code has also been cut down to send `1` every 5 seconds over the UART connection, so your 9160 receiver should be able to get the message and log it.

    cheers

    -brett

    app_libUARTE.tar.gz

  • Hi Brett,

    I have to spend some more time on this, unfortunately. I realized that my UART implementation on the 9160 isn't working properly either when I started testing with your example. Will try to get you an update tomorrow.

    Cheers,

    Vidar

Reply Children
Related