Moving from Mega to XMega programming, need help

Go To Last Post
31 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello All, 

 

Back after 5 years yay!

So I'm pretty familiar with Mega AVR, usually write in CodeVisionAvr.

Now I'd like to set foot in XMega territory but don't have that sheer amount of time for experimenting like I had 10 years ago, also my main job kinda drifted away from hardware engineering to financial systems but keepin it as hobby.

I'd really appreciate some tips or youtube/literature links about where to pay attention and what are the main differences.

 

Best Regards Y'All!

 

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

Welcome back!  You will find a lot has changed, you may want to look at the new attiny 0/1 series, or the newer DA/DB... etc parts, the AVR's have grown up now, and share a lot with the old xmega parts.

AS7 is still around, but now called MicroChip Studio 7, there is also MPLABx and platformio as well.

Jim

https://www.microchip.com/Develo...

https://www.microchip.com/Develo...

 

Just a few dev boards that include a programmer and hw debugger

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

Last Edited: Tue. Nov 24, 2020 - 09:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Start by reading AVR1000

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

@ ki0bk Thanks for the suggestion, I have an MCUZone ATXmega32A-AU board, is it good enough to start with?

 

@ clawson Looks like a nice entry point, will have a look :)

 

On a side note, this is probably a (very) future question but I'm planning have myself a "fun project platform" consisting of a Raspberry + Touchscreen acting as UI / complicated networking host and Xmega as realtime IO handler.

What do you think is the best interface between them?

UART seems to go max realistic 921600 with 100KB/s actual

SPI gives theoretical 8Mhz with 1MB/s but chip needs to run at 32Mhz and SPI got its share of problems on Raspberry side

USB is complicated in many ways and reported speeds vary from 500KB/s to 1MB/s

Some bizarre 8-bit parallel interface wheel re-invention, not sure if it's even worth discussing

 

Which of there do you think has best result per headache?

Last Edited: Tue. Nov 24, 2020 - 11:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did the same jump this year. Yes, there are differences, but after a couple of months and one product out with xmega32a4u, I'd say the two are different and yet feel very similar. In the beginning it is overwhelming and quickly becomes easier.

 

I use Atmel Studio 7. Most of my low-level development (where the MCU makes a difference) is reading the manual about what registers I need to set, then doing that with the defines from the MCU-specific header. The registers and fields are different, but the process is the same. Outside of that, the rest is the same - just C development.

 

ASF abstracts a lot of the HW details away. I try to avoid for simple things, but for complicated subsystems like USB, for example, it is useful. I'd often read how ASF does things and then simplify and do in my own way.

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

Delfistyaosani wrote:
usually write in CodeVisionAvr.
CodeVisionAVR has very recent updates for XMEGA.

Delfistyaosani wrote:
... literature links ...
Begin with XMEGA selection; the XMEGA's web page will have links to AVR10xx for CPU (etc) and AVR13xx for peripherals.

There's partial conversion of Atmel XMEGA PDF to Microchip web documents.

 


CodeVisionAVR V3 Revision History

 

AVR MCUs | Microchip Technology

[top of right column]

View our Quick Reference Guide to get a quick overview of Microchip's 8-bit AVR portfolio, peripheral integration, and migration options.

Online Docs (enter XMEGA)

 

"Dare to be naïve." - Buckminster Fuller

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

ki0bk wrote:
or the newer DA/DB... etc parts,
a comparison of megaAVR and AVR D :

What are the AVR28DA128 AVR32DA128 AVR48DA128 AVR64DA128 ?? | Page 5 | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

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

Delfistyaosani wrote:
What do you think is the best (sic) interface between them?

As always, that depends on what you want it to do.

 

What data rate do you actually need ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil

As mentioned before it's not for a specific project but something like a "platform template" I could later use as the base for different kinds of "control and sense" applications from simple sensor feed like serial CO2 / flipping a few relays to an ADS1258 going full nuts.

What I want to achieve is a framework with stable and as fast as possible packet-driven interface to not reinvent the wheel every time I want to poll a sensor, flip a relay, send a buffer to WS2812s or control an array of sprinklers.

USB looks like best candidate but I have no experience in either side of USB, is there some generic usb driver in linux like winusb that would just give me raw packet / pipe access?

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

Delfistyaosani wrote:
USB is complicated in many ways ...
and simplified by the several XMEGA USB API (Atmel UDI/ASF-USB (ASF3), ASF4?, LUFA, a few on GitHub)

USB is "relatively" simple at the packet level plus there's a sigrok decoder; simple in Linux and Python and simple in the XMEGA USB device controller.

