Point take that is only a problem on the newer once. (and we all assume that a read from undefined flash just is remapped).
I don't assume that. Not only have I read about other people's tests, I've tested flash address wraparound on several tiny/mega AVRs. It's also well documented (search for " --pmem-wrap-around ")
In the usual case with power of two flash, I believe that wraparound is implicitly guaranateed.
The datasheet spcifies what bits of Z are used: just enough to cover the entire range.
I thought that the "newer" GCC facilities were cycle-accurate?
In C, via __builtin_avr_delay_cycles, yes. It's a GCC extension.
For my purposes, I needed assembly language, and I needed something that would use a minimum of code space via a (re)callable subroutine. Looks like the OP wants assembly language, too.
theusch wrote:
Didn't OP want run-time?
Where did he say that, exactly?
"Experience is what enables you to recognise a mistake the second time you make it."
"Good judgement comes from experience. Experience comes from bad judgement."
"Wisdom is always wont to arrive late, and to be a little approximate on first possession."
"When you hear hoofbeats, think horses, not unicorns."
"Fast. Cheap. Good. Pick two."
"We see a lot of arses on handlebars around here." - [J Ekdahl]
I don't see how 'runtime' is implied. Macros take parameters, too.
C'mon; you are stretching things now, aren't you? Are you arguing that there is, then, no difference between e.g. delay routines that are expanded at build time such as your example code, and those that pass a parameter at run-time?
You can put lipstick on a pig, but it is still a pig.
I've never met a pig I didn't like, as long as you have some salt and pepper.
Of course not. Why be specious? This is irrelevant to the thread. If the OP can achieve what they're looking for by extracting from my or your or anyone else's posts, what difference does it make?
theusch wrote:
C'mon; you are stretching things now, aren't you?
If you say so.
Macros have parameters, as you well know, and as has already been established in this thread. A suggestion was made in #41 to examine and emulate _delay_nn macros' code generation, but you don't have a problem with that.
theusch wrote:
So you can't use _builtin_xxx except in a C source? [not a GCC person]
Possibly, but none that I know of. It is a C extension.
theusch wrote:
I quoted, from #1. At least that was the way I took it.
" I want to write delay routine that is accepting delay time ..."
Have you >>looked<< at the code in #46? It is a macro, yes, but it generates a call to a subroutine.
"Experience is what enables you to recognise a mistake the second time you make it."
"Good judgement comes from experience. Experience comes from bad judgement."
"Wisdom is always wont to arrive late, and to be a little approximate on first possession."
"When you hear hoofbeats, think horses, not unicorns."
"Fast. Cheap. Good. Pick two."
"We see a lot of arses on handlebars around here." - [J Ekdahl]
Have you >>looked<< at the code in #46? It is a macro, yes, but it generates a call to a subroutine.
Perhaps I'm getting too old, or the virus is affecting me.
joeymorin wrote:
Use like this:
delay_c 46
is, to me, at build time. It cannot accept a parameter at run time...let's say 8-bit (for convenience) ADCH, can it?
Why am I having such a hard time grasping how
joeymorin wrote:
Of course not. Why be specious? This is irrelevant to the thread. If the OP can achieve what they're looking for by extracting from my or your or anyone else's posts, what difference does it make?
is relevent to the thread? Are you saying that you code can take, e.g. the value in ADCH at run time after a conversion and produce a proportional delay? I thought that is what OP was asking for in #1. Which post can be extracted to produce this varying ADCH-proportional delay?
You can put lipstick on a pig, but it is still a pig.
I've never met a pig I didn't like, as long as you have some salt and pepper.
Posted by joeymorin: Fri. Apr 17, 2020 - 08:51 PM(Reply to #62)
1
2
3
4
5
Total votes: 0
theusch wrote:
Why am I having such a hard time grasping how
How should I know?
The first (and only) mention of 'runtime' was by you.
The first (and only) mention of ADCH was by you.
theusch wrote:
Perhaps I'm getting too old, or the virus is affecting me.
Look at the macro in #46 again. It generates two instructions. An 'ldi' and an 'rcall'. If you wish, you can rcall delay_loop yourself, having arranged to load tmp with whatever value you wish, perhaps with the contents of ADCH.
The code in #46 was offered with:
Here's how I did cycle-accurate delays in one project:
No other claims were made.
I fail to understand the value of this diversion. It is not helping the OP. Who, as you can see, hasn't been here for a while.
"Experience is what enables you to recognise a mistake the second time you make it."
"Good judgement comes from experience. Experience comes from bad judgement."
"Wisdom is always wont to arrive late, and to be a little approximate on first possession."
"When you hear hoofbeats, think horses, not unicorns."
"Fast. Cheap. Good. Pick two."
"We see a lot of arses on handlebars around here." - [J Ekdahl]
Boy, I must have tickled your isolation bone. OK, tell me the exact wording to distinguish between build-time and runtime? Call them case A and case B. I read that OP wanted case B. Did you read that differently?
The answers to this might be important, as it may well be the niggle.
joeymorin wrote:
The first (and only) mention of ADCH was by you.
And that was a bad example to make it clear as an example of a runtime/dynamic/not-the-same-value-every-time ?
joeymorin wrote:
If you wish, you can rcall delay_loop yourself, having arranged to load tmp with whatever value you wish, perhaps with the contents of ADCH.
I'm very confused again -- no, you cant pass that and have your macro lines such as
.elseif \cycles > (((3 * 256) + 7) + 2)
work. How? "cycles" is ADCH at build time when the macro is expanded. How do you know is ADCH is less than 0 or greater than a million? Won't ou be working with the I/O address at this time?
joeymorin wrote:
I fail to understand the value of this diversion. It is not helping the OP.
Who asked for run-time delay, and you gave build-time. And no, substituting ADCH value as "cycles" ain't gonna carry out your statements.
You can put lipstick on a pig, but it is still a pig.
I've never met a pig I didn't like, as long as you have some salt and pepper.
The datasheet spcifies what bits of Z are used: just enough to cover the entire range.
Moderation in all things. -- ancient proverb
- Log in or register to post comments
TopI also read somewhere here that:
Don't always work. But I can't remember if it was a HW error or a compiler error.
Also on of the chips (I think a 16k flash version) always push a illegal return addr. for (r)call ! so that for will (has to do wrap all the time).
I have not seen anywhere that Atmel has guarantied wrap to work other than for 8k chips.
Add
But this is about a SW delay OP for some reason want to do.
I wanted OP to do it him self but now it's solved.
- Log in or register to post comments
TopI've lost track here. Your solution, joey, is a build-time solution, right? Didn't OP want run-time?
I thought that the "newer" GCC facilities were cycle-accurate?
If there is a reasonable range of values, couldn't a Duff's device-type-thing be used?
You can put lipstick on a pig, but it is still a pig.
I've never met a pig I didn't like, as long as you have some salt and pepper.
- Log in or register to post comments
TopFor my purposes, I needed assembly language, and I needed something that would use a minimum of code space via a (re)callable subroutine. Looks like the OP wants assembly language, too.
"Experience is what enables you to recognise a mistake the second time you make it."
"Good judgement comes from experience. Experience comes from bad judgement."
"Wisdom is always wont to arrive late, and to be a little approximate on first possession."
"When you hear hoofbeats, think horses, not unicorns."
"Fast. Cheap. Good. Pick two."
"We see a lot of arses on handlebars around here." - [J Ekdahl]
- Log in or register to post comments
Toptheusch wrote:
Isn't that what "using parameter as delay needed" (in the title) means ?
Top Tips:
- Log in or register to post comments
Top"Experience is what enables you to recognise a mistake the second time you make it."
"Good judgement comes from experience. Experience comes from bad judgement."
"Wisdom is always wont to arrive late, and to be a little approximate on first possession."
"When you hear hoofbeats, think horses, not unicorns."
"Fast. Cheap. Good. Pick two."
"We see a lot of arses on handlebars around here." - [J Ekdahl]
- Log in or register to post comments
Topfair point - and it's the way the 'C' delay works, too.
Top Tips:
- Log in or register to post comments
TopI quoted, from #1. At least that was the way I took it.
" I want to write delay routine that is accepting delay time ..."
And the "not working" code immediately following sets a "parameter" and then jumps to the "routine".
So you can't use _builtin_xxx except in a C source? [not a GCC person]
You can put lipstick on a pig, but it is still a pig.
I've never met a pig I didn't like, as long as you have some salt and pepper.
- Log in or register to post comments
TopC'mon; you are stretching things now, aren't you? Are you arguing that there is, then, no difference between e.g. delay routines that are expanded at build time such as your example code, and those that pass a parameter at run-time?
You can put lipstick on a pig, but it is still a pig.
I've never met a pig I didn't like, as long as you have some salt and pepper.
- Log in or register to post comments
TopMacros have parameters, as you well know, and as has already been established in this thread. A suggestion was made in #41 to examine and emulate _delay_nn macros' code generation, but you don't have a problem with that.
"Experience is what enables you to recognise a mistake the second time you make it."
"Good judgement comes from experience. Experience comes from bad judgement."
"Wisdom is always wont to arrive late, and to be a little approximate on first possession."
"When you hear hoofbeats, think horses, not unicorns."
"Fast. Cheap. Good. Pick two."
"We see a lot of arses on handlebars around here." - [J Ekdahl]
- Log in or register to post comments
TopPerhaps I'm getting too old, or the virus is affecting me.
is, to me, at build time. It cannot accept a parameter at run time...let's say 8-bit (for convenience) ADCH, can it?
Why am I having such a hard time grasping how
is relevent to the thread? Are you saying that you code can take, e.g. the value in ADCH at run time after a conversion and produce a proportional delay? I thought that is what OP was asking for in #1. Which post can be extracted to produce this varying ADCH-proportional delay?
You can put lipstick on a pig, but it is still a pig.
I've never met a pig I didn't like, as long as you have some salt and pepper.
- Log in or register to post comments
TopThe first (and only) mention of 'runtime' was by you.
The first (and only) mention of ADCH was by you.
The code in #46 was offered with:
No other claims were made.
I fail to understand the value of this diversion. It is not helping the OP. Who, as you can see, hasn't been here for a while.
"Experience is what enables you to recognise a mistake the second time you make it."
"Good judgement comes from experience. Experience comes from bad judgement."
"Wisdom is always wont to arrive late, and to be a little approximate on first possession."
"When you hear hoofbeats, think horses, not unicorns."
"Fast. Cheap. Good. Pick two."
"We see a lot of arses on handlebars around here." - [J Ekdahl]
- Log in or register to post comments
TopBoy, I must have tickled your isolation bone. OK, tell me the exact wording to distinguish between build-time and runtime? Call them case A and case B. I read that OP wanted case B. Did you read that differently?
The answers to this might be important, as it may well be the niggle.
And that was a bad example to make it clear as an example of a runtime/dynamic/not-the-same-value-every-time ?
I'm very confused again -- no, you cant pass that and have your macro lines such as
work. How? "cycles" is ADCH at build time when the macro is expanded. How do you know is ADCH is less than 0 or greater than a million? Won't ou be working with the I/O address at this time?
Who asked for run-time delay, and you gave build-time. And no, substituting ADCH value as "cycles" ain't gonna carry out your statements.
You can put lipstick on a pig, but it is still a pig.
I've never met a pig I didn't like, as long as you have some salt and pepper.
- Log in or register to post comments
TopI can't quite figure out why this is a bone you can't seem to let go of, but whatever gets you through the day...
Did say:
"Experience is what enables you to recognise a mistake the second time you make it."
"Good judgement comes from experience. Experience comes from bad judgement."
"Wisdom is always wont to arrive late, and to be a little approximate on first possession."
"When you hear hoofbeats, think horses, not unicorns."
"Fast. Cheap. Good. Pick two."
"We see a lot of arses on handlebars around here." - [J Ekdahl]
- Log in or register to post comments
TopPages