Thoughts on my first XMEGA project

Go To Last Post
62 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That's it, thanks! :)
Actually I already set the CLK_SCLKSEL_PLL but I forgot the wait loop.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cool, that the additional code example helped.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kmr wrote:
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)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ce wrote:
1. BSCALE=-5; BSEL=3301 -> 19376 baud
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!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ce wrote:
A Xmega update would be great!
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:
AVR 58 > (optimal-bsel-bscale 32000000 19200)
3301
-5
"Normal"
0.010001659

To 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:

AVR 59 > (optimal-bsel-bscale 32000000 19200 :report 2)
Mode   BSCALE BSEL       Baud    Error
--------------------------------------
Normal     -5 3301    19201.9   0.010%
Normal     -4 1651    19196.2  -0.020%
Normal     -3  825    19207.7   0.040%
Normal     -2  413    19184.7  -0.080%
Normal     -1  206    19230.8   0.160%
Normal      0  103    19405.7   1.071%
Double     -1 3331    19201.9   0.010%
Double      0 1666    19196.2  -0.020%
Double      1  832    19219.2   0.100%
Double      2  416    19219.2   0.100%
Double      3  207    19312.0   0.583%
Double      4  103    19405.7   1.071%
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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).

  • 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!

I love Digital
and you who involved in it!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Although 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:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ce wrote:
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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ali_dehbidi wrote:
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.

Pages