UART SCI RX66t Smart Configurator issue

Hello, 

I am using RX66t SCI UART with code created with Smart Configurator. I tried to send a string continuously to the serial port. The complete string is sent only the first time. 

I need to modify and add the below bold line. That solves the problem and the string is sent continuously. But the modification is outside 

/* Start user code and /* End user code comments and if I made changes to setup in Smart Configurator this line added to solve the issue is removed (for example if I remove transmit end interrupt use). 

How can I solve this to keep my code compatible with Smart Configurator for future use?

I see the example provided using R_Config_SCI12_Serial_Send and they are only sending once. So, the issue is not reproduced.

static void r_Config_SCI12_transmit_interrupt(void)         // in Config_SCI12_user.c
{
if (0U < g_sci12_tx_count)
{
SCI12.TDR = *gp_sci12_tx_address;
gp_sci12_tx_address++;
g_sci12_tx_count--;
}
else
{
SCI12.SCR.BIT.TIE = 0U;
SCI12.SCR.BIT.TEIE = 1U;
SCI12.SCR.BYTE &= 0x5BU;
}
}

Another valid point to add the bolded line could be in the R_Config_SCI12_Serial_Send just before setting TIE, TEIE and TE bits in SCR register. But the problem is the same. The code is outside recommended user code space for Smart Configurator.

IEN(SCI12, TXI12) = 0U;

SCI12.SCR.BYTE &= 0x5BU;
SCI12.SCR.BYTE |= 0xA0U;

/* Set TXD12 pin */
PORT8.PMR.BYTE |= 0x02U;

