I don't want to write my own code, I just want to see example. Funny I don't see any code, the only one I saw is this.Hi,
in the instruction set manual there are assembler examples for using SPM.
****
Do you want to write your own bootloader, or why do you ask?
In either case: try to read bootloader source code.
Klaus
Thanks KlausHi,
I refer to this document:
Atmel AVR Instruction Set Manual [OTHER]
Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016
Page 169 f
Even the Atmeta328p Datasheet shows this:
25.2.5 Simple Assembly Code Example for a Boot Loader
Both sections are easy to find:
* Open the document in the PDF reader
* use the PDF reader´s search function for "SPM"
* step through the different "SPM" loactions
Klaus
Or: your datasheet is different.Your data sheet is different.
SPM is an instruction with different features on different AVRs. Thus you can find "general" information in the AVR general instruction set....while you need to read the 328p datasheet for the features that belong to the 328p microcontroller.The assembly instruction datasheet on SPM is really bad,
It surely mentions that it can do a "page write". Indeed 48 times in the 328p datasheet.it never mention that SPM can do loops
I don't understand your thinking. Every instruction is performed automatically.Nothing on the datasheet said that it's automatic
Again: Why do you call it "loop", while the datasheet says it is performed simultaneously. The datasheet does not talk about a loop, it´s just you.So in this case with page erase, it only need to execute SPM instruction one time, the MPU will do the loop to write FFFFH into all 64 locations(128bytes) according to the start address in Z registers? I just want to confirm this.
I´m fine with this.I disagree with you.
No need to shout.As a hardware designer more and novice in in software or firmware. IT IS VERY IMPORTANT TO KNOW HOW THE HARDWARD PERFORM WITH A SOFTWARE COMMEND.
This is your thinking like an external FLASH chip is wired to a microprocessor.I said SPM perform in a loop to erase 64 words, IT HAS TO BE. memory is accessed by address, data bus AND with Rd and Wr signal.
You take the words right of my mouth!THE BIGGEST MISTAKE PEOPLE MAKE IS THE PROGRAMMER ACTUALLY THINK OF IT LIKE SOFTWARE WHEN WRITING THE VHDL OR AHDL. THAT'S WHERE IT BECOMES DEADLY. Most that wrote VHDL/AHDL do not think of the hardware, signal waveform timing. THEY DON’T THINK OF IT AS REAL TIME.
I understand the reason because after the SPM Z is pointing to the beginning of next page. So they subtract the page size to get back to the starting of the last page that was being written.no, with the ADIW instruction you are pointing to the next element, once you get to fill the last element of the page, the Z pointer will point to the next page (the first element at x00) so, to finalize the page write you need to point again to the previous page we just got out. the easiest way is to substract a pagesize to the pointer.
why you say? you can squeeze 2 bytes by only having the Zpointer for all the operations, so no need to have a Start_L and Start_H registers to keep track of the start of each page. (remember, you have many pages, but most of the time you'll write them sequentially)
who is pointing the the data buffer? Y registers(R28:R29), you can see loading from Y pointer (and increment Y+) to R0 and R1 to proceed to the writing
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?