Re: Serial connection is garbled at 32MHz
Greg Ungerer <[email protected]> Fri, 18 Apr 2008 11:29:26 +1000
| Newsgroups | gmane.comp.hardware.motorola.microcontrollers.coldfire |
|---|---|
| Message-ID | <[email protected]> |
Hi Loren, Loren A. Linden Levy wrote: > Good thought, I went and looked for that too. But alas it was not a > change there other than adding the definition of 32MHz. Is this just some confusion on what the frequency should be set to? By convention the CONFIG_CLOCK_ is set to the CPU core clock - not the actual frequency of the crystal that you hook up to the CPU silicon. I presume that you mean you are hooking up a 32MHz crytsal to the 5282 chip? I am traveling and I don't have the 5282 data sheet handy, but maybe that means the CPU core is running at 64MHz. If so then that is the CONFIG_CLOCK_ you should be using. Regards Greg > Index: asm-m68knommu/coldfire.h > =================================================================== > RCS file: /var/cvs/uClinux-2.4.x/include/asm-m68knommu/coldfire.h,v > retrieving revision 1.19 > diff -u -r1.19 coldfire.h > --- asm-m68knommu/coldfire.h 25 Sep 2007 06:25:01 -0000 1.19 > +++ asm-m68knommu/coldfire.h 17 Apr 2008 15:10:14 -0000 > @@ -38,6 +38,7 @@ > /* > * Define master clock frequency. > */ > + > #if defined(CONFIG_CLOCK_11MHz) > #define MCF_CLK 11289600 > #elif defined(CONFIG_CLOCK_16MHz) > @@ -50,6 +51,8 @@ > #define MCF_CLK 25000000 > #elif defined(CONFIG_CLOCK_29_5MHz) > #define MCF_CLK 29500000 > +#elif defined(CONFIG_CLOCK_32MHz) > +#define MCF_CLK 32000000 > #elif defined(CONFIG_CLOCK_33MHz) > #define MCF_CLK 33000000 > #elif defined(CONFIG_CLOCK_40MHz) > > > Only CONFIG_M547x, CONFIG_M5208), CONFIG_M5235, CONFIG_M5249, and > CONFIG_M527x get either a multiple of 2 or division by 2. I am > starting to think it might have something to do with my boot-loader > (u-boot) but I am not sure. > > Alex > > On Thu, 17 Apr 2008 15:41:13 +1000 > Greg Ungerer <[email protected]> wrote: > >> Hi Loren, >> >> Loren A. Linden Levy wrote: >>> So this is really funny if I calculate the UBG1(2) values in this way: >>> >>> #if defined(CONFIG_CLOCK_32MHz) && defined(CONFIG_M5282) >>> printk("Alex's baud rate hack!!!\n"); >>> baudclk = ((2*MCF_BUSCLK / mcfrs_baud_table[i]) + 16 ) / 32; >>> >>> rather than: >>> >>> #else >>> baudclk = ((MCF_BUSCLK / mcfrs_baud_table[i]) + 16) / 32; >>> #endif >>> >>> I get 19200 baud rate. What the heck is going on here.... >> Hmmm, you didn't change coldfire.h did you? >> It has conditional code for some ColdFire CPU types that >> divides the master clock frequency by 2 to get that MCF_BUSCLK. >> Though the 5282 is not one of them normally. >> >> Regards >> Greg >> >> >> >> >> >>> On Mon, 07 Apr 2008 10:50:44 +1000 >>> Greg Ungerer <[email protected]> wrote: >>> >>>> Hi Loren, >>>> >>>> Loren A. Linden Levy wrote: >>>>> On Fri, 04 Apr 2008 11:06:59 +1000 >>>>> Greg Ungerer <[email protected]> wrote: >>>>>> Allon Stern wrote: >>>>>>> On Apr 3, 2008, at 2:20 PM, Loren A. Linden Levy wrote: >>>>>>>> So I am making progress with this external FPGA (thanks to all the >>>>>>>> help) and I have the code basically working (I think). One thing we >>>>>>>> are doing is artificially running the chip (M%282) at 32MHz and this >>>>>>>> screws up the display over serial (I get nonsense characters). This is >>>>>>>> not too big a deal b/c I can connect just fine over telnet I was just >>>>>>>> wondering if there was an obvious way to fix it (settings?). Thanks >>>>>>>> again. >>>>>>> I'd suggest looking at (assuming 2.6) linux2.6.x/drivers/serial/mcfserial.c >>>>>>> >>>>>>> Look for the line (#636 in my kernel): >>>>>>> /* compute the baudrate clock */ >>>>>>> >>>>>>> This is where it determines the baudrate clock based on the CPU clock. >>>>>>> >>>>>>> It appears to be based off of MCF_BUSCLK, which is defined in >>>>>>> linux2.6.x./include/asm-m68knommu/coldfire.h as >>>>>>> #define MCF_BUSCLK (CONFIG_CLOCK_FREQ / CONFIG_CLOCK_DIV) >>>>>>> >>>>>>> Both CONFIG_CLOCK_FREQ and CONFIG_CLOCK_DIV are defined in your .config. >>>>>> That is right. If you are just feeding a different master >>>>>> clock to the 5282 then the right change to make is to >>>>>> CONFIG_CLOCK_FREQ. Look for the config menu item with the >>>>>> text "Set the core clock frequency". This is only in 2.6.x >>>>>> kernels. >>>>>> >>>>>> If using a 2.4.x kernel then you need to change the clock >>>>>> frequency manually in the source (look in >>>>>> linux-2.4.x/include/asm-arm/coldfire.h). >>>>> It is a 2.4.x kernel and I actually already added the 32MHz option >>>>> (coldfire.h): >>>>> >>>>> --- linux-2.4.x/include/asm-m68knommu/coldfire.h 25 Sep 2007 06:25:01 -0000 1.19 >>>>> +++ linux-2.4.x/include/asm-m68knommu/coldfire.h 4 Apr 2008 17:46:52 -0000 >>>>> @@ -38,6 +38,7 @@ >>>>> /* >>>>> * Define master clock frequency. >>>>> */ >>>>> + >>>>> #if defined(CONFIG_CLOCK_11MHz) >>>>> #define MCF_CLK 11289600 >>>>> #elif defined(CONFIG_CLOCK_16MHz) >>>>> @@ -50,6 +51,8 @@ >>>>> #define MCF_CLK 25000000 >>>>> #elif defined(CONFIG_CLOCK_29_5MHz) >>>>> #define MCF_CLK 29500000 >>>>> +#elif defined(CONFIG_CLOCK_32MHz) >>>>> +#define MCF_CLK 32000000 >>>>> #elif defined(CONFIG_CLOCK_33MHz) >>>>> #define MCF_CLK 33000000 >>>>> #elif defined(CONFIG_CLOCK_40MHz) >>>>> >>>>> >>>>> and an entry in the config.in file for kernel configuration. >>>>> >>>>> --- linux-2.4.x/arch/m68knommu/config.in 25 Sep 2007 06:25:01 -0000 1.76 >>>>> +++ linux-2.4.x/arch/m68knommu/config.in 4 Apr 2008 17:46:09 -0000 >>>>> @@ -34,7 +34,6 @@ >>>>> endmenu >>>>> >>>>> ############################################################################# >>>>> - >>>>> mainmenu_option next_comment >>>>> comment 'Processor type and features' >>>>> >>>>> @@ -93,6 +92,7 @@ >>>>> 24MHz CONFIG_CLOCK_24MHz \ >>>>> 25MHz CONFIG_CLOCK_25MHz \ >>>>> 29.5MHz CONFIG_CLOCK_29_5MHz \ >>>>> + 32MHz CONFIG_CLOCK_32MHz \ >>>>> 33MHz CONFIG_CLOCK_33MHz \ >>>>> 40MHz CONFIG_CLOCK_40MHz \ >>>>> 45MHz CONFIG_CLOCK_45MHz \ >>>>> >>>>> >>>>> Now I am a little confused about the serial baudrate calculation (I >>>>> found it is actually in the file drivers/char/mcfserial.c). >>>>> >>>>> For the M5282 the calculation is: >>>>> >>>>> #else >>>>> baudclk = ((MCF_BUSCLK / mcfrs_baud_table[i]) + 16) / 32; >>>>> #endif >>>>> >>>>> Which is basically identical to what I found in the manual. Here the >>>>> baud_rate table entry is number 14 which is 19200. So the baudclck for >>>>> 32MHz and 66MHz come out to be 52 and 180 respectively. I guess i do not understand why I am getting junk out if the clock calculation here is being mad correctly. I am in the process of looking throiugh the UART UBG settings to se iff there is something I am missing. Any input or hints would be appreciated. >>>> Seems like you have taken the correct approach. >>>> >>>> Regards >>>> Greg >>>> >>>> >>>> >>>> ------------------------------------------------------------------------ >>>> Greg Ungerer -- Chief Software Dude EMAIL: [email protected] >>>> Secure Computing Corporation PHONE: +61 7 3435 2888 >>>> 825 Stanley St, FAX: +61 7 3891 3630 >>>> Woolloongabba, QLD, 4102, Australia WEB: http://www.SnapGear.com >>>> --- >>>> [email protected] Send a post to the list. >>>> [email protected] Join the list. >>>> [email protected] Join the list in digest mode. >>>> [email protected] Leave the list. >>>> >>> >> > > -- ------------------------------------------------------------------------ Greg Ungerer -- Chief Software Dude EMAIL: [email protected] SnapGear -- a Secure Computing Company PHONE: +61 7 3435 2888 825 Stanley St, FAX: +61 7 3891 3630 Woolloongabba, QLD, 4102, Australia WEB: http://www.SnapGear.com --- [email protected] Send a post to the list. [email protected] Join the list. [email protected] Join the list in digest mode. [email protected] Leave the list.