UART send a register value problem


           I am working on RL78/I1b (R510MMGD) controller.In Uart,UART_SEND() function(Inbuilt function) created by code generator.Above function send only char or string.for ex: R_UART1_SEND("hai",3). it will send hai perfectly.

i want to send RTC Registers value like SEC,HOUR,MIN,DAY,MONTH,YEAR.for ex:R_UART1_SEND("SEC",2). it wont send such a SEC register will send S,E,C.I also tried R_UART1_SEND(SEC,2). it will send three times NULL.

then i also separate the digits.for ex i got from SEC register as 25. i separated as '2' & '5'. i want to send that register value by using above function.

can u please suggest me,whether above function is enough to send register value (or) need to create separate function for send some values of variable. for ex: b=5 means i want to send 5,not 'b' (value of  'b' only need to send) by using R_UART1_SEND(b,1);

  • Hi!

    for send a value of "b" first you need convert the int value to ascii, try using the itoa function.

    b = 5;

    c = integertoascii(b);


    I hope this can help you.

  • thanks for your reply, i tried with ascii also. it didnt work. because the function has constant arguments R_UART1_SEND(* const txbuf, no of digit)

  • I use the RL78G13 and my own functions for UART RxTx, maybe help you...

    first I make a function for send 1 byte:

    void sendByte(char byteToSend){

      for(;!STIFx;){   //wait for transmit flag


      STIFx = 1;        //clean the transmit flag

      RXDx  = byteToSend;      //put the byteToSend into the Transmit register


    second I make a function for transmit a "string" or a value of  "x" variable, function stops when a "0" or "null" is found

    if you need print "null" values you can add the number of byte to transmit for limit the cycle

    void printString(char *stringToSend){

      while(*stringToSend != 0){

          sendByte(*stringToSend);    // use the first function for send a first byte stringToSend point.

          stringToSend ++;                  // next byte



    so... if you need print a int value

    void integerToAscii(unsigned short i, char *a)


    short j, k;

    for(j = 5; j >= 0; j--)


    a[j] = (char)(((i%10) + 48) & 0xFF);

    i /= 10;


    k = 0;

    while((a[0] == '0') && (k < 5))


    for(j = 0; j < 5; j++) a[j] = a[j + 1];

    a[5] = 0;




    now you can use

    int b;

    char c;

    b = 5;



  • Thanks for above function. it will be useful for me.I need to clarify some doubts.

    I used CUBESUITE+ for RL78/I1B(R510MMGD) controller. It will generate code for transmit (i.e:R_UART_SEND) function. i think it will be send Char by char because arguments becomes *const txbuf.

    i just need to send a char without using Code generator built in function. is it possible?

    i checked with your void Sendbyte( char bytetosend) to transmit a charcter. it didnt work. please explain it clearly.

  • fine, in my case (/G13), I use all the UARTS available without any code from generator but, you need make your own functions for setting the UART, the above function don't work, sorry, finger error, RXDx is a receiver register, you need use TXDx :( really sorry.

    forget the above function

    "x" is the number of UART in my case "0", "1" or "2".

    void sendByte(char byteToSend){

    for(;!STIFx;){ //wait for transmit flag


    STIFx = 0; //clean the transmit flag

    TXDx = byteToSend; //put the byteToSend into the Transmit register


    the function takes the byte "byteToSend" wait in cycle for interrupt transmit flag, clean the flag and put "byteToSend" in to the TXDx for transmit

    do you have the interrupts enabled?

  • yeah, but i dont know it was right or wrong (interrupt enable).can you send me your uart transmit function project alone. it will be easy for my referrence.

    u can just create a new project with transmit and receive function. and interrupt enable also. that project will convert into .rar file and if you dont mind post here or send  to this mail id   [email protected]   .


  • ok, view this repo here are the uart.c and uart.h I use in my projects, so you need adjust the configuration at your clock frequency, I have this configuration at 20MHz and replace the "RxDx,RxDDx" and "TxDx,TxDDx" for the ports and pin acording your MCU.

    use the above functions to transmit

  • finally solved the "UART send a register value problem".

    I solved a problem on this method . some other ways  may be there. if anyones known,please post  on this page.

    Must Check every uart send arguments upto null. becoz Inbuit function becomes Const string arguments.  

    try This (character,string and any values of variables will be sent).

    R_UART0_Send("s",1);      //Character will be sent


    R_UART0_Send("ABCD k",6);  //string will be sent


    Send_Data(a,4);  //ex: a=1234  // "a" value will be sent


    NOTE: 1. In uart interrupt user.c file , static void r_uart0_callback_sendend(void) function must be Tx_End=1;

              2. R_UART0_Send(); becomes in buit function.

    void Send_Data(unsigned int Value,unsigned char NoOfDigit)


    unsigned char LoopCtr;

    unsigned int Divider;

    unsigned int i;




    for ( i = 0; i < NoOfDigit; i++)









    void check_Tx_End(void)



        Tx_End = 0;