This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to merge libuarte with app_ble_uart example for use two uart

Hello,

In my project i want two use two UART as off now i am using app_ble_uart example since by default 6,8 is tx and rx pins respectively. so overall application of my project is i need to receive the commands from the mobile application to device and from another external sensor board i need to receive the data  continuously to device from RS232 pin number of 3,4 TX ,RX respectively so now i can able to use one UART with 6,8 pins for sending commands from the mobile application to device but if i change the pin number to 3,4 in same uart_init it will disconnected from the mobile app so i have got information from the devzone like using libuarte example and i don't know to merge with the app_ble_uart example so please help me to resolve this problem or if any reference on this please share me.

thank you.

  • Hello Edvin,

    thanks  for your reply, and 

    What chip are you using by the way? In your tags, it says nRF52810, but your screenshot says pca10056, which suggests you are using the nRF52840. The nRF52810 doesn't have two UARTs, so you can't really use that.

    Yes, i am using NRF52840 only so that's why i have select the pac10056 for app_ble_uart example. however nrf52840 is having two UART's right.

     

    Are you sure you have set up the UART using the correct baudrate? And that the RX pin on your UARTs are not floating?

    I have select the baud rate as 115200 you can observe in the uart_init code snippet above . RX pins are should not floating means i need to pull up that right.??

    Does the issue only occur if you initialize both UARTs, or does it also happen if you connect only one (either UART0 or UART1. Test both one at the time).

    No, i think i am not initialize two UART's and i don't know how to configure it that's why i have raised a query for that. actually it happens only  when i am using single UART. TX=P1.3 and  RX=P1.4 

    1. Is it possible to implement with single UART or i should use 2 UART's.??

    2. If i can implement this with single UART means how to achieve this successfully.??

    thank you.

  • sagarnayakm said:
    however nrf52840 is having two UART's right.

    Yes. But the nRF52810 does not. That's why I needed to ask when I saw that tag. But that is fine. It should work with 2x UART on the nRF52840.

    sagarnayakm said:
    I have select the baud rate as 115200 you can observe in the uart_init code snippet above . RX pins are should not floating means i need to pull up that right.??

    Well, I believe the common method is that the other UART peripheral's TX pin (which is connected to your RX pin) has the pull. Let me rephrase the question. Is pin P1.04 physically connected to a UART device when the error occurs? I see that you are using baud rate 115200, but is that also the baud rate that the other device is using?

    sagarnayakm said:
    No, i think i am not initialize two UART's and i don't know how to configure it that's why i have raised a query for that. actually it happens only  when i am using single UART. TX=P1.3 and  RX=P1.4 

    Ok. Just trying to find the cause for the communication error event.

    sagarnayakm said:
    1. Is it possible to implement with single UART or i should use 2 UART's.??

    If you intend to communicate with UART to two different devices, you should use 2 UARTs. If not, then the two devices may decide to send data at the same time, and you will receive corrupted data. So unless you only intend to receive from one and transmit to the other, and they use the same baudrate, you should use 2x UART instances.

    sagarnayakm said:
    2. If i can implement this with single UART means how to achieve this successfully.??

    ----

    Best regards,

    Edvin

  • Is pin P1.04 physically connected to a UART device when the error occurs? I see that you are using baud rate 115200, but is that also the baud rate that the other device is using?

    Yes, its connected physically, because the custom board has been developed and from the sensor board as well as MCU has the same baud rate .

    If you intend to communicate with UART to two different devices, you should use 2 UARTs. If not, then the two devices may decide to send data at the same time, and you will receive corrupted data. So unless you only intend to receive from one and transmit to the other, and they use the same baudrate, you should use 2x UART instances.

    Sorry i get confused that should use 2 UART or not . because in my case i am using MCU with only one  HW_UART which is connected to sensor board physically, so BLE data send happens with Virtual UART  no need to configure UART for that, and sending a data over BLE as well as data from the HW_UART of sensor board to MCU at a time is possible right.?? 

    i am totally new to this nordic so can you please share code that how to use two UART in app_ble_uart example.

    Ok. Just trying to find the cause for the communication error event.

    Ok. i will try to find cause for communication error event and will let you know status.

    thank you.

  • sagarnayakm said:
    sending a data over BLE as well as data from the HW_UART of sensor board to MCU at a time is possible right.?? 

    Ah, yes. That is possible. And you don't need two UARTs for that. I only thought you wanted to pass the data from BLE out on a physical UART as well, since the headline for this ticket says "two uarts". 

    Well, if you intend to use only one UART, that is easier. You can more or less use the ble_app_uart example directly then. Look for the callback where:

    1: the physical uart has been written to, and disable the ble_nus_data_send() from this callback in order to not forward this data directly over BLE.

    2: The callback where the nRF receives data over the BLE service, and disable that the nRF will send this data over the physical UART. 

    And instead of that default behavior, you need to modify the application to do whatever you want it to do. 

    Best regards,

    Edvin

  • Hello Edvin,

    thanks for your reply,

    I only thought you wanted to pass the data from BLE out on a physical UART as well, since the headline for this ticket says "two uarts". 

    Yes, i want to send the command data from the MOBILE APP to MCU over BLE and i want to send the data from the sensor board to MCU over MAX232 with HW_UART but

    1: the physical uart has been written to, and disable the ble_nus_data_send() from this callback in order to not forward this data directly over BLE.

    No, want to receive the data from the sensor board to MCU over MAX 232 with HW_UART here i need to send the data to BLE as well i couldn't disable the function ble_nus_data_send() here . the device should receive the data and send to MOBILE_APP over BLE.

    The callback where the nRF receives data over the BLE service, and disable that the nRF will send this data over the physical UART.

    Ah, like when device receives the data from sensor board it will send to nrf over BLE  and then again APP will send this data to HW_UART. this is what you ment.??

    thank you.

Related