UART imx6 trash problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART imx6 trash problem

696 Views
joãosilva
Contributor I

Hello everyone,

I am trying to port FreeRTOS to execute in the imx6 smart devices board and I'm developing the needed drivers to do it and I am facing an issue trying to use the serial port, I have seen many examples using the serial port but everything I do goes the same way. If I use a function to print just one character. I am able to print the character, like one by one(Calling the same function separately), but if I use a function to print a string for example, that is nothing more than print some characters one after the other i only get trash in my port. I will put my code here, if you could help me would be great.

This function I use for the serial port configuration.

int mxc_serial_init(void)
{
int tmp;
__REG((0x020e0000) + 0x280) = 0x00000003; // ALT3 CSI0_DAT10 TxD
__REG((0x020e0000) + 0x284) = 0x00000003; // ALT3 CSI0_DAT11 RxD
__REG((0x020e0000) + 0x920) = 0x00000001; //UART1_UART_RX_DATA_SELECT_INPUT
tmp=__REG((0x020c4000) + 0x24) & 0x0000003F ; //CSCDR1 uart_podf div by 1
__REG((0x020c4000) + 0x24) = tmp; // UART refclk = 80MHz

// Enable UART1
// enable uart1, ignore RTS, wordsize 8bits, 1 stop bit, no parity
__REG(UART1_BASE + UCR2) = 0x01; // reset UART state machines
__REG(UART1_BASE + UCR2) = 0x2006; // UCR2 = CTSC,TXEN,RXEN=1,reset
__REG(UART1_BASE + UCR1) = 0x0001; // UARTEN = 1,enable the clock
__REG(UART1_BASE + UCR2) |= UCR2_IRTS; // configure IRTS bit
__REG(UART1_BASE + UCR2) |= UCR2_WS ;
__REG(UART1_BASE + UCR2) |= UCR2_STPB;
__REG(UART1_BASE + UCR3) |= 0x00000004; // set RXD_MUX_SEL bit
__REG(UART1_BASE + UCR1) |= 0x0201; // recieve ready interput enable

// disable parity
__REG(UART1_BASE + UCR2) &= ~(0x00000100);

//SetRFDIV_to_div_by_1_UART1();
tmp = __REG(UART1_BASE + UCR1); // save UFCR to default value
__REG(UART1_BASE + UFCR) = 5<<7; // set RFDIV to div-by-1 or b101
__REG(UART1_BASE + UFCR) |= tmp; // set other UFCR bits back to default
__REG(UART1_BASE + UBIR) = 0x4;
__REG(UART1_BASE + UBMR) = 0xD8;

}

These next two functions I use to print a character.

int mxc_can_putc(void)
{
unsigned int status = __REG(uart_address_global + UTS);

if (status & UTS_TXFULL)
{
return FALSE;
}
else
{
return TRUE;
}
}

void mxc_serial_putc(signed char c)
{
/* wait for transmitter to be ready */
while (!mxc_can_putc());
//while(__REG(uart_address_global + UTS) & UTS_TXFULL)
__REG(UART_PHYS + UTXD) = c;
}

And this one I use to print a string:

void mxc_serial_puts(char *s)
{
//int aaa = 0;
while (*s)
{
//while (!mxc_can_putc());
mxc_serial_putc(*s++);
//for(aaa = 0; aaa < 500000000; aaa++);

}

}

Now, if I call myself the putc function I can print the char I want, but if I use the puts I only get trash.

Like in the next example:

void _init(void)
{
mxc_serial_init();
mxc_serial_putc('i');
mxc_serial_putc('n');
mxc_serial_putc('i');
mxc_serial_putc('t');
mxc_serial_putc('\n');
mxc_serial_puts("aaaaa1\n");
}

This is the output i have:

init
���e����m��s��{m�O�1\-+��^�� T .�Uq���}'qע�����d���u�/����I��=>�?��M�; �����w���=Pj���w�.�`�mw]�uF>�wo���ܹ�{�X�7}I����3���/?����cf �.�N���� �)����\���ݽ��￱�לm���λz�z����/~Cɽ/T����Z���� ��<�{���j� O��H��� |� E����_���^�  ֕� �v����s�ͫ<���ʳ�����=�l��ܗ�������7G?�?�� |���U}��埧��}ս�������3�� ��Ӷg�?��t|�V��������c�����Go�o��M]�{�>��}Ğum�~{�Rjo/��

Do you know what can possibly causing this?

Kind Regards,

João Silva

Labels (1)
Tags (1)
0 Kudos
Reply
0 Replies