megaAVR 0-series

Go To Last Post
173 posts / 0 new

Pages

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

Some things are not very logical.
- Why new 8/16/32er Tinys have the double amount of ADC's than brandnew Megas here?
- Mega0 Interrupt-Table looks very messy.
- The labeling on the housings is still Atmel...

Last Edited: Fri. Nov 23, 2018 - 07:31 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Von Neuman architecture compilers (including gcc) generally just put all "const" data (inc literal strings) into ROM/Flash, or have an option to do so.  Perhaps whatever hack avr-gcc uses to put const data in RAM can simply be turned off?

 

Edit:  Oh wait - perhaps not.   Addresses in .text are zero-based, but when accessed as data, they appear at a different offset...

 

Followup.  Apparently I was worried about an issues that has been solved for a long time.

Avr-gcc already has an "architecture" defined for AVRs like the ATmega4809

"const" data, including literal strings, goes off into the .rodata section, with symbols appropriately offset and accessible via "ld" instructions.

If you're using one of the chips with a unified 64k address space, you shouldn't need PROGMEM or __flash...

 

-mmcu=atxmega3

avrxmega3

“XMEGA” devices with up to 64 KiB of combined program memory and RAM, and with program memory visible in the RAM address space.

This does indeed appear to do the desirable thing with data that is merely "const" (including literal strings), and subsequent tools also behave as desired.

 

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <stdio.h>

const char s[] = "this is a const string";
const char PROGMEM p[] = "this is a progmem string";
const char __attribute__((section(".text"))) t[] = "this is a .text string";
const char __flash f[] = "this is a __flash string";

int main() {
    printf("%s\n", s);
    printf("%s\n", p);
    printf("%s\n", t);
    printf("this is a constant literal string.");
}

Compile with "avr-gcc -mmcu=atmega4809 -g -Os foo.c", copy to .hex with "avr-objcopy -O ihex -R .eeprom a.out a.hex"

 

(edited) "avr-nm -S -n" output:

000000a0 T __trampolines_end
000000a0 T __trampolines_start
  :
000000a0 00000019 T f          *** __flash string ***
000000b9 00000019 T p          *** progmem string ***
000000d2 T __ctors_end
000000d2 W __init
000000de 00000010 T __do_clear_bss
000000f6 T __bad_interrupt
000000f6 W __vector_1
  :
000000f6 W __vector_9
000000fa 00000017 T t
00000112 0000002e T main
  :
00000752 t __stop_program
00000754 T _etext
  :
00004000 A __RODATA_PM_OFFSET__
00004754 00000017 R s       *** const string *** (note == _etext!) ***

 

Edited Output from "avr-objdump -s a.out":

