#avr Logs

Dec 25 2017

#avr Calendar

06:31 AM nuxil: Mornings!. did you all have a good christmast eve?
06:34 AM nohitt: Yeah
06:36 AM nuxil: :)
06:36 AM polprog: im tired after christmas
06:37 AM polprog: and it's barely 2 o clock
06:37 AM nuxil: hehe. i got sick :p
06:38 AM nuxil: my nose is like a river
06:38 AM polprog: oh, hope you get better
06:38 AM nuxil: its just a cold
06:39 AM nuxil: anywho. can you take a look at this code. "DDS" stuff. i have broken it down to the important parts.
06:39 AM nuxil: https://pastebin.com/AEL12B7d
06:40 AM nuxil: the lmp command in the asm
06:40 AM nuxil: *lpm
06:40 AM nuxil: how does it read the sin table ?
06:41 AM tpw_rules: what do you mean
06:42 AM polprog: i mean... you commented all of it, that;s how it works
06:42 AM nuxil: no i mean. how does that code loop over the sin table.
06:42 AM polprog: rjmp 1b means label "1" before
06:42 AM nuxil: seen that the stuff is put into R30 and lpm uses R0
06:42 AM tpw_rules: r30:r31 == Z
06:43 AM nuxil: aha
06:43 AM polprog: i'd replace __tem_reg__ with r0
06:43 AM nuxil: thats not reccomended according to the link you gave me :p
06:43 AM polprog: since LPM loads to r0, __tmp_reg__ can change in any new gcc version
06:43 AM nuxil: http://www.nongnu.org/avr-libc/user-manual/inline_asm.html
06:44 AM polprog: if you want the temporary register then you use tmp_reg, but lpm always loads to r0
06:44 AM tpw_rules: r26:r27 == X and r28:r29 == Y too, some instructions/conventions use them as 16 bit wide pointers
06:44 AM tpw_rules: also i believe the sbis will only take 1 or 3 cycles, cause it's either skipping or not skipping a 2 word instructiojn
06:45 AM polprog: yeah, calculating cycles with sbis and other instructions like that can be tricky
06:45 AM nuxil: it will only use 3 cycles on a 2 word. like sreg
06:45 AM tpw_rules: i guess GCC is using %A3 as an alias for the third address register, i.e. Z?
06:45 AM tpw_rules: but it doesn't look like you're loading r31 anywhere
06:45 AM polprog: yeah, i noticed that too
06:46 AM tpw_rules: nuxil: yea but isn't rjmp a 2 word
06:47 AM nuxil: rjmp = Words: 1 (2 bytes)
06:47 AM nuxil: Cycles: 2
06:47 AM polprog: also, lpm needs some parameters as well
06:47 AM nuxil: no it doesnt
06:47 AM tpw_rules: oh, never mind then
06:48 AM tpw_rules: yea, in that case sbis will take 1 or 2 cycles
06:48 AM nuxil: if lpm has no parameter it assumes r0
06:48 AM polprog: oh. okay
06:52 AM nuxil: do you see if its possible to remove more instructions? atm its 10 cycles. giving me a resolution of about ~1 hz.
06:53 AM polprog: first you are claring r18 and r19, then youre adding a value to them
06:53 AM nuxil: fcpu / cycles / 2^24 ~ 1 .. using a 24bit (phase accumulator) which determines resolution of frequency.
06:54 AM polprog: perhaps mov-ing the value there could be used
06:54 AM polprog: also take a look at how method parameters are passed
06:54 AM polprog: let me find that, i had some presentation pdf that i know took a lot of time to find
06:54 AM nuxil: yea. but the code loops between lable and sbis. that is 10 cycles.
06:55 AM polprog: what do you use r18 and r19 for?
06:55 AM nuxil: ad0 and ad1
06:56 AM polprog: wait a sec
06:57 AM polprog: http://polprog.net/papiery/avr/inline%20assembly%20with%20gcc.pdf
06:58 AM polprog: this will show you which registers the ad0, ad1 and ad2 are after you call them
06:58 AM polprog: after you call the method
06:58 AM polprog: or not help :/
06:58 AM polprog: anyway, good to read
06:59 AM * nuxil downloads
06:59 AM polprog: i suppose foo in the call at the end of paste is some wide int?
07:00 AM lomas: Hi, Can I program avr using avr mk ii after I select low fuse to 0xFF (external Clock) ?
07:00 AM polprog: if so you could just make uint32_t ad in the method and figure out where it's located in the registers basing on that pdf
07:00 AM nuxil: Signal_OUT( SIGNALS[SG.mode], SG.acc >> 16, SG.acc >> 8, SG.acc);
07:00 AM nuxil: SG.fr1 = 0xe8; SG.fr2 = 0x03; SG.fr3 = 0x00;
07:00 AM nuxil: :)
07:01 AM nuxil: acc is a 32bit uint
07:02 AM polprog: yeah, so you could avoid breaking it into those 8 bit ints
07:02 AM polprog: maybe that would simplify your asm as well
07:02 AM nuxil: hmm.
07:02 AM nuxil: i am only using the 24 bits tho
07:03 AM polprog: like? is there uint24_t ?
07:03 AM nuxil: there isnt
07:03 AM polprog: so you are using uint32_t?
07:04 AM nuxil: acc is a 32bit. but the inline asm only use 24 bits of the 32bit.
07:04 AM polprog: well, you can just pass the 32 bit int and use the registers it will be put in
07:05 AM polprog: hmm maybe ill find some more interesting pdf on my phone to upload to the mirror
07:07 AM nuxil: well. i dont want a 32 bit phase accumulator, fcpu(16mhz)/ cycles(10) / 2^32 =~ 0.0003 hz resolution
07:08 AM nuxil: unless we can crunch the cycles down to 1 or 2 :p
07:08 AM nuxil: which is impossible
07:08 AM polprog: look at that drawing with colorful boxes there where it's shown where what kind of ints go when you call a function
07:09 AM polprog: page 5
07:09 AM polprog: suppose you want the lowest byte from your 32 bit int that is the first parameter (if it's a second param it's similar)
07:09 AM polprog: the you read r22
07:10 AM polprog: so in your case if your method lookes like Signal_OUT(const uint8_t *signal, uint32_t ad) then if you need ad0 you read r18
07:10 AM polprog: right?
07:12 AM polprog: also , what does add, adc, adc on the beginning of the loop do there?
07:37 AM Sulinstajn: hello! few days ago I've been asking about TWI problem - I've solved it, but now I have other one
07:38 AM Sulinstajn: does any one of you know, why every time I read TWDR I got 0xFF?
07:39 AM polprog: are you sure the device is sending stuff back?
07:40 AM Sulinstajn: the whole transaction works well (i think), only at the end when I'm awaiting data there is problem
07:40 AM polprog: those are great for debugging for me https://www.ebay.com/itm/24MHz-8CH-USB-Logic-Analyzer-8-Channel-Logic-Analyzer-Compatible-to-Saleae/162134953459?hash=item25bfff0df3:g:Jz0AAOSwh2xYBDu5
07:41 AM Sulinstajn: I can wire up some cheap china "osilloscope" what I have there, but I don't think I'll see something useful
07:44 AM polprog: give it a try
07:44 AM Sulinstajn: hmm nothing, give me a moment - I'll try use soundcard
08:04 AM Sulinstajn: hmm it looks like, that slave really isn't sending data back
08:05 AM Sulinstajn: thank you, I'll be looking for problem somewhere else
08:25 AM Sulinstajn: oh it looks that it works
08:26 AM Sulinstajn: problom was in my wrong understanding of datasheet
08:28 AM Sulinstajn: but despite that, thank you for your help
08:28 AM polprog: always check things that are easy to check ;)
09:31 AM [1]MrMobius is now known as MrMobius
10:16 AM nuxil: So i have a question. the signal tables are defined with sections. like
10:16 AM nuxil: const uint8_t sinewave[] __attribute__ ((section (".MySection1"))) = {...}
10:17 AM nuxil: and in my makefile i need to put LDFLAGS += -Wl,-section-start=.MySection1=FooBar
10:17 AM nuxil: but cant PROGMEM be used instead ? like
10:17 AM nuxil: static const uint8_t sinewave[] PROGMEM {...}
10:18 AM polprog: yeah
10:18 AM nuxil: whats the benefit of defining a section like that vs progmem ? other than knowing excatly where the table is located.
10:18 AM theBear: hmmm... in the first version, what would be an appropriate example of FooBar
10:19 AM polprog: you can use the macros from <avr/pgmspace.h>
10:19 AM polprog: but since you are passing a pointer to flash and have your routine in assembly those will not be much help
10:19 AM nuxil: LDFLAGS += -Wl,-section-start=.MySection1=0x3A00
10:19 AM nuxil: @theBear,
10:21 AM theBear: and that'd be what, just an arbitrary address between the end of your compiled output chunk and the end of regular/progmem ? i spose that'd explain why i never seen it, kinda obsolete when you can just do it the 2nd way
10:23 AM theBear: the "instead" made me think the section might refer to eeprom or external addressed something (like how the external ram can be defined and thusly becomes addressed on whatever models can do that, mostly old/first series big mega's from memory)
10:23 AM nuxil: yea its code from old atmega im looking at and trying to get working on my atmega324
10:24 AM nuxil: atmega8 code :p
10:27 AM polprog: some C voodoo: https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work , explained pretty well
10:28 AM nuxil: well. SIGNAL is a array of pointers. holding each table
10:28 AM nuxil: *pointing to each
10:28 AM * nuxil goes to make coffee and loads up stackoverflow
10:29 AM theBear: mmm, a little while back i "needed" to use a old mega8 or 16 to run some code from a fancy current model, and it was damned annoying how many things they changed the name of for some minor and obscure and largely unimportant technical detail, that's what i say
10:31 AM nuxil: yea. i see names on stuff (registers etc) is not the same. take a bit time to go back and forward between manuals figuring out what foo and bar does :p
10:34 AM nuxil: like GICR is EXINT
10:35 AM theBear: come to think of it, it's been a LONG time since all the old/90s series became outta date and forgotten by almost everyone (other than us of course, heh) ... i thinking maybe the PROGMEM stuff wasn't around lib/compiler side of things at that stage (course that doesn't decide if it does/doesn't work today) .. not that the first avr gcc stuff wasn't awesome (specially if you had wrestled with any of the shitty windows/commercial cheap or free options
10:35 AM theBear: before then, effing amazing how much some of them could write plain and obviously broken asm from the simplest of code,) just saying that now the whole avrlibc/gcc combo is just so amazing effing awesome
10:37 AM theBear: nuxil, indeed, tho i pretty sure that (probably just) after i finished what i was doing, someone mentioned a compat header/defines list(well file i spose) that covers at least all the directly-translatable stuff between the old and new, might be worth having a quick poke around webland for somethingl ike that
10:37 AM nuxil: i want to port in manually so i can learn more and how this code works.
10:38 AM theBear: fairy-nuff... i'd be a massive hypocrit if i didn't accept that as a valid course of action
10:39 AM nuxil: :)
11:39 AM [1]MrMobius is now known as MrMobius
11:58 AM rue_bed: If I'm writing an assembler bit, I just compile and reedit
11:58 AM rue_bed: usually
12:47 PM sympatix: hi everyone, i'm new on this channel but not on irc :) how can i steering servomotors with OC0 8 bit channel, is it possible? (tiny2313)
12:48 PM sympatix: i can do it with OC1 (16 bit)
12:55 PM rue_mohr: yes
12:55 PM rue_mohr: horrid resolution, but yes
12:55 PM rue_mohr: why a 2313 tho?
12:57 PM sympatix: cause i have some, also have mega8 to 16
12:57 PM rue_mohr: k
12:57 PM rue_mohr: do you know how servo pulses work?
12:58 PM rue_mohr: http://ruemohr.org/~ircjunk/tutorials/elex/hobbyservo/servo101.html
12:58 PM sympatix: i have sg90 simplest one i think, i have values to move angles
12:58 PM rue_mohr: ok
12:59 PM rue_mohr: do you know how to calculate the rollover time of the timer?
01:01 PM sympatix: probably not, is it important on 8 bit OC0 instead of 16bit OC1?
01:03 PM rue_mohr: 16 bit will improve the resolution of the movement
01:03 PM rue_mohr: doyou only want to change between two positions?
01:04 PM rue_mohr: hmm this one takes a long time to answer
01:05 PM sympatix: firstly yes, two positions is enough for a proof of concept
01:05 PM * rue_mohr looks for something else to do
01:05 PM rue_mohr: ah ok
01:05 PM rue_mohr: the process is to set the rollover of the timer to the update pulse interval
01:05 PM rue_mohr: do you know how servo control pulses work?
01:06 PM rue_mohr: I suppose I can assume you do
01:06 PM rue_mohr: hey are you translating this text?
01:07 PM sympatix: translating? what do u mean? i'm polish but i use english in general
01:07 PM rue_mohr: ok, its a low reply time was just wondering
01:07 PM rue_mohr: do you know how servo control pulses work?
01:08 PM sympatix: not at all, it's new area for me
01:08 PM rue_mohr: ok see this link
01:08 PM rue_mohr: http://ruemohr.org/~ircjunk/tutorials/elex/hobbyservo/servo101.html
01:09 PM rue_mohr: read that and give me a shout
01:10 PM sympatix: okey i'l familiarize with it and give u some feedback
01:10 PM sympatix: thx
01:11 PM rue_mohr: if you know how servo pulses work, I can show you how to set up the tiny2313 to generate basic pulses
01:46 PM nabil: m
03:03 PM antto: go get lost somewhere on facebook!
03:04 PM learath: hah, come now, is it really ok to wish that on *anyone*? :P
03:04 PM antto: ;P~
03:05 PM polprog: haha
03:05 PM polprog: did you guys /ignore them yet?
03:06 PM antto: i don't use /ignore
03:06 PM antto: i think that's wrong
03:07 PM NonaSuomy: Eventually they will get klined
03:07 PM polprog: "eventually"
03:07 PM polprog: jesus the storm on #freenode
03:08 PM polprog: oh. and :vbell of in screen
03:09 PM polprog: since my terminal is flashing like a 90's rave party
03:57 PM dev1990_ is now known as dev1990
05:41 PM Emil: antto: mate
05:41 PM Emil: antto: lol
05:41 PM Emil: antto: it's a bot
05:41 PM Emil: not a real user
05:41 PM Emil: polprog: you can stop those with +r also
05:42 PM Emil: Sorry, +R
05:42 PM Emil: Ohwait it was just for pms
06:58 PM rue_mohr: +R is more annoying than the freq that we get spammed
06:59 PM rue_mohr: we just need to make sure we have someone at the wheel
06:59 PM -!- #avr mode set to +o by rue_mohr
06:59 PM -!- #avr mode set to +o by rue_mohr
06:59 PM rue_mohr: someone ready on the kill switch
06:59 PM rue_mohr: abcminiuser, hey!
06:59 PM rue_mohr: there you are!
07:00 PM rue_mohr: your alive! did you actually get my message?
07:02 PM Casper: if I were op, and still using mirc, I'ld have scripted something quick for that
07:03 PM Casper: I used to be quite good at mirc scripting
07:03 PM Casper: hmmm
07:03 PM Casper: I wonder...
07:04 PM Casper: ah not implemented here
07:04 PM Casper: some ircd have a mean to made a badword list
07:04 PM Casper: any line containing one of the word would be blocked...
07:05 PM Casper: sadly, they did not implemented it
07:15 PM -!- #avr mode set to -o by Tom_L
07:53 PM rue_shop3: but like, look at how many problems we have had over the last 11 years, like 6?
07:54 PM Casper: #avr had little issues, probably due to the smaller size
07:54 PM Casper: usually they will /list then sort by size, and go from the top to the bottom
07:54 PM Casper: but I'm kinda surprised that freenode do not have a badwords filtering
07:55 PM Casper: yet, not surprised at all since freenode is kinda against moderation
07:55 PM abcminiuser: rue_shop3, rumours of my demise were...premature
07:55 PM abcminiuser: Which message?
07:56 PM rue_shop3: I wrote you an email, but iirc it came back as a gone domain
07:56 PM rue_shop3: so the mx records might be gone
07:56 PM rue_shop3: cause the site is still there
07:56 PM rue_shop3: iirc
07:56 PM rue_shop3: 4 walls...
07:57 PM rue_shop3: Casper, I could make the channel invite only, but that WILL kill it
07:57 PM Casper: rue_shop3: yeah, +R is the most that is acceptable, and not yet required
07:58 PM rue_shop3: its also a pain for me
07:58 PM rue_shop3: most of the time I'm not logged in
07:58 PM rue_shop3: that why when there is a floood like that I take so long to respond, cant type good in a hurry
07:58 PM Tom_L: what is +R?
08:06 PM Casper: +r sorry
08:21 PM Emil: Tom_L: +R prevents PM's from unauthenticated users
09:24 PM abcminiuser: rue_shop3, my domain is still up -- and I still get email
09:24 PM abcminiuser: Perhaps my server doesn't like you? :P
09:24 PM Tom_L: yo
09:41 PM rue_shop3: but it was in the channel
10:10 PM [1]MrMobius is now known as MrMobius
11:56 PM day__ is now known as day