USB classes make the complication though ease operating system interface especially on Windows.

Delfistyaosani wrote:
Which of there do you think has best result per headache?
SPI if XMEGA is on a Pi Hat else USB.

Some Ethernet MAC and Wi-Fi have the IP stack all the way to TCP with some to HTTP plus TLS; otherwise, the Microchip TCP/IP stack or lwIP though these consume some flash and RAM.

Single Pair Ethernet (SPE) exists for automotive PHY (100BASE-T1); industrial SPE PHY may arrive next year (10BASE-T1L to 1km)

 


ASF-USB Device Stack

Protocol decoders - sigrok

 

Single-pair Ethernet PHY Offers the Industry’s Leading Ultra-low TC10-compliant Sleep Current and is Functional Safety Ready | Microchip Technology

10Base-T1S schedule | Microchip

How 10BASE-T1L single-pair Ethernet brings the network edge closer with fewer cables - Analog - Technical articles - TI E2E support forums

 

"Dare to be naïve." - Buckminster Fuller

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

Delfistyaosani wrote:
is there some generic usb driver in linux like winusb that would just give me raw packet / pipe access?
Yes for USB packets; though this isn't XMEGA :

https://github.com/rrevans/ubaboot/blob/master/ubaboot.py#L154 (the loader for the ubaboot bootloader)

in

GitHub - rrevans/ubaboot: USB bootloader for atmega32u4 in 512 bytes (search for libusb)

 

"Dare to be naïve." - Buckminster Fuller

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

I made the jump to xmega and its really not as hard to wrap ones head around as you might think.  I took the plunge with the XMEGA32E5 and if I can get it to work, ANYONE can.

 

Don't sweat it.  Oh, one thing....if you try using Atmel START be warned...it doesn't always work...search my threads on XMEGA.  My suggestion is to read the datasheets...theres usually two.  One for the family, and the other for the device.  And you do need to read them both.

 

Once you do that, then write your program, and when you hit the brick wall come here and ask us for some assistance. 

 

Investing in a CodeVision license is also a worthwhile investments s the CV wizard is great for setting up the XMEGA. Ask me how I know this wink

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

