init of one UARTE OK but subsequent UARTE failing in slightly modified example in .../examples/libuarte/main.c

Hi
We'll be adding to a design that uses libuarte/UART0.     I've tested/run the example code and it's fine.  Changing/swapping
index from UARTE0 or 1 works fine as does reassigning TxD/RxD pins from 8 & 6 to others.

So I just made some minor changes and first decided to instantiate both UARTEs, and just to see a test string on both UARTE
outputs.    sdk_config.h  turned on UARTE1   .    Complies w GCC /burns fine.    Runs up to "Here #1" and stops.

[I do not have a debugger setup yet just  JLinkRTTView for logging debug printfs for "Hello #n" progress stamps.]

Are there some configuration options I'm missing/need correction,  esp in  NRF_LIBUARTE_ASYNC_DEFINE(...)    ??
Anything else I can check?

Shouldn't be any resource constraints otherwise.   I'd like to see both UARTEx's  emit something ....   and yes, HWFC
is of course disabled.  Both ports used/configured singly (i.e, commenting out init/usage of the other port) work 100%.


Thanks
Bill
San Jose

--------------------------------------------------------------------------------------------------

Key excerpts:

#include xxxxx  ec.
....

.....
NRF_LIBUARTE_ASYNC_DEFINE(libuarte1,   0,  0, 0,  NRF_LIBUARTE_PERIPHERAL_NOT_USED, 128, 3);
NRF_LIBUARTE_ASYNC_DEFINE(libuarte2,   1,  0, 0,  NRF_LIBUARTE_PERIPHERAL_NOT_USED, 128, 3);
.....

/// two separate copies uart_handler1(), uart_handler2()   - noninterfering w each other, etc

main()

      /// same intro setup (clockcs, etc) as orig code....

       nrf_libuarte_async_config_t nrf_libuarte_async_config[] = {
          // UARTE0
        { .tx_pin = TX_PIN_NUMBER,      // == 0,6
          .rx_pin = RX_PIN_NUMBER,     // == 0,8
          .baudrate = NRF_UARTE_BAUDRATE_115200,
          .parity = NRF_UARTE_PARITY_EXCLUDED,
          .hwfc = NRF_UARTE_HWFC_DISABLED,
          .timeout_us = 100,
          .int_prio = APP_IRQ_PRIORITY_LOW
     },
           // UARTE1
       {  .tx_pin = SER_CON_TX_PIN,     // == 1,13
          .rx_pin = SER_CON_RX_PIN,     // == 1,14
          .baudrate = NRF_UARTE_BAUDRATE_115200,
         .parity = NRF_UARTE_PARITY_EXCLUDED,
         .hwfc = NRF_UARTE_HWFC_DISABLED,
         .timeout_us = 100,
         .int_prio = APP_IRQ_PRIORITY_LOW
         }
       };

 

         dprintf(0,"Here 0\n");

         err_code = nrf_libuarte_async_init(&libuarte1, &nrf_libuarte_async_config[0], uart_event_handler1, (void *)&libuarte1);
         APP_ERROR_CHECK(err_code);
         nrf_delay_ms(25);

         dprintf(0,"Here 1\n");

         err_code = nrf_libuarte_async_init(&libuarte2, &nrf_libuarte_async_config[1], uart_event_handler2, (void *)&libuarte2);
         APP_ERROR_CHECK(err_code);
         nrf_delay_ms(25);

         dprintf(0,"Here 2\n");

         nrf_libuarte_async_enable(&libuarte1);
         nrf_delay_ms(25);

         dprintf(0,"Here 3\n");

         nrf_libuarte_async_enable(&libuarte2);
         nrf_delay_ms(25);

         dprintf(0,"Here 4\n");

         err_code = nrf_libuarte_async_tx(&libuarte1, text, text_size);
         APP_ERROR_CHECK(err_code);
         nrf_delay_ms(500);

         err_code = nrf_libuarte_async_tx(&libuarte2, text, text_size);
         APP_ERROR_CHECK(err_code);
         nrf_delay_ms(500);

         dprintf(0,"Here 5\n");
         .
         .
         .
         .

  • Hello,

    What does 

    err_code = nrf_libuarte_async_init(&libuarte2, &nrf_libuarte_async_config[1], uart_event_handler2, (void *)&libuarte2);
    

    return?

    If you haven't connected the debugger yet (which I suggests you do for help during development), try to print err_code instead of passing it into APP_ERROR_CHECK(err_code);

    Best regards,

    Edvin

  • Edvin,
    I quickly got RTTView setup -   still have to bring up Ozone.    The err_code value for the second 'open' call
    we are discussing: 
     
           err_code = nrf_libuarte_async_init(&libuarte2, &nrf_libuarte_async_config[1], uart_event_handler2,          (void *)&libuarte2);

    is   7  and then Fatal Error.

    BTW, are the parameters of my config at top of code OK for    NRF_LIBUARTE_ASYNC_DEFINE(...)  ??

           NRF_LIBUARTE_ASYNC_DEFINE(libuarte1, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 128, 3);
           NRF_LIBUARTE_ASYNC_DEFINE(libuarte2, 1, 0, 1, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 128, 3);


    When I use 

       NRF_LIBUARTE_ASYNC_DEFINE(libuarte1, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 128, 3);
       NRF_LIBUARTE_ASYNC_DEFINE(libuarte2, 1, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 128, 3);

    the err_code on the 2nd init call is  3  instead and then fatal error.    




    Thanks
    Bill


    RTTView Output:

    00> Here Start
    00> Here 0
    00> err_code = 0...
    00> Here 1
    00> err_code = 7...
    00> <error> app: Fatal error
    00> 


  • Edvin,

    I quickly got RTTView setup -   still have to bring up Ozone.    The err_code value for the second 'init' call
    we're discussing: 
     
           err_code = nrf_libuarte_async_init(&libuarte2,
                                                                   &nrf_libuarte_async_config[1],
                                                                   uart_event_handler2,         
                                                                    (void *)&libuarte2);


    is 7  and then Fatal Error (see below).

    Again, this call works fine if the first call to ...init(....)  is not made and both UARTE0 and 1 work fine separately (if indeed the indexing is working OK in the ...DEFINE macro.


    BTW, are the parameters of my config at top of code OK for    NRF_LIBUARTE_ASYNC_DEFINE(...)  ??

      NRF_LIBUARTE_ASYNC_DEFINE(libuarte1, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 128, 3);
      NRF_LIBUARTE_ASYNC_DEFINE(libuarte2, 1, 0, 1, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 128, 3);


    Thanks
    Bill


    RTTView Output:

    00> Here Start
    00> Here 0
    00> err_code = 0...
    00> Here 1
    00> err_code = 7...
    00> <error> app: Fatal error
    00> 


  • Edvin, 
    Slight changes to declarations 


    NRF_LIBUARTE_ASYNC_DEFINE(libuarte1, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 128, 3);
    NRF_LIBUARTE_ASYNC_DEFINE(libuarte2, 1, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 128, 3);

    result in err_code on 2nd ...init()  call  being 3  instead of  7.

    err_code == 3  :   NRF_ERROR_INTERNAL    (??)

    err_code == 7:     NRF_ERROR_INVALID_PARAM


    My bet is that my parameter setups  in  NRF...DEFINE   are conflicting/screwed up.   





Related