Contents of section .text:
   :
 0090 0c947b00 0c947b00 0c947b00 0c947b00  ..{...{...{...{.
 00a0 74686973 20697320 61205f5f 666c6173  this is a __flas
 00b0 68207374 72696e67 00746869 73206973  h string.this is
 00c0 20612070 726f676d 656d2073 7472696e   a progmem strin
 00d0 67001124 1fbecfef cdbfdfe3 debf28e2  g..$..........(.
 00e0 a0e0b8e2 01c01d92 a630b207 e1f70e94  .........0......
 00f0 89000c94 a8030c94 00007468 69732069  ..........this i
 0100 73206120 2e746578 74207374 72696e67  s a .text string
 0110 000084e5 97e40e94 b60089eb 90e00e94  ................
   :

Contents of section .rodata:
 4754 74686973 20697320 6120636f 6e737420  this is a const 
 4764 73747269 6e670074 68697320 69732061  string.this is a
 4774 20636f6e 7374616e 74206c69 74657261   constant litera
 4784 6c207374 72696e67 2e00               l string..        *** Where we want it! ***

 

edited output from "avr-objdump -s a.hex"

Contents of section .sec1:
 0000 0c946900 0c947b00 0c947b00 0c947b00  ..i...{...{...{.
   :
 00a0 74686973 20697320 61205f5f 666c6173  this is a __flas
 00b0 68207374 72696e67 00746869 73206973  h string.this is
 00c0 20612070 726f676d 656d2073 7472696e   a progmem strin
 00d0 67001124 1fbecfef cdbfdfe3 debf28e2  g..$..........(.
 00e0 a0e0b8e2 01c01d92 a630b207 e1f70e94  .........0......
 00f0 89000c94 a8030c94 00007468 69732069  ..........this i
 0100 73206120 2e746578 74207374 72696e67  s a .text string
   :
 0740 aa81b981 ce0fd11d cdbfdebf ed010895  ................
 0750 f894ffcf 74686973 20697320 6120636f  ....this is a co   *** Where we want
 0760 6e737420 73747269 6e670074 68697320  nst string.this    ***  this in flash
 0770 69732061 20636f6e 7374616e 74206c69  is a constant li
 0780 74657261 6c207374 72696e67 2e00      teral string..  

 

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

Service Pack 7.10.3

...

  • Support has been added for the following devices:
    ATA5787, ATA5835, ATmega3208, ATmega3209, ATmega4808, and ATmega4809.

...

That is not the question here.

That could be true with just with adding correct memory and IO model. (the chips still have LPM)

 

The question is if the compiler use that the flash also is memory mapped. So instead of only Z as a pointer also X and Y can be used.

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

Hey, just a theoretical question - in older AVRs Flash, EEPROM and RAM were separated but now they are "together" in one address space. So is it possible to run program from RAM or EEPROM?

extronic.pl

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

extronic wrote:

...but now they are "together" in one address space. So is it possible to run program from RAM or EEPROM?

 

They are not together, they are still two separate entities. All that has changed is that the code space is now visible within a region of the data space memory map. See figure 5-1 in the datasheet. Note that the inverse, with data visible within the code space, does not happen.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "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." - Heater's ex-boss

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

one could hope that there would come a new version of AT94K chips, they are so far the only AVR's that run code from RAM

 

why would you run code from RAM in most cases a simple interpreter would do a fine job (about the speed of C code).

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

You're right. Thanks for your explanation.

extronic.pl

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

No. Take a look at the memory map for the Mega4809 for example, the program memory is placed at the top of the memory space. Since the program counter can only address the code space, it can't see the other memory types that are at lower addresses.

 

However, to address 48k of flash (24k words) the PC must be 15 bit. So we can place values addressing 48k-64k there. I wonder how that is handled...

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

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

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

It's actually surprise me that a 4809 is 14% faster than a XMEGA (at same clk speed)

 

add:

But since they use the IAR compiler it's not relevant for many of us.

Last Edited: Fri. Nov 30, 2018 - 03:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sparrow2 wrote:

But since they use the IAR compiler it's not relevant for many of us.

 

You could always download Coremark and compile with your chosen GCC-AVR version.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "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." - Heater's ex-boss

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

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

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

sparrow2 wrote:
It's actually surprise me that a 4809 is 14% faster than a XMEGA (at same clk speed)
From the megaAVR 0-series manual in notes for the instruction set summary :

2. One extra cycle must be added when accessing lower (64 bytes of) I/O space.

Likewise in the XMEGA AU manual :

2. One extra cycle must be added when accessing Internal SRAM.

BUS Matrix is apparently improved simpler for megaAVR 0-series versus XMEGA (XMEGA AU has a DMA controller as an additional bus master)

 

Edit: DMA

 

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

Last Edited: Sat. Dec 1, 2018 - 04:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

http://packs.download.atmel.com/#collapse-Atmel-ATmega-DFP-pdsc

1.3.300 (2018-11-27)

...

Corrected TCA0 event names for ATmega4809|4808|3209|3208|1609|1608|809|808. Added linker scripts for ATmega809. 

...

 

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

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

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

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

Curiosity Nano boards are on sale through 3-Jan'19 :

https://plus.google.com/+MicrochipTech/posts/fCjvY9JaFWc

Have yourself a merry little….development board! Enjoy 25% off one of our Curiosity Nano boards from now through January 3, 2019. Offering full programming and debugging capabilities, the ATmega4809 and the PIC16F18446 Nano boards offer complete support for your next design. They're also small enough to keep in your pocket or hang on your tree. Click here to place your order and use code NANOHOLIDAY at checkout: https://mchp.us/2LdtHLc

...

the URL in that post :

Microchip Technology - Development Tools - Curiosity Nano Boards

 

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

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

Arduino Bluetooth Low Energy version 0.1.0 was released 13-Nov'18 :

GitHub - arduino-libraries/ArduinoBLE

...

Enables BLE connectivity on the Arduino MKR WiFi 1010 and Arduino UNO WiFi Rev.2.

This library currently supports creating a BLE peripheral.

...

 

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

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

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

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

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

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

Cool, that guy figured out a way of combining my jtag2updi UPDI programmer with the Arduino Uno WiFi R2 software package, that supports Mega4809.

I suspected it could be done in theory, but never actually decided to do it, my knowledge of the intricacies of Arduino IDE configuration files is not that good.

 

I'll link to his method: https://hackaday.io/project/1348...

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

 

Courageous decision to ditch the offset connectors

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

angelu wrote:
Courageous decision to ditch the offset connectors

So not Arduino shield compatible.....

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274

 

 

 

Pages