This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UART not working with CC-RL compiler

Hi all,

I want to print strings on the serial terminal. Below is the code. Its working as expected with GNURL78 compiler, but printing garbage value when compiled with CC-RL compiler. Please tell me where am I making the mistake.

I am using R5F10BMG MCU and e2 studio IDE.

void uart1_p_init (void)
{
   /***** Configure UART0 *****/
   /* Supply clock to serial array unit 1 */
   SAU1EN = 1U;

    /* >=4 cycle delay required by manual */
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();

    /***** Set input clock (CK00 and CK01) to Fclk *****/
    /* ck00 - fCLK/2^4 and ck01 - fCLK */
    SPS1 = 0x0004U | 0x0040U;

    /***** Setup operation mode for transmitter (channel 1) *****/
    /* SMR10 initial value */
    SMR10 = 0x0020U | 0x0002U | 0x0001U;
    SCR10 = 0x8000U | 0x0080U | 0x0010U | 0x0007U;
    SDR10 = 0xCE00U; //_CE00_UART1_TRANSMIT_DIVISOR;

    /* noise filter on */
    NFEN0 = 0x04U;
    SIR11 = 0x0004U | 0x0002U | 0x0001U;    /* clear error flag */
    SMR11 = 0x0020U | 0x0100U | 0x0002U;
    SCR11 = 0x4000U | 0x0080U | 0x0010U | 0x0007U;
    SDR11 = 0xCE00U;

    /* Output is not inverted */
    SO1 |= 0x0001U;

    SOL1 |= 0x0000U;    /* output level normal */
    SOE1 |= 0x0001U;    /* enable UART1 output */

    /* Set RxD1 pin */
    PM1 |= 0x02U; //P11 as RxD1

    /* Set TxD1 pin */

    PM1 &= 0xFBU; //P12 as TxD1
    P1 |= 0x04U;

    /* Enable UART1 transmit and receive operation (channel 1) */
    SS1 = 0x0002U | 0x0001U;

    /* Enable INTST1 interrupt flag */
    STIF1 = 1U;
    SRIF1 = 1U;
}

/* Transmit the character */
unsigned char uart1_putchar(unsigned char c)
{
    while (0U == STIF1);
    STIF1 = 0U;
    SDR10L = (unsigned char)c;
    return (unsigned char)SDR10L;
}

void uart1_puts(const unsigned char *s)
{
   while ('\0' != *s)
   {
       (void)uart1_putchar(*s++);
   }
}
/*====================================================================*/
#include "serial_gnu.h"

void main(void)
{
	uart1_p_init();
	uart1_putchar('A');
	uart1_puts("UART Init\n");

}
 

Parents Reply Children
No Data