Hi,
In my application, I would like to transfer data from MCU ---(UART#1)---> BLE#1(Peripheral) ---> BLE#2(Central) ---(UART#2)---> PC.
I start my code based on ble_app_uart_pca10040e_s112 & ble_app_uart_c_pca10040_s132.
The model I am using for BLE#1 is nrf52810.
The data of 78 byte is transferred from MCU to BLE#1 through UART#1 every 20ms.
The data only transfer in one way. i.e. No data send back from PC to MCU is needed.
I have confirmed the above example code works properly with the following setting:
The UART#1 baud rate between MCU and BLE#1: 250kbps
The UART#2 baud rate between BLE#2 and PC: 460kbps
Both peripheral and central BLE tx_phys and rx_phys is set to BLE_GAP_PHY_AUTO.
No flow control for both UART#1 and UART#2.
Peripheral m_ble_nus_max_data_len is set to 78. (As all data are fixed size of 78 byte)
Peripheral NRF_SDH_BLE_GATT_MAX_MTU_SIZE is set to 81 in sdk_config.h. (I expect it is data length +3 bytes?)
Central BLE#2 ECHOBACK_BLE_UART_DATA is set to 0.
What I would like to do is to increase the transfer rate as follow:
Every 5ms, 78 byte data transfer from MCU to BLE#1, with baud rate 690kbps.
I have confirmed that the 78 bytes is transferred correcly from MCU to BLE#1 only if the BLE#1 is not advertising or connected, by checking the total received data length, header (first 5 bytes) and footer (last 5 bytes) are received correctly.
However, if the BLE starts advertising, BLE#1 does not receive the data correctly.
I added some counter and found the success vs failure ratio is about 15~20 vs 1000.
I suspect if the BLE is processing (some interrupt event?) affects the UART FIFO process? (Just some guess, please correct me)
And what I would like to ask is:
1. If the targeted data through put is possible?
Due to some restriction on MCU processing, UART transfer have to be finished within 1.2ms.
The remaining 3.8ms is for MCU accessing other sensors to collect the 78 byte data.
Therefore the baud rate of UART#1 have to be around 690kbps, which can finish the transfer through UART#1 within 1.1ms.
Lower baud rate (i.e. 460kbps) will be too slow for as it takes around 1.7ms.
2. How to increase the data throughput between BLE?
I have already increase the PHY to BLE_GAP_PHY_2MBPS for both tx and rx (although my application is transfering data one way) on both peripheral and central.
And confirmed it is changed by the BLE_GAP_EVT_PHY_UPDATE event in ble_evt_handler. (By referencing this post: devzone.nordicsemi.com/.../nrf52832-ble_gap_phy_2mbps-configuraion-in-ble_app_uart-peripheral-mode)
Is there anything else I have to configure?
Is the transfer rate between BLE 300kbps?
Is there anyway I can check if my setting is correct?
3. What caused the received data from UART#1 lost some bytes? Is there anyway to improve the performance?
When the BLE is advertising or transmitting data, UART#1 will not receive data correcly.
Some bytes are missing. For example, if the original data from MCU is:
ABCDEFG1234567...
It will receive with some randomly missing byte like:
ABDEF24567... or ACDEF12457...
And I cannot figure out what caused the problem.
Thank you in advanced.
Joe