I am using two identical sets: BRD4001A + BRD4250A (EFR32FG). I am trying to transmit data received in the stream from VCOM over the radio channel, and on a primitive device send the received data to VCOM too.The example simple_trx_with_fifo was taken as a basis.
On the transmitting device, I read the data in the main loop using the following function:
void send_uart_data(void){
int uart_count;
uint16_t Tx_Fifo_Space;
int a;
int len = 0;
if (packetTx){
uart_count = get_rx_count(); //get the number of unread bytes from the UART ring buffer
Tx_Fifo_Space = RAIL_GetTxFifoSpaceAvailable(railHandle);
if((uart_count >= 1) && Tx_Fifo_Space == TX_FIFO_SIZE) {
len = (uart_count + PACKET_HEADER_LEN) < Tx_Fifo_Space ? uart_count : Tx_Fifo_Space -2;
for (int i = PACKET_HEADER_LEN; i < len + PACKET_HEADER_LEN; i++) {
a = RETARGET_ReadChar();
txPtr[i] = (uint8_t)a; //global array for radio transmission
}
sendPacket(len + PACKET_HEADER_LEN);
}
}
}
void sendPacket(uint16_t packetLength)
{
RAIL_Idle(railHandle, RAIL_IDLE, true);
txPtr[0] = (packetLength - PACKET_HEADER_LEN) >> 8;
txPtr[1] = (packetLength - PACKET_HEADER_LEN) & 0xff;
txWritten = RAIL_WriteTxFifo(railHandle, txPtr, packetLength, true);
packetTx = false;
tx_count += txWritten;
RAIL_StartTx(railHandle, channel, RAIL_TX_OPTIONS_DEFAULT, NULL);
}
On the receiving side, when RAIL_EVENT_RX_PACKET_RECEIVED occurs, I call the function to save the received packet from the RX FIFO to my ring buffer:
After that in the main loop I call the function to read the ring buffer into VCOM:
void read_ring_buff(void){
uint8_t tmp = 0;;
int err = BUFFER_READ_EMPTY;
if(RETARGET_IsTX_ready()){
err = read_byte_ring_buffer(&tmp, &ring_buff);
if (err == BUFFER_READ_OK){
RETARGET_WriteChar((char)tmp);
}
}
}
int read_byte_ring_buffer(uint8_t *byte, struct ring_buffer *buffer){
int err = BUFFER_READ_OK;
if ((buffer->PtrTail != buffer->PtrHead) /*&& (buffer->byte_count != 0)*/){
*byte = buffer->BUF[buffer->PtrTail];
buffer->PtrTail = (buffer->PtrTail + 1) % BUFF_LEN;
buffer->byte_count--;
}
if (buffer->PtrTail == buffer->PtrHead)
err = BUFFER_READ_EMPTY;
return err;
}
int RETARGET_IsTX_ready(void){
if (!(RETARGET_UART->STATUS & USART_STATUS_TXIDLE)){
return 0;
}
return 1;
}
I cannot understand at what point and in what place the data is lost and for what reason. The data is most likely not the same as the one sent. If you send a small amount of data, then there are slightly fewer errors.
Thanks.
Discussion Forums
32-bit MCUs
Answered
Answered
move to proprietary forum.
0
Hi Daniil,
I don't see anything obviously wrong with this code, at least not on the RAIL side. I would recommend to open a support ticket, and attach the application itself so we can reproduce the issue.
Andras
Correct Answer
0
Hello,
did this issue result in a solution, please? I experienced similar exceptions in data buffer transfers as if some RAIL/uart interrupts have been left untriggered or not serviced, being hard to debug.
Now I am going to refactor this real-time uart wireless bridge code from the RAIL to Connect stack and iostream, hoping to link critical low level processes from a fine working Silabs libraries. : )
Thank you, Tom
0
Hi,
May I ask you to create a new forum topic regarding your issue?
Also, please note that the above issue is related to Simplicity Studio v4 / Flex SDK 2.x. I assume this is a newer project and you use Simplicity Studio v5 (we only recommend SSv4 for existing project started in SSv4, when effort is already put into the project but highly recommend to start new development in SSv5 or even migration older project from SSv4 to SSv5 if that requires only a reasonable effort).
VCOM transmission
Hi
I am using two identical sets: BRD4001A + BRD4250A (EFR32FG). I am trying to transmit data received in the stream from VCOM over the radio channel, and on a primitive device send the received data to VCOM too.The example simple_trx_with_fifo was taken as a basis.
On the transmitting device, I read the data in the main loop using the following function:
On the receiving side, when RAIL_EVENT_RX_PACKET_RECEIVED occurs, I call the function to save the received packet from the RX FIFO to my ring buffer:
After that in the main loop I call the function to read the ring buffer into VCOM:
I cannot understand at what point and in what place the data is lost and for what reason. The data is most likely not the same as the one sent. If you send a small amount of data, then there are slightly fewer errors.
Thanks.
Hi Daniil,
I don't see anything obviously wrong with this code, at least not on the RAIL side. I would recommend to open a support ticket, and attach the application itself so we can reproduce the issue.
Andras
Hello,
did this issue result in a solution, please? I experienced similar exceptions in data buffer transfers as if some RAIL/uart interrupts have been left untriggered or not serviced, being hard to debug.
Now I am going to refactor this real-time uart wireless bridge code from the RAIL to Connect stack and iostream, hoping to link critical low level processes from a fine working Silabs libraries. : )
Thank you, Tom
Hi,
May I ask you to create a new forum topic regarding your issue?
Also, please note that the above issue is related to Simplicity Studio v4 / Flex SDK 2.x. I assume this is a newer project and you use Simplicity Studio v5 (we only recommend SSv4 for existing project started in SSv4, when effort is already put into the project but highly recommend to start new development in SSv5 or even migration older project from SSv4 to SSv5 if that requires only a reasonable effort).
BR,
/sza2