can anyone analys this code or give codevision equivalent
Elsewhere in that file is:
# define __SPM_REG SPMCSR or # define __SPM_REG SPMCR
also:
#define __BOOT_SIGROW_READ (_BV(__SPM_ENABLE) | _BV(SIGRD))
also
# define __SPM_ENABLE SPMEN or # define __SPM_ENABLE SELFPRGEN
So the code effectively says:
uint8_t boot_signature_byte_get(const __flash uint8_t * addr) { __SPM_REG = __BOOT_SIGROW_READ; return *addr; }
That is still in "GCC format" (the __flash is a GCC thing) but CV should have some equivalent of "__flash" (it might even be __flash in fact!).
Replace __SPM_REG and __BOOTSIGROW_READ in that when you know whether the AVR you are trying to use has SPMCR or SPMCSR and SPEN or SELFPRGEN.
Is this just a continuation of your other thread - which has outstanding questions:
https://www.avrfreaks.net/forum/programmer-show-me-ics-signature
Hi sorry im researching about this topic and i cant ask my question there
Is this just a continuation of your other thread - which has outstanding questions:
And the other-other thread https://www.avrfreaks.net/forum/c... where OP gave an x51 fragment?
Indeed, you gurus will need to reverse-translate sophisticated [to me] GCC inline assembler chunks -- I ran out of eye of newt. That said, OP is posing fairly low-level constructs/concepts out of context. In this thread, there is no mention of which AVR model. Other models may not even have an SPM reg, or values may be different.
-- read the datasheet section on how the read the signature row info.
-- if it indeed involves a flash read, then learn how to do that in CV.
-- combine the two.
can anyone ... or give codevision equivalent
Hah -- found it. David Prentice solved this (and related) problems some years ago...
https://www.avrfreaks.net/forum/p...
uint8_t boot_signature_byte_get(uint16_t address) { #asm ldd r31, y+1; //move Pagedata MSB reg 1 ldd r30, y+0; //move Pagedata LSB reg 1 ldi r26, 33; sts SPMCRAddr, r26; //move spmcrval to SPM control register lpm r30, z; //store program memory #endasm }
Making it inline is left as an exercise for the student.
And -- in a current CV version, the parameter loaded into Z might not be on the stack.
And -- the "33" constant may not be the same for your target AVR model.
And -- other caveats about possible save-restore of registers.
Is there a 4-cycle limitation? If so, probably why the C sequence that Cliff showed is not used directly -- after seting SPMxCR value, a straight flash read might not get to the LPM in four cycles if the parameter bytes are read off the stack.
the "33" constant may not be the same for your target AVR model.
Again: thus defeating the object of this code to identify the model of the processor!!
https://www.avrfreaks.net/comment...
https://www.avrfreaks.net/comment...
Again: thus defeating the object of this code to identify the model of the processor!!
Do we know that we are on the same snipe hunt as finding what an arbitrary unmarked IC is?
And for the benefit of the doubt, OP could be using signature as an example...perhaps it is cal data OP is after.
In digging out the CV equivalent of spm_boot.h and equivalent, some pertinent prior discussions were found. One can winnow down to find the model expecially with a limited universe to choose from. If a model like Mega48 with no sig row read support, then something other than 1e will be found. And so on.
Continuing with that, there are only so many AVR8 models with sig row read functionality. There are only so many possible addresses for SPMCR/SPMCSR. There will only be so many combinations for the magic bits needed.
[another complication that I found is the Mega88-family datasheet and chip-includes having wrong/incomplete information on this feature.
Do we know that we are on the same snipe hunt as finding what an arbitrary unmarked IC is?
To be fair, no - not for sure.
The OP has been asked to clarify but, so far, has not.
Again: thus defeating the object of this code to identify the model of the processor!!
I'm reminded of chemistry lab assignment: Identify the unknown substance in the container (usually a tube of fluid).
One then carries out a number of tests to play the 20 Questions game with the fluid. And indeed, some/many will be n/a.
but those are external tests applied to the sample - which is rather different from the sample trying to identify itself internally ...
"I'm pink, therefore I'm Spam..."