0

I am new to Renesas and infact this is my first time hands-on. I really liked the Peripheral pin code generator. But I need help with respect to UART. I tested in simulator it was not working in that and in actual hardware there is some random character being spitted out continously.

I tried to write a sample code to test UART but it was not working for me. Please let me resolve this problem.

Toolchain: GCC for Renesas 4.9.2.201801-GNURL78 (Latest)

IDE version : e2 studio 6.2.0

///CODE
static const uint8_t messageHelloWorld[13] = {“Hello World\r\n”};
uint8_t g_Uart0RxBuf; /* 1 byte RX Buffer */
MD_STATUS g_Uart0TxEnd; /* Signals end of Tx */
extern volatile uint16_t g_uart0_rx_count; /* uart0 receive data number */
extern volatile uint16_t g_uart0_rx_length; /* uart0 receive data length */

void init_uart()
{
int i = 0,flag=0;
for(i=0;i<10;i++)
{
g_Uart0TxEnd = R_UART0_Send(messageHelloWorld, 13);
while(g_Uart0TxEnd == 0);
}
P1 = 0xFF;

R_UART0_Receive(&g_Uart0RxBuf,1);

while (1U)
{
if( g_uart0_rx_count >= g_uart0_rx_length)
{
if(flag ==0)
flag=0xff;
else
flag = 00;
P1=flag;

/* Send the recieved char on console */
g_Uart0TxEnd = R_UART0_Send(&g_Uart0RxBuf, g_uart0_rx_length);
while(g_Uart0TxEnd == 0);        /* Wait for final transmit */
}
/* Initialize the RX Buffer for Next Reception */
R_UART0_Receive(&g_Uart0RxBuf,1);
}
}

/***********************************************************************************************************************
* Function Name: main
* Description  : This function implements main function.
* Arguments    : None
* Return Value : None
***********************************************************************************************************************/
void main(void)
{
R_MAIN_UserInit();
/* Start user code. Do not edit comment generated here */

//P1 = 0x10;
int i =1;
double j=0,x=0;
while (1U)
{
P1 = 0x00;
uart_fn();
}
/* End user code. Do not edit comment generated here */
}

/***********************************************************************************************************************
* Function Name: R_MAIN_UserInit
* Description  : This function adds user code before implementing main function.
* Arguments    : None
* Return Value : None
***********************************************************************************************************************/
void R_MAIN_UserInit(void)
{
/* Start user code. Do not edit comment generated here */
EI();
R_UART0_Start();
/* End user code. Do not edit comment generated here */
}

/* Start user code for adding. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */

Attila Banyai answered
    • Hello,

      Thank you for your inquiry!

      We have noticed that you had also commented on https://gcc-renesas.com/question/sprintf-format-specifiers-dont-working/ saying that you are encountering the same problem.

      Please let us know if this is a separate query, or if we should follow-up on this thread only.

      Additionally, in the other thread above we were requesting, through a comment, that you please provide us with the following details if possible:

      1. the e2 Studio version
      2. the device you are using
      3. the toolchain version

      Thank you, we look forward to hearing back from you soon.


      Best regards,
      The GNU Tools Team

    • It is actually same issue.But what i realized is sprintf is working but the problem was actually with UART. That’s why i thought i can create a separate issue. I have already mentioned the details that you were askig for.
      Still i will write them here.
      1. the e2 Studio version – 6.2.0
      2. the device you are using – R5F10268A
      3. the toolchain version – GCC for Renesas 4.9.2.201801-GNURL78 (Latest)