[uClinux-dev] slow UART on MCF 5272?

Greg Ungerer gerg at snapgear.com
Wed Nov 14 18:50:51 EST 2001


Hi Johan,

"Magnusson, Johan" wrote:
> I'm new to this list (not as a reader but anyway..). I have been working
> with the uClinux distribution for MCF5272 for two weeks now and it has been
> working pretty good, except from some problems using the second UART. So
> what would you expect? yet another UART problem? of course!
> 
> I am having troubles running this UART in 115200. 9600 works fine but 115200
> is VERY shaky, 38400 works but i don't get the speed I am asking for.

This sounds very much like a problem I fixed recently
for the 5272 uarts. The baud rate calculation was done
using a simple integer divide. Meaning that sometimes,
depending on the clock frequency and baud rate, you would
get quite inaccurate baud rate divisors. The problem was
particularly bad at large baud rates (like 115200).

The mcfserial.c in cvs.uclinux.org has a fix, as does my
latest distritbuion release.

Basically the fix is to round the divisor. The code change is
a one liner in change_speed():

        baudclk = ((MCF_CLK / mcfrs_baud_table[i]) + 16) / 32;

Regards
Greg



 This
> feels like a problem induced by my UART initialization.
> 
> So here is what I do:
> 
> in mcfserial.c i do according to previous mails on the list from Greg
> Ungerer i add:
> 
> >        /* Enable the output lines for the serial ports */
> >        portp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_PBCNT);
> >        *portp = (*portp & ~0x000000ff) | 0x00000055;
> >        portp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_PDCNT);
> >        *portp = (*portp & ~0x000003fc) | 0x000002a8;
> 
> Ok?
> 
> I then initialize my serial port from my program using:
> 
> >  cfmakeraw(&t);
> >
> >  t.c_cflag &= ~CBAUD;
> >  t.c_cflag |= B115200 | CS8 | CLOCAL;
> >  t.c_oflag = 0; /* turn off output processing */
> >  t.c_lflag = 0; /* no local modes */
> >
> >  t.c_cflag |= CRTSCTS;
> 
> > if (tcsetattr(fd, TCSANOW, &t) < 0)
> >  {
> >    perror("fd_setup : tcsetattr");
> >    exit(1);
> >  }
> 
> ok?
> 
> This results in my cellular phone (Ericsson t39) not getting my "message".
> speeds under 38400 works fine but higher speeds do not work. Ohh it works
> from my PC but not from my embedded system.
> 
> I have tried a couple of arguments for the serial port set-up without any
> effect on the result. I also noticed someone pointing out a rounding problem
> (in mcfserial.c) in setting the speed registry bits (integer division to
> integer). I implemented the proposed solution, without any luck.
> 
> what am I doing wrong here?? This have to be some silly initialization
> problem, but I am obviously not good enough to fix it!
> 
> Best regards
> Johan K Magnusson
> This message resent by the uclinux-dev at uclinux.org list server http://www.uClinux.org/

-- 
------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Wizard        EMAIL:  gerg at snapgear.com
SnapGear                                       PHONE:    +61 7 3435 2888
825 Stanley St,                                  FAX:    +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia              WEB:   www.snapgear.com
This message resent by the uclinux-dev at uclinux.org list server http://www.uClinux.org/



More information about the uClinux-dev mailing list