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

TWI and UART

Situation: SES, SDK 16, nRF52832, no BLE.

I'm trying to use both the UART and TWI 0. TWI works fine with BLE and all the rest. However, when I enable the UART, TWI quits working but the UART works just fine.

1) I checked instantiation - the two do not share.

2) UART and UARTE both enabled in sdk_config.h as in peripheral/uart example.

3) Using app_uart_fifo per the demo.

4) You can't compile the legacy stuff required without UARTE enabled, there's a compile time error.

Where to start?

  • Hello,

    That does sound strange. Right off the bat my suspicion is that they share a define/buffer/instance or pin, which the enabling of UART overwrites control of.
    Which pins are you using for both the UART and TWI?

    when I enable the UART, TWI quits working but the UART works just fine.

    Could you also tell me some more about the behavior you are seeing? How do you determine that the TWI has stopped working?

    1) I checked instantiation - the two do not share.

    How did you check this? I am just asking this to be sure before ruling it out.

    3) Using app_uart_fifo per the demo.

    Are you working with a modified version of the UART peripheral example, in which you have added TWI as demonstrated in the TWI Scanner example?
    If you are, please elaborate on what modifications and additions you have made to the exampe.
    Please correct me if I am wrong.
    For the record, are you implementing a TWI slave or master on your device?

    4) You can't compile the legacy stuff required without UARTE enabled, there's a compile time error.

    This is interesting. Could you elaborate on what you mean by "legacy stuff" and which compile time error you are getting?

    Looking forward to resolving this issue together,

    Best regards,
    Karl

     

  • I can't answer all because some things got fixed and I moved on.

    1) I think I enabled TWI before the UART during failure. Initializing the UART first and now it seems to work. This is a guess as other stuff has changed.

    2) Instantiation was checked through the nRF52832 chip manual to make sure (TI has this problem with shared serial peripherals).

    3) Yes, using the peripheral demo and TWI as master from some other example. The TWI worked fine until I added the UART. And for the record, not a slave and not multi-master.

    4) I tried to run the UART direct without the FIFO and UARTE but always got an undefined typedef in one of the uart.h files (I forget which). I assume that with the FIFO enabled you need UARTE? Is there anyway of just running the raw UART without DMA?

    This is another mysterious problem that went away but I'm not sure why and this seems to happen a lot.

  • Hello again,

    Jed Marti said:
    I can't answer all because some things got fixed and I moved on.

    I am happy you were able to resolve some of your issues.

    Jed Marti said:
    2) Instantiation was checked through the nRF52832 chip manual to make sure (TI has this problem with shared serial peripherals).

    Yes, resource sharing like this is quite common - but which TWIM instance did you use?
    TWIM0 and UARTE0 share the same IRQ, so if you used both of these that might be the cause of this.

    Jed Marti said:
    4) I tried to run the UART direct without the FIFO and UARTE but always got an undefined typedef in one of the uart.h files (I forget which). I assume that with the FIFO enabled you need UARTE? Is there anyway of just running the raw UART without DMA?

    Yes, you may use just the UART peripheral, without the UARTE peripheral.
    You can disable both UARTE and UART easyDMA in the UART peripheral example with the following lines:

    #define UARTE_ENABLED 0 
    #define UART_EASY_DMA_SUPPORT 0 
    #define UART0_CONFIG_USE_EASY_DMA 0


    Jed Marti said:
    This is another mysterious problem that went away but I'm not sure why and this seems to happen a lot.

    Are you currently experiencing an issue you would like help resolving, or are you saying that the issue went away and will remain a mystery?
    In the case of the former, I am happy to help resolving it! And in the case of the latter, I am happy that you were able to resolve you issue and that both peripherals are currently working as expected.

    Best regards,
    Karl

  • Hello Marti,

    Can you please share the working code of TWI and BLE?

    Are you using the custom BLE example?

Related