Author Topic: megaAVR 0-Series ATMEGA4809 and ATMEGA4808 makes me feel like I am starting over  (Read 1838 times)

0 Members and 2 Guests are viewing this topic.

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3513
  • Country: us
  • If you want more money, be more valuable.
I designed a dev PCB with the new-ish ATMEGA4809 8bit AVR MCU. The specs and new features look pretty nice, but I totally underestimated how much the new architecture would impact firmware development. I have completed many dozens of ATMEGA projects over the past 5-6 years and compiled a lot of easily re-usable code. This new MCU has a very different way of handling peripherals and the required code is totally different.

The first challenge I am trying to get through is a TWI / I2C driver and then move onto the ADC's. I have spent a day so far on the I2C and that is really only enough for me to have learned I need to start from scratch.

Is anyone aware of some app notes, examples, videos, or libraries to help get I2C Master implemented on the ATMEGA4808 0-Series? This MCU can only be awesome if I can program it, lol.
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 1225
  • Country: pl
Seems related to ATtiny 1-series and a lot of the tech inside of them is supposedly borrowed from the Xmega line. Maybe this will be of some help.

Sorry, can't say much more. I have bought a few for the new features but haven't used them yet.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3066
  • Country: us
Heh.  Well, there's the Arduino code (which seems to have been written by Microchip (Atmel?)):https://github.com/arduino/ArduinoCore-megaavr/blob/master/libraries/Wire/src/utility/twi.c
I've been doing stuff with the UART.  It's not THAT different, aside from the whole structure-based access.  (Though the things I'm doing with the UART are much simpler than I2C tends to be...)
The NVM Controller is pretty sweet, compared to the things you had to do for the same goals on an old AVR.
 

Offline richardman

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: us
It's similar to the XMega's, unfortunately the XMega is not as popular as it could be, so....
// richard http://imagecraft.com/
JumpStart C++ for Cortex (compiler/IDE/debugger): the fastest easiest way to get productive on Cortex-M.
Smart.IO: phone App for embedded systems with no app or wireless coding
 

Offline imo

  • Super Contributor
  • ***
  • Posts: 2019
  • Country: 00
Who is the targeted audience with this new series?
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 1225
  • Country: pl
<tinfoil hat mode ON>
Maybe they started to sell Xmegas under the old brands to slowly migrate everybody onto Xmegas :scared:

Truth be told, at least on paper, these new models appear to be superior chips. More peripherals, one pin programming interface realized with UART, memory-mapped flash, the event system...

And they even tend to be cheaper, like the 8-pin ATtiny212 which beats the old ATtiny13A on price and specs.

One obvious disadvantage is more registers which means few useful ones are accessible in 1 clock cycle anymore.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 3712
  • Country: fr
Truth be told, at least on paper, these new models appear to be superior chips.

Well, compared to the older models, yes. But outside of this context, "superior chips" would be a bit of a stretch. ;D
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3513
  • Country: us
  • If you want more money, be more valuable.
<tinfoil hat mode ON>
Maybe they started to sell Xmegas under the old brands to slowly migrate everybody onto Xmegas :scared:

Truth be told, at least on paper, these new models appear to be superior chips. More peripherals, one pin programming interface realized with UART, memory-mapped flash, the event system...

And they even tend to be cheaper, like the 8-pin ATtiny212 which beats the old ATtiny13A on price and specs.

One obvious disadvantage is more registers which means few useful ones are accessible in 1 clock cycle anymore.

I feel that they are hoping to avoid scaring customers with a new name, although these new chips are really a new family and should be treated as such.
Relative to the older ATMEGAS, they are definitely superior. Lot's of welcome improvements, but sadly at the cost of having to refactor code after going through the initial learning curve that was not immediately obvious. I should have looked closer for sure while I was initially choosing these, but in the end, I think the new features will outweigh the code updates.

The price is definitely nice on these. My first project is fairly priced sensitive so that is a bonus, but really I chose it for the apparent improvements in real-time control I am expecting with the control independent peripherals [CIP]. That feature will offload some pressure for me to have super-tight code to accomplish time-sensitive tasks.

Anyway....guessing I will spend the next couple of days becoming friends with these little chips. I need solid I2C, ADC, and UART modules right off the bat. Everything else can be learned as needed. Surprised how little information there is after a year on the market. I was quite spoiled with the massive resources for developing the older ATMEGA AVR's. It was so easy to find discussions and examples for just about anything.
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3513
  • Country: us
  • If you want more money, be more valuable.
Truth be told, at least on paper, these new models appear to be superior chips.

Well, compared to the older models, yes. But outside of this context, "superior chips" would be a bit of a stretch. ;D

Perhaps excellent bang for the buck is a good way to describe these. They are cheap.
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 1225
  • Country: pl
It also appears that ARM has nothing to offer in SOIC8 or SOT23, if that's your thing.

As I said before, they are supposedly derived from Xmegas. So perhaps you can find some info/examples for those, and compare if it matches the datasheet of the new parts.
Disclaimer: I have never even read anything about Xmegas, let alone program one :-DD
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 3712
  • Country: fr
It also appears that ARM has nothing to offer in SOIC8 or SOT23, if that's your thing.

Oh, you would think that... https://www.cypress.com/part/cy8c4014sxi-420t
 :D

And there are of course other lines of MCUs such as the PIC10F/12F.
 

Online up8051

  • Regular Contributor
  • *
  • Posts: 74
  • Country: pl
Cypress chips are rather expensive:

Cypress Cy8C4014SXI 2,16$
Microchip ATTINY402   0,41$
 

Offline lucazader

  • Regular Contributor
  • *
  • Posts: 127
  • Country: nz
ST has some new much smaller packages in their new G0 lineup.

Like the STM32G030J6 can be had for about $0.40 in volume and is an 8 pin soic package. (https://www.digikey.com/product-detail/en/stmicroelectronics/STM32G030J6M6/STM32G030J6M6-ND/10326687)

Admittedly this is a very new part, and until more recently there have been very limited choices for very small pin count ARM based micros.
I think this is going to change over the next little while as chip makers move production to smaller process nodes, enabling smaller cheaper processor die's for parts like the above.

Also while the CY8C4014 migth be expensive. the CY8C4013 is much more affordable.
$0.24 in single quantity on digikey (https://www.digikey.com/product-detail/en/cypress-semiconductor-corp/CY8C4013SXI-410/2015-CY8C4013SXI-410-ND/9771769)
« Last Edit: September 14, 2019, 01:04:51 am by lucazader »
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3513
  • Country: us
  • If you want more money, be more valuable.
I managed to get enough guidance from the online tool Atmel START: https://start.atmel.com/#dashboard

At first, I thought it was a gimmick, but it actually helped me build examples based on the device I have and the application. The code generated is a bit thick but every line is commented so I could easily follow and adapt it to what I was after. I am not a top-notch coder since I only code about 15% of my productive time - so this boost was a welcome time saver.

Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 
The following users thanked this post: Someone

Offline RES

  • Regular Contributor
  • *
  • Posts: 77
  • Country: 00
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 1225
  • Country: pl
The STM32G0 looks like a viable upgrade indeed, with 32 bit core and more MHz. I wonder how it stacks up against AVRs in terms of I/O access latency? Can it run the peripherals at full 64MHz speed? How many clocks to set a pin or read some peripheral register?

AFAIK a programming dongle is required to get anything done on STMs?

Is there any equivalent of AVR's event system in the ARM world? Some things I would like to do and I believe can be done by the new AVRs:
- sample and synchronize an external signal to the system clock, distribute it to multiple peripherals, guarantee arrival in the same clock cycle
- distribute a strobe to multiple peripherals to perform actions simultaneously, like atomically capture the counts of multiple timers
- cascade arbitrary number of timers, schedule input capture on timer A by timer B
 

Online jhpadjustable

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: us
  • Salt 'n' pepper beard
AFAIK a programming dongle is required to get anything done on STMs?
Any SWD pod would surely do. But STLink v2 clones are $2 on Aliexpress. AFAIK all STM32 chips have a bootloader in ROM that can accept commands to erase/program/verify/lock over async serial and usually other available interfaces.
Quote
Is there any equivalent of AVR's event system in the ARM world? Some things I would like to do and I believe can be done by the new AVRs:
- sample and synchronize an external signal to the system clock, distribute it to multiple peripherals, guarantee arrival in the same clock cycle
- distribute a strobe to multiple peripherals to perform actions simultaneously, like atomically capture the counts of multiple timers
- cascade arbitrary number of timers, schedule input capture on timer A by timer B
The timers and peripherals in the ARM MCU world vary somewhat by vendor. Cypress' ARM PSoC 4100/4200 series appear to have extensive core independence and versatile internal signal routing. Some of them have FPGA-like logic blocks. I'm pretty sure your examples would be straightforward. ST's timers are complex in themselves and decently automatable, but the interface with the rest of the system is pretty traditional. Some of your examples might be possible, with caveats.
"There are more things in heaven and earth, Arduino, than are dreamt of in your philosophy."
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3066
  • Country: us
Quote
Is there any equivalent of AVR's event system in the ARM world?
Well, the Atmel (Microchip) SAMD series have what looks to be the SAME event system as the new AVRs...Packages as small as SO14, and down around the $1 mark.
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 1225
  • Country: pl
Very similar and more or less functionally equivalent though not exactly identical.
Atmel clearly never cared about making their peripherals consistent between different MCU families :)
« Last Edit: September 15, 2019, 01:31:29 pm by magic »
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 6412
  • Country: de
There are some natural differences between a 8 bit and 32 bit CPU. So things have to be different in some places (e.g. no extra buffer registers for atomic access needed with the ARM). Also the internal timing / maximum clock is different.

I have not used the old Xmega series, but AFAIR the periphery was also more ARM like than like the old AVRs.
Still the ADC is back to 10 Bits and maximum supply voltage to 5 V.
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 1225
  • Country: pl
Heh.  Well, there's the Arduino code (which seems to have been written by Microchip (Atmel?)):https://github.com/arduino/ArduinoCore-megaavr/blob/master/libraries/Wire/src/utility/twi.c
I just stumbled upon this Arduino library too and realized it's the one you already linked. Their repo also has a driver for SPI.
Apparently there are already a few Arduino boards using new AVRs. I guess this answers the question who is going to buy those chips. The Arduino crowd won't even notice a difference, unless they do but then it's too late :D

There are some natural differences between a 8 bit and 32 bit CPU. So things have to be different in some places (e.g. no extra buffer registers for atomic access needed with the ARM). Also the internal timing / maximum clock is different.
Of course, but we are talking completely different peripherals with different feature sets and everything, not just small tweaks.
 

Offline MarkR42

  • Contributor
  • Posts: 29
  • Country: gb
It seems that the atmega 4809 is available in a PDIP-40 package, old-school. Everything else in the range (and most others) is surface mount.

The megaavr 0-series are a lot like the attiny 1-series which have been around a bit longer, https://jaycarlson.net/pf/atmel-microchip-tinyavr-1-series/

I've been using the attiny1614 and its peripherals are very similar (there are slightly fewer of everything, but it's much the same).

There are some useful examples of the attiny1614 here https://github.com/chromia/attiny1614example which probably work unmodified or with few changes on the mega 4809.

I'm most enjoying the way that they seem to have managed to standardise the peripherals on these new lines of MCUs, they're much more consistent and predictable than the older ones, every (enable-able) device has an enable bit, in its CTRLA register.

I use the toolchain https://github.com/vladbelous/tinyAVR_gcc_setup but I tried the atmel studio too, that's ok.

Also the updi programming interface (just 1 wire!) is nicer than the thing that arduino etc use (3 wires?) - and the reset pin is not required for normal programming.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3066
  • Country: us
Quote
who is going to buy those chips.
They're cheap.  The ATmega4809 looks to be the cheapest 40-pin DIP AVR you can get, at normal prices (Mouser, q1)(Digikey seems to be having a sale on m164 and m324...)  And it's generally more powerful, too.
And the 8-pin ATtiny4x2 chips put the existing low-end 8bit chips to shame.  4x the memory of an ATtiny13, and it's got peripherals, and it's half the price.  About 1/3 the price of the ATtiny85 (which still doesn't have a UART or real I2C.)
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 6540
That new Atmel logo still puts me off every time I see it on their parts... looks more like a cheap Chinese brand than the "serious" logo they had before:

 

Offline techman-001

  • Frequent Contributor
  • **
  • Posts: 515
  • Country: au
  • Electronics technician for the last 47 years
Quote
who is going to buy those chips.
They're cheap.  The ATmega4809 looks to be the cheapest 40-pin DIP AVR you can get, at normal prices (Mouser, q1)(Digikey seems to be having a sale on m164 and m324...)  And it's generally more powerful, too.
And the 8-pin ATtiny4x2 chips put the existing low-end 8bit chips to shame.  4x the memory of an ATtiny13, and it's got peripherals, and it's half the price.  About 1/3 the price of the ATtiny85 (which still doesn't have a UART or real I2C.)

I prefer my 40 pin 32 bit STM32 for $0.95 instead of a 8 bit ATmega4809 for $3.49 :)


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf