Goodbye "magic" frequency crystals for UART output. With the 4095 possible values of BSEL (the replacement for UBRR) and using BSCALE to bit shift BSEL from -7 to +7 bits, it's possible to get very close baud rates, even with formerly impossble situations like 115.2Kbps with a CLK of 1MHz and 300 baud with a CLK of 32MHz. I'm extending AVRCalc ( http://www.avrcalc.com/ ) to handle selecting the best BSEL and BSCALE for a given clock frequency and desired baud rate.
I am not sure about that. Right now I use the internal 32 MHz, calibrated by an external 32kHz quartz. To get a standard baud rate like 19200 I have to choices (excluding double speed):
1. BSCALE=-5; BSEL=3301 -> 19376 baud
or
2. BSCALE=0; BSEL=103 -> 19405 baud
This means the first choice is better. But I still have nearly a 1% error. Usually this is accurate enough. But right now the data sheet doesn't say anything about the accuracy of my 32MHz clock over a huge temperature variance. So I feel a bit insecure about it. What do you think about this?
BTW: I loved to use AVRCALC in my former projects. For this calculation I had to stress my pocket calculator. A Xmega update would be great! 8)
AVRCalc computes a baud speed of 19202 for BSCALE of -5 and BSEL of 3301. In general, using a combination of BSCALE and U2X, you should be able to get BSEL into the 2048 to 4095 range. In that range, you'd have a maximum error of 2 parts in 1000, or 0.2%.
Quote:
But I still have nearly a 1% error.
A 1% error on the XMEGA side will allow the other side of communication to have up to a 3-4% error and still have perfect 10 bit UART packet.
Quote:
But right now the data sheet doesn't say anything about the accuracy of my 32MHz clock over a huge temperature variance. So I feel a bit insecure about it. What do you think about this?
You're right, there have been no temperature curves. The accuracy at 32MHz with 16x PLL will be the same as the 2MHz internal oscillator. In an app note that I saw last year, a 0.5% accuracy for the internal oscillator was quoted. Ideally, the datasheet will have a value somewhere in that range.
Quote:
BTW: I loved to use AVRCALC in my former projects. For this calculation I had to stress my pocket calculator. A Xmega update would be great! 8)
Glad that you liked it. I've been sidetracked on other projects, but a new release will appear at some point!
While I don't have the computations placed in the GUI application, yet. Here's an example of what I do from the REPL (read, evaluation, print, loop) for XMEGA calculations. To find the optimal BSCALE, BSEL, mode, and error:
Thanks for your calculations. It was a bit late (european time) on my working day yesterday and I mixed up the formulas for (BSCALE >=0) and (BSCALE <0). This means your calculations are correct and I did a mistake.
Avoiding such mistakes is one more argument for AVRCALC! :wink:
Just one comment: The Normal Speed Mode should be preferred. Because the XMEGA A Manual says
Quote:
Normal Speed mode has higher toleration of baud rate variations.
(8077B-AVR_06/08, chapter 19.8.3, page 220)
Im my case (8 bit + 1 start and 1 stop bit) the recommended max. receiver error is 2% in normal and 1.5% in double speed mode (see tables on the same page).
Posted by Ali_dehbidi: Thu. Sep 18, 2008 - 01:12 PM
1
2
3
4
5
Total votes: 0
hi guys
look at this cool chip "MCF51QE32CLH" it's cheaper than the XMEGA series and faster!
the price is about 3$ and it is 32bit and can run 50MHz and have 46MIPS!
But if you wanted 50MHz 32bit why would you go for a no-hoper like Freescale Coldfire when ARM's rule the planet? NXP will sell you an LPC for a lot less than $3!
I had a short look at the data sheet. This chip has two killing points for me:
1. It consumes 31mA @ 25MHz; XMEGA A1: 21mA @ 32MHz
2. It has only 2 UARTS (SCI); XMEGA A1: 8 USARTS
The Coldfire chips are not bad. But you cannot say in general that they are better. It depends on your project.
Avoiding such mistakes is one more argument for AVRCALC!
Yep, most of the delay has been getting the Macintosh port finished for the new version.
Quote:
Just one comment: The Normal Speed Mode should be preferred. Because the XMEGA A Manual says: Normal Speed mode has higher toleration of baud rate variations.
Right. You may have noticed, but I setup optimum-bsel-bscale to first search for optimal normal speed (and return those when finding just the one best value) rather than double speed. However, based on the 2% and 1.5% figure, perhaps the function should favor Normal over Double, even if the Normal error rate is up to (2/1.5=1.33) times higher than the best Double rate.
look at this cool chip "MCF51QE32CLH" it's cheaper than the XMEGA series and faster!
the price is about 3$ and it is 32bit and can run 50MHz and have 46MIPS!
We like to look at new chips. To get the most responses to your thought, you might want to open a new thread about it so that people will find it easier than being buried in this thread.
That's it, thanks! :)
Actually I already set the CLK_SCLKSEL_PLL but I forgot the wait loop.
- Log in or register to post comments
TopCool, that the additional code example helped.
Kevin Rosenberg
http://b9.com
http://kevin.hypershots.com
- Log in or register to post comments
Top1. BSCALE=-5; BSEL=3301 -> 19376 baud
or
2. BSCALE=0; BSEL=103 -> 19405 baud
This means the first choice is better. But I still have nearly a 1% error. Usually this is accurate enough. But right now the data sheet doesn't say anything about the accuracy of my 32MHz clock over a huge temperature variance. So I feel a bit insecure about it. What do you think about this?
BTW: I loved to use AVRCALC in my former projects. For this calculation I had to stress my pocket calculator. A Xmega update would be great! 8)
- Log in or register to post comments
TopKevin Rosenberg
http://b9.com
http://kevin.hypershots.com
- Log in or register to post comments
TopTo generate a report with all BSCALE and mode combinations with an error rate of less than 2%, I pass the maximum allowed error value to the function:
Kevin Rosenberg
http://b9.com
http://kevin.hypershots.com
- Log in or register to post comments
TopThanks for your calculations. It was a bit late (european time) on my working day yesterday and I mixed up the formulas for (BSCALE >=0) and (BSCALE <0). This means your calculations are correct and I did a mistake.
Avoiding such mistakes is one more argument for AVRCALC! :wink:
Just one comment: The Normal Speed Mode should be preferred. Because the XMEGA A Manual says
Im my case (8 bit + 1 start and 1 stop bit) the recommended max. receiver error is 2% in normal and 1.5% in double speed mode (see tables on the same page).
- Log in or register to post comments
Tophi guys
look at this cool chip "MCF51QE32CLH" it's cheaper than the XMEGA series and faster!
the price is about 3$ and it is 32bit and can run 50MHz and have 46MIPS!
I love Digital
and you who involved in it!
- Log in or register to post comments
TopBut if you wanted 50MHz 32bit why would you go for a no-hoper like Freescale Coldfire when ARM's rule the planet? NXP will sell you an LPC for a lot less than $3!
- Log in or register to post comments
TopAlthough this is a bit off topic...
I had a short look at the data sheet. This chip has two killing points for me:
1. It consumes 31mA @ 25MHz; XMEGA A1: 21mA @ 32MHz
2. It has only 2 UARTS (SCI); XMEGA A1: 8 USARTS
The Coldfire chips are not bad. But you cannot say in general that they are better. It depends on your project.
BTW: I am an AVR Freak! :mrgreen:
- Log in or register to post comments
TopKevin Rosenberg
http://b9.com
http://kevin.hypershots.com
- Log in or register to post comments
TopKevin Rosenberg
http://b9.com
http://kevin.hypershots.com
- Log in or register to post comments
TopPages