I tried to send the data and receive through the uart but i am unable finish this can someone help meProgram:
#include <stdint.h>
#include "tx_api.h"
#include "hal_data.h"
#include "r_sci_uart.h"
#include "rfid.h"
#include "SEGGER_RTT/SEGGER_RTT.h"
#define TRANSFER_LENGTH 128
uint8_t g_rfid_src[TRANSFER_LENGTH];
uint8_t g_rfid_dest[TRANSFER_LENGTH];
uint32_t g_rfid_transfer_complete = 0;
uint32_t g_rfid_receive_complete = 0;
void rfid_entry(void)
{
fsp_err_t err = R_SCI_UART_Open(&g_uart_ctrl, &g_uart_cfg);
SEGGER_RTT_printf(0, "Err: %d\n",err);
assert(FSP_SUCCESS == err);
err=0;
SEGGER_RTT_printf(0, "ErrR: %d\n",err);
char single_char = 'A';
err = R_SCI_UART_Write(&g_uart_ctrl, (uint8_t *)&single_char, 1);
SEGGER_RTT_printf(0, "Err1: %d\n",err);
// Wait for transfer to complete
uint32_t timeout = 10000000;
while (g_rfid_transfer_complete == 0 && timeout > 0)
timeout--;
}
if (timeout == 0)
SEGGER_RTT_printf(0, "Transfer timeout occurred\n");
// Handle the timeout situation
SEGGER_RTT_printf(0, "Transmitted: %d\n", g_rfid_transfer_complete);
// Reset the transfer complete flag
g_rfid_transfer_complete = 0;
// Start the read operation
err = R_SCI_UART_Read(&g_uart_ctrl, g_rfid_dest, TRANSFER_LENGTH);
SEGGER_RTT_printf(0, "Err2: %d\n",err);
// Wait for receive to complete
SEGGER_RTT_printf(0, "Received: %d\n", g_rfid_dest);
// Reset the receive complete flag
g_rfid_receive_complete = 0;
void rfid_callback(uart_callback_args_t * p_args)
switch (p_args->event)
case UART_EVENT_TX_COMPLETE:
g_rfid_transfer_complete = 1;
break;
case UART_EVENT_RX_COMPLETE:
g_rfid_receive_complete = 1;
default:
}}Output:00> Err: 000> ErrR: 000> Err1: 000> Transmitted: 100> Err2: 000> Received: 536744216
Hello,
What is the problem exactly ?
As far as I see you both transmit and receive data and no errors occur. Do you get the UART_EVENT_TX_COMPLETE and UART_EVENT_RX_COMPLETE events ?
Yes i too don't have any error but i didn't get the UART_EVENT_TX_COMPLETE and UART_EVENT_RX_COMPLETE events I have passed the character a but i don't know why i receive 00> Received: 53674421200> Err1: 000> Err1: 0 can you please help me
How is g_rfid_transfer_complete set to 1 then ?
I have set the case but it did not come to this case statement we only receive 0
On your logs above there is:
00> Transmitted: 1
which implies that g_rfid_transfer_complete is 1 and this can only happen if UART_EVENT_TX_COMPLETE is triggered. Am I wrong ?
yeah you are correct.can you send me the uart transmitter and receiver code?
I have already on this post which I believe is for the same issue:
community.renesas.com/.../rfid