For many years I wrote in assembler and had the option with the .locate or org statements to put code at a specific address. For example I want to put a block of data at 0xD000, how do I do that with the IDE. There are several posts showing this is not possible but the last i found was a few years back so with all the changes has it happened?
Use C++ pointers.
Why?
Usually, you would create a section in the linker script at the appropriate address, and then use __attribute__((section("yoursection")))
to place a variable into that section.
Just using a pointer to an absolute address won't work, because the memory might be reserved for the stack or the heap (or something else that you don't want to overwrite), that's why you need to make sure you reserve the section in the memory layout specified in the linker script.
No clue. But I am curious - if you are writing in C/C++ how would the need to do arise?
a7
I am writing data in FRAM modules and the MEGA has room in FLASH to hold the tables, they can get upto about 30K. I then write them into the FRAM which I then use on a Nano. FRAM and Nanos are inexpensive and compact vs a Mega. It takes a little over 30 seconds to write a 32K x 8 FRAM. Currently I get the pointer to where it is stored then move it from there. It is much easier to examine when on even 16 bit boundaries.
Does the ATmega328P allow mapping external (F)RAM into its address space?
Edit: At first sight, it doesn't (the ATmega2560 does), so how are you using a pointer to access the external memory?
Sorry but no, the ATmega328P chip does not bring out its address and data bus plus control lines. It comes with SPI, Parallel, and I2C. I use the I2C, treat it the same as EEPROM but there are no delays. The I2C 32Kx8 I use is mapped from 0 to 0x7FFF. With I2C I can transfer as many bytes as I want in one access period. What it does do is give me a lot more RAM as variables can be stored in flash but access is slower. Great place to store messages, menus, etc. as the HMI normally is slow by design.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.