Parents
  • Hello dear Luistope, thank you for posting on the Renesas community. 
    I'm not sure how you're getting the result with that line of code, as it doesn't work for me on my hardware.

    By the way, if you need a way to send a string continuously and without changing the generated code of the smart configurator, follow the below.

    1- Check the transmission end callback function in the smart configurator

    The code of "SCI12_User.c" file 

    /***********************************************************************************************************************
    * DISCLAIMER
    * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products.
    * No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all
    * applicable laws, including copyright laws. 
    * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED
    * OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    * NON-INFRINGEMENT.  ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY
    * LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT,
    * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR
    * ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability 
    * of this software. By using this software, you agree to the additional terms and conditions found by accessing the 
    * following link:
    * http://www.renesas.com/disclaimer
    *
    * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved.
    ***********************************************************************************************************************/
    
    /***********************************************************************************************************************
    * File Name        : Config_SCI12_user.c
    * Component Version: 1.12.0
    * Device(s)        : R5F566NNHxFP
    * Description      : This file implements device driver for Config_SCI12.
    ***********************************************************************************************************************/
    
    /***********************************************************************************************************************
    Pragma directive
    ***********************************************************************************************************************/
    /* Start user code for pragma. Do not edit comment generated here */
    /* End user code. Do not edit comment generated here */
    
    /***********************************************************************************************************************
    Includes
    ***********************************************************************************************************************/
    #include "r_cg_macrodriver.h"
    #include "Config_SCI12.h"
    /* Start user code for include. Do not edit comment generated here */
    #include <string.h>
    /* End user code. Do not edit comment generated here */
    #include "r_cg_userdefine.h"
    
    /***********************************************************************************************************************
    Global variables and functions
    ***********************************************************************************************************************/
    extern volatile uint8_t * gp_sci12_tx_address;                /* SCI12 transmit buffer address */
    extern volatile uint16_t  g_sci12_tx_count;                   /* SCI12 transmit data number */
    /* Start user code for global. Do not edit comment generated here */
    /* End user code. Do not edit comment generated here */
    
    /***********************************************************************************************************************
    * Function Name: R_Config_SCI12_Create_UserInit
    * Description  : This function adds user code after initializing the SCI12 channel
    * Arguments    : None
    * Return Value : None
    ***********************************************************************************************************************/
    
    void R_Config_SCI12_Create_UserInit(void)
    {
        /* Start user code for user init. Do not edit comment generated here */
        /* End user code. Do not edit comment generated here */
    }
    
    /***********************************************************************************************************************
    * Function Name: r_Config_SCI12_transmit_interrupt
    * Description  : This function is TXI12 interrupt service routine
    * Arguments    : None
    * Return Value : None
    ***********************************************************************************************************************/
    
    #if FAST_INTERRUPT_VECTOR == VECT_SCI12_TXI12
    #pragma interrupt r_Config_SCI12_transmit_interrupt(vect=VECT(SCI12,TXI12),fint)
    #else
    #pragma interrupt r_Config_SCI12_transmit_interrupt(vect=VECT(SCI12,TXI12))
    #endif
    static void r_Config_SCI12_transmit_interrupt(void)
    {
        if (0U < g_sci12_tx_count)
        {
            SCI12.TDR = *gp_sci12_tx_address;
            gp_sci12_tx_address++;
            g_sci12_tx_count--;
        }
        else
        {
            SCI12.SCR.BIT.TIE = 0U;
            SCI12.SCR.BIT.TEIE = 1U;
        }
    }
    
    /***********************************************************************************************************************
    * Function Name: r_Config_SCI12_transmitend_interrupt
    * Description  : This function is TEI12 interrupt service routine
    * Arguments    : None
    * Return Value : None
    ***********************************************************************************************************************/
    
    void r_Config_SCI12_transmitend_interrupt(void)
    {
        /* Set TXD12 pin */
        PORTE.PMR.BYTE &= 0xFDU;
    
        SCI12.SCR.BIT.TIE = 0U;
        SCI12.SCR.BIT.TE = 0U;
        SCI12.SCR.BIT.TEIE = 0U;
        
        r_Config_SCI12_callback_transmitend();
    }
    
    /***********************************************************************************************************************
    * Function Name: r_Config_SCI12_callback_transmitend
    * Description  : This function is a callback function when SCI12 finishes transmission
    * Arguments    : None
    * Return Value : None
    ***********************************************************************************************************************/
    
    static void r_Config_SCI12_callback_transmitend(void)
    {
        /* Start user code for r_Config_SCI12_callback_transmitend. Do not edit comment generated here */
    	extern uint8_t *str_buffer_ptr; //External variable for string address buffer
    	R_Config_SCI12_Serial_Send(str_buffer_ptr,strlen((const char*)str_buffer_ptr));// Retransmit the string
        /* 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 */
    


    The code of "main.c" file 
    /***********************************************************************
    *
    *  FILE        : RX66N_SCI_UART_TEST.c
    *  DATE        : 2024-03-12
    *  DESCRIPTION : Main Program
    *
    *  NOTE:THIS IS A TYPICAL EXAMPLE.
    *
    ***********************************************************************/
    #include "r_smc_entry.h"
    #include <string.h>
    
    uint8_t *str_buffer_ptr; //Global variable for string address buffer
    
    void main(void);
    
    void main(void)
    {
    	R_Config_SCI12_Start();
    
    	/*Allocate string to the external pointer buffer*/
    	str_buffer_ptr = "HelloWorld";
    	/*Send continuous data thorough SCI12*/
    	R_Config_SCI12_Serial_Send(str_buffer_ptr,strlen((const char*)str_buffer_ptr));
    
        while (1) {
    
        	/*change string in run time if needed*/
        	str_buffer_ptr = "String Changed!";
    
        	/*Blinky LED*/
            PIN_WRITE(LED1) = ~PIN_READ(LED1);
            /* Delay 500 milliseconds before returning */
            R_BSP_SoftwareDelay(500, BSP_DELAY_MILLISECS);
    
        }
    }
    


    My approach for this is to pass the string to a global pointer variable and resend the data through "R_Config_SCI12_Serial_Send" function using that pointer variable within the "r_Config_SCI12_callback_transmitend" function. 
     

    After initializing the UART and sending the string for the first time as the above code, the "R_Config_SCI12_Serial_Send" will be invoked after the completion of each string transfer in "r_Config_SCI12_callback_transmitend" function. 

    Finally, if you want to change the content of the string, you just need to assess the address of the new string to the "str_buffer_ptr" variable, and the new string will be sent instantly. 

    I've tested that and seems OK to me, I hope you find it useful. Don't hesitate to ask questions if you needed. 

    Best regards, 

    Hossein. 

    If this or any other user's response answers your concern, kindly verify the answer. Thank you!

    Renesas Engineering Community Moderator
    https://community.renesas.com/
    https://academy.renesas.com/
    en-support.renesas.com/.../

  • Hello Hossein and thank you for your answer,

    I find the solution. r_Config_SCI12_callback_transmitend was never raised. Priority of the group was set to zero (disabled) so was not raised. 

    I'm not sure how you're getting the result with that line of code

    That line was written by me. I added that line to solve the issue. Has the same effect disabling TIE, TE before setting again.

Reply
  • Hello Hossein and thank you for your answer,

    I find the solution. r_Config_SCI12_callback_transmitend was never raised. Priority of the group was set to zero (disabled) so was not raised. 

    I'm not sure how you're getting the result with that line of code

    That line was written by me. I added that line to solve the issue. Has the same effect disabling TIE, TE before setting again.

Children
No Data