As mentioned above the AVR DA, DB, ... series, (The DB can use an external Xtal, the DA can't), has a lot of the newer modules first released within the Xmega series.

An advantage is that they can run on 3V or 5V.

A disadvantage is that they are limited to 20 24 MHz, where as the Xmega can run at 32 MHz.

 

Keep in mind that the Xmegas are 3V only systems!

 

JC

 

Edit:  24 MHz... blush

Last Edited: Wed. Nov 25, 2020 - 05:21 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
if you try using Atmel START be warned...it doesn't always work...search my threads on XMEGA

Out of interest, have you grown to get on with START, or have you abandoned it?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For the CPU link I'd favour SPI. Surely the data rate available will be sufficient. It's perhaps the easiest of all interfaces to implement and program and unlike UART there's no concerns about matching clocks. 

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

DocJC wrote:

A disadvantage is that they are limited to 20 MHz, where as the Xmega can run at 32 MHz.

 

Nope, they are 24MHz.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

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

Also worth noting is that AVR Dx can run at 24MHz across the whole voltage range (1.8V - 5.5V)

Best regards,
Amund Aune
Applications Engineer @ Microchip Norway
(The postings on this site are my own and don’t necessarily represent Microchip’s positions, strategies, or opinions. For official Microchip Support, please visit https://microchipsupport.force.com/s/)

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

Well I favor using USART along with a good protocol like S.N.A.P, and with fractional baud rate generators, speed matching should not be a problem...

I have not yet made the jump to xmega, but giving a serious look at the DA/DB family, just picked up a nano to get started with, it's great that it comes with a built in debugger, so no other hardware is needed and it is breadboard friendly as well.  Programming is so easy, just drag/drop the file to the device.

 

Good luck with your projects, keep us informed with your progress.

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

clawson wrote:
SPI ... perhaps the easiest of all interfaces to implement 

although this would require implementing both Master & Slave.

 

implementing Slave is a path less travelled ...

 

does the RPi have an SPI Slave implementation?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:
... and with fractional baud rate generators, speed matching should not be a problem...
to which AVR D add auto-baud.

XMEGA internal clock can be calibrated given one of

  • Atmel-ICE or Power Debugger with a frequency counter
  • USB SOF

 

AN_8319 AVR1510: XMEGA-A1 Xplained training - XMEGA USART (FBRG : BSEL, BSCALE)

AN_8049 AVR1307: Using the XMEGA USART

USART | Migration from the megaAVR® to AVR® Dx Microcontroller Families

XMEGA Internal RC Oscillator Calibration

 

"Dare to be naïve." - Buckminster Fuller

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

awneil wrote:

jgmdesign wrote:
if you try using Atmel START be warned...it doesn't always work...search my threads on XMEGA

Out of interest, have you grown to get on with START, or have you abandoned it?

Abandoned it.  At least for XMEGA. 

 

As I suggested:

jgmdesign wrote:
Investing in a CodeVision license is also a worthwhile investments s the CV wizard is great for setting up the XMEGA. Ask me how I know this

The CV Wizard is simple, and very straightforward for the most part.  I understand why START does what it does, but again, as I learned the hard way with LarryVC, it is seriously flawed.  Especially with XMEGA and the newer XTINY and AVR8 series parts.  I DO use START with the SAM parts, but with some hand holding I have learned that I can set up a SAM without START and STARTS bloat.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

jgmdesign wrote:
Especially with XMEGA and the newer XTINY and AVR8 series parts.
Likewise for MCC is another code generator though minus XMEGA.

Come Join Us (MPLAB Now Supports AVRs) | Page 7 | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Wed. Nov 25, 2020 - 04:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

 

Keep in mind that the Xmegas are 3V only systems!

 

Operating voltage - 1.6 – 3.6V

• Operating frequency 

0 – 12MHz from 1.6V

0 – 32MHz from 2.7V

 

Guess it covers quite some spectrum?

No worries about 5V/485/LVDS/whatever signal systems, I'm used to level shifters drivers and so on :)

 

clawson wrote:
For the CPU link I'd favour SPI

 

Guess you're right, USB stack on xmega would be a pain especially for me having zero xp with usb whatsoever.

One thing to take care of will be RPi SPI not having an independent clock (WTF?) maybe there's a way to lock one specific core at specific clock and dedicate it to IO operations?

I hope operating one SPI in master and another in slave is supported.

Also as xmegas have lots of USARTs maybe leave SPI for data only and use USART as command console? Might help avoid congestion when data transfer is almost saturated with stuff I should have probably used an FPGA for

Last Edited: Wed. Nov 25, 2020 - 04:57 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Delfistyaosani wrote:
I'm used to level shifters drivers and so on :)

Level shifters are built in to the Dx parts.

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

ki0bk wrote:
Level shifters are built in to the Dx parts.

Sounds good, probably gonna replace where I'd use a mega328p with Dx BUT where the hell are cheap chinese bootleg core boards?

I tried searching ALL in-production DA/DB models and got zero results. Not on aliexpress, not even on MCUzone. 

The only thing available seems to be the EV35L43A board suspiciously suitable for smart vibrator integration and no way to buy on mainstream stores.

Buying from Digikey/Mouser using a US forwarder is straight robbery with shipping being more than item price. Any ideas?

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

Delfistyaosani wrote:
Buying from Digikey/Mouser using a US forwarder is straight robbery with shipping being more than item price. Any ideas?

Buy a 1000 and start you own local distribution! devil

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

ki0bk wrote:
Buy a 1000 and start you own local distribution! devil

 

Aaaand sell 2 units per year because hardware development in my country is a joke.

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

Delfistyaosani wrote:
because hardware development in my country is a joke.

time to start an Arduino club for teens.... 

 

The new Dx chips are bleeding edge still so no Chinese cloans yet.

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

Delfistyaosani wrote:
Any ideas?
A boat across the Black Sea?  Olimex though XMEGA128A1; so, Olimex SMT protoboard or a protoboard you find.

AVR DB, and DA, are in PDIP for 28 pins; the SMT packages aren't that difficult to solder by hand.

Might be able to score samples from Microchip (MCU's web page, upper right for 'Sampling Options")

You're only slightly closer to BFE cheeky

 

AVR128DB28 - 8-bit Microcontrollers

SMT-PROTOBOARD - Open Source Hardware Board (Olimex)

 

edit : currently, low minimums

https://www.microchipdirect.com/product/search/all/AVR128DB28

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Wed. Nov 25, 2020 - 10:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well I have one XMega board from MCUZone, hopefully some folks will release a Dx board meanwhile.

I can solder thinner pins but I HATE IT.

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

More XMEGA32A4U boards :

 

Spain :

ledoelectronics - Products - AVR (middle of next to last row)

 

Florida :

Development Boards | Gabotronics (one of the distributors is in Romania)

 

"Dare to be naïve." - Buckminster Fuller