#avr Logs

Dec 18 2017

#avr Calendar

04:32 AM thardin: and r24, r24 hmm
04:35 AM thardin: is that to get the Z flag set up? I see a breq afterwards
05:35 AM nuxil: status register ?
05:39 AM nuxil: SEZ
06:01 AM thardin: I'd expect LD to set the status flags
07:20 AM Neomex is now known as X-cat
07:21 AM X-cat is now known as xXxPussyDestroye
07:22 AM xXxPussyDestroye is now known as WhyBother
07:22 AM WhyBother is now known as what
07:22 AM what is now known as Neomex
08:26 AM thardin: is there a way to printf() 24-bit ints with avr-gcc? would be nice not to have to cast to 32-bit
08:26 AM nuxil: thardin, how would r24, r24 setup the z flag ,, breq "branc if equal" but. a Z flag is only set if a result from a arithmetic/logic operation is zero right?? so a=1, b=1, a & b = 1 -> Z will not be set?
08:27 AM nuxil: why dont you use sez if you need to "force it" ? it also only uses 1 clock. while ld uses 2.
08:28 AM thardin: nuxil: I'm looking at avr-gcc output
08:29 AM thardin: and r24,r24 would set Z if r24==0
08:29 AM nuxil: yea
08:29 AM thardin: what I'm pondering is if/why LD doesn't set Z
08:29 AM thardin: but I guess it just doesn't
08:29 AM nuxil: why would it?
08:29 AM thardin: 6502 does :]
08:30 AM nuxil: does LD do a arithmetic or logic operation (and or nor ...) ?
08:31 AM thardin: presumably not
08:42 AM rue_mohr: LD dosn't change ANY of the status bits
08:43 AM rue_mohr: do... you have the pdf with all the gory details on the avr instruction set?
08:54 AM rue_mohr: should I mention the tst instruction?
08:57 AM thardin: I have it somewhere
09:02 AM nuxil: dont you have it in your datasheet for your chip?
09:03 AM rue_mohr: it isn't
09:03 AM nuxil: my datasheet for the atmega324 got it
09:03 AM rue_mohr: I'm talking about the 1-page-per-instruction gory detail doc
09:03 AM rue_mohr: I'm talking about the 1-page-per-instruction gory detail doc
09:03 AM rue_mohr: that properly tells you everything
09:03 AM rue_mohr: its NOT in the chip datasheets
09:04 AM nuxil: https://gyazo.com/e3221eeee0cf82edfa4088779032646f
09:04 AM nuxil: well tell that to my datasheet :p
09:05 AM rue_mohr: dont think you understand
09:05 AM rue_mohr: (and I cant open that)
09:05 AM thardin: anyway, not important
09:05 AM rue_mohr: sure it is
09:05 AM rue_mohr: hold on
09:06 AM rue_mohr: http://ruemohr.org/~ircjunk/avr/atmelinstructions.pdf
09:06 AM rue_mohr: look at that
09:06 AM thardin: I have discovered one worrying thing: avr-gcc seems able to silently run out of space for autos
09:06 AM * nuxil downloads
09:06 AM thardin: like if it runs out of registers to use in a function
09:07 AM rue_mohr: see, a whole page dedicated to each instruction.
09:07 AM rue_mohr: descriptions and examples and everything
09:07 AM nuxil: yea. a bit more in depth that the short description in my datasheet
09:07 AM rue_mohr: EXACTLY
09:08 AM rue_mohr: if youwant to know HOW an instruction effects a register instead of just knowing if it does or not.
09:08 AM rue_mohr: er, status flag, whatever
09:09 AM thardin: I've been hunting problems with some 24-bit -> 8-bit compression code. seemingly simple things like if (s < 0) { s = ~s; } not working
09:10 AM thardin: until I make some local variables global
09:10 AM rue_mohr: k, someone didn't track their memory usage properly on a small microcontroller?
09:11 AM rue_mohr: does that statement even make sense?
09:11 AM rue_mohr: like is it signed or not?
09:12 AM thardin: I have plenty of space. bss/heap in XMEM, data area is 226 bytes. so plenty of space for stack say
09:13 AM thardin: I have 24-bit signed big-endian values that I convert to __int24. then to be sure I convert that to int32_t and print
09:13 AM thardin: which shows sensible values that exactly equal my binary data
09:14 AM rue_mohr: huh
09:15 AM thardin: but somehow when I want to turn that into uint32_t where negative values are bitflipped (so -128 -> 127) it doesn't seem to notice the int32_t:s are negative until I put them in BSS
09:15 AM rue_mohr: well, pretty sure atmel wont be fixing anything in the gcc package
09:15 AM thardin: I can print the values just fine for some reason
09:15 AM rue_mohr: er, microchip
09:16 AM thardin: it is somewhat worrying. I've had similar surprises with say printf() failing because of giving it too many values
09:16 AM thardin: and avr-gcc going along with it
09:16 AM thardin: as if you're only allowed to push so many values on the stack
09:17 AM rue_mohr: srsly? your using printf on an 8 bit avr?
09:17 AM LeoNerd: I use it a fair amount
09:17 AM thardin: it's useful
09:17 AM rue_mohr: ouch
09:17 AM LeoNerd: Having read the vfprintf.c implementation, I can state I don't believe it will understand a 24bit integer. So you'll have to widen it to 32 at the valist level
09:18 AM LeoNerd: .. also there isn't a flag for it
09:18 AM thardin: ye, that's what I suspect. it's really lacking
09:18 AM thardin: no 64-bit support either
09:18 AM LeoNerd: Pretty sure I've done 64bits before
09:18 AM LeoNerd: %lld
09:18 AM rue_mohr: it really sounds like you should be using a different processor
09:18 AM rue_mohr: long long long i -> long long long is too long for gcc
09:19 AM thardin: sure, when atmel/microchip makes a 32-bit Space Grade(tm) micro
09:19 AM LeoNerd: Mmm? uint64_t exists on AVRs
09:19 AM LeoNerd: My microvoltmeter uses them all over the shop
09:20 AM thardin: for now we're keeping the option of using an ATmegaS128 open
09:21 AM thardin: but it's really beside the point, it's a huge wtf that gcc seems to be behaving this way
09:21 AM nuxil: patch it :p
09:22 AM LeoNerd: I think the 24bit integer support in gcc is quite new, so it's probably got some holes in it somewhere
09:22 AM thardin: no doubt. but the 24->32-bit cast works fine, and I'd expect 32-bit manipulation to be rock solid
09:22 AM thardin: and still doesn't explain the behavior difference when moving locals to bss
09:41 AM thardin: docs claims pseudos that don't fit registers get put on stack, as one expects
11:03 AM Neomex: how would you reverse polarity for dc motor with avr?
11:04 AM Emil: Neomex: H-bridge
11:04 AM Neomex: no way to hack around with switching i/o pins?
11:04 AM Emil: eh?
11:04 AM Emil: What do you have
11:05 AM thardin: if you had a very small motor or stepper
11:05 AM thardin: I've done so with some tiny chinese steppers
11:05 AM Emil: do NOT drive a stepper directly from the IO
11:05 AM Emil: unless it's again a very small motor :D
11:05 AM Emil: but yeah I mean
11:06 AM thardin: yes they're like 10x5 mm
11:06 AM Emil: if it's a small motor
11:06 AM Emil: then you can drive it directly from the avr
11:06 AM Emil: two pins function as a h bridge directly
11:06 AM Neomex: i might desolder some transistors for the h bridge
11:06 AM Neomex: how small is very small exactly?
11:06 AM Emil: Neomex: eh if it really is a small motor
11:06 AM Emil: Neomex: well
11:07 AM Emil: atmega328p has iirc max 40mA per IO and total 200mA for whole chip
11:07 AM Emil: I recommend staying at max 20mA
11:08 AM Emil: The drive characteristic (sinking and sourcing) are quite symmertrical but sinking current is a tad easier iirc
11:08 AM thardin: Neomex: how big is the motor? what kind of coil resistance?
11:08 AM Emil: thardin: 10x5mm was mentioned above
11:08 AM Emil: but that doesn't exactly tell us the impedance
11:08 AM Emil: also
11:09 AM Emil: You can get away with driving a bigger inductive load if you are switching very, very fast
11:10 AM Neomex: 2.5x2.5cm there is no describtion on it whatsoever, dont remember where i got it from
11:10 AM Emil: (not recommended though
11:10 AM Emil: Neomex: too big
11:10 AM Emil: imho
11:10 AM thardin: Emil: that was my stepper :)
11:10 AM Emil: thardin: lol
11:10 AM Emil: thardin: I should read the usernames :D
11:10 AM Emil: nicks*
11:30 AM Jartza: lol
11:31 AM Jartza: customer sent a christmas present
11:31 AM Jartza: https://www.alko.fi/tuotteet/470649/Torres-Mas-La-Plana-2012-lahjapakkaus
11:31 AM Jartza: must be a pretty nice wine, haven't opened it
11:31 AM Jartza: I just have this nasty habit of reading names backwards too... :P
11:32 AM Jartza: I'm not sure about the Anal Palsam
11:56 AM thardin: I have a theory now, possibly
11:57 AM nuxil: Jartza, hehe. you been bitbaning spi/ic2 protocol's to much, you mind is set on the reverse order of the msb :p
11:57 AM nuxil: Anal Palsam is def a wine i would not buy. sound like a product for people with anal issues :p "Balsam" :p
11:58 AM thardin: putting in a cast to int8_t before the cast to __int24 will sign extend the MSB. for some reason this makes a difference despite shifting up by 16 immediately afterward
11:58 AM thardin: so possibly there's some C promotion-to-32-bit gotcha in there
12:00 PM thardin: making the int24's global might prevent some of that garbage
12:43 PM Jartza: nuxil: yes, I have twisted mind :)
12:43 PM Jartza: nuxil: how about the displays? :)
01:57 PM nuxil: Jartza, not yet.. keep in mind its xmas time so mail may be a bit slow.
01:59 PM Emil: thardin: hm?
01:59 PM Emil: thardin: unlikely
01:59 PM thardin: Emil: I thought so too
02:02 PM thardin: http://härdin.se/code.txt for reference
02:03 PM thardin: maybe there's something I'm missing though
02:03 PM thardin: but what effectively used to happen is the if (compress_s < 0) check would always come out false
02:03 PM thardin: even for negative numbers
02:04 PM Emil: thardin: hey you are a ham
02:04 PM thardin: yes
02:04 PM Emil: have you had contact with OH2TI?
02:04 PM Emil: Polytekikkojen Radiokerho PRK
02:04 PM thardin: nope, OH6 is what's across the baltic
02:04 PM Emil: hm?
02:04 PM Emil: I don't quite understand
02:05 PM thardin: the number is the distruct
02:05 PM thardin: district
02:05 PM Emil: ??
02:05 PM Emil: So you've not had QSO with OH2TI? okay, try sometimes ;)
02:06 PM thardin: I've talked to OH6ESQ in vasa a few times
02:06 PM thardin: mostly about freedv/codec2
02:06 PM Emil: yo
02:06 PM Emil: mate
02:07 PM Emil: codec2 (digital codecs in general) is all the rage in our club :D
02:07 PM Emil: Granted we are very experimental
02:07 PM thardin: nice
02:07 PM thardin: I've done a few QSOs locally. I'd like to set it up with the local repeater system
02:08 PM thardin: I've been working on a patchset for ffmpeg for it
02:08 PM thardin: which I should submit again
02:09 PM thardin: OH2TI is a club it seems. you don't have special club prefixes in finland? sweden has SK for clubs (SM and SA for operators)
02:10 PM Emil: thardin: naw, all callsigns are for everyone, mine is OH1BHT
02:10 PM thardin: might be tricky to reach espoo from umeå over vhf at least
02:10 PM Emil: OH is the general prefix (we have others, too, but they are not given out unless you pay for them :D), then there's the district (but you can choose whatever you want :D, usually based on where you are or where you were born or whatever)
02:11 PM Emil: then there's the actual identification part which is 3 letters but again if you buy a vanity call it can be 1-5 iirc
02:11 PM thardin: but if I can get freedv set up at SK2AT then we can probably set up a QSO with one of their HF beams
02:11 PM thardin: or via SJ2W
02:15 PM nuxil: Jartza, was it the 7th or 8th you shipped them like 10 days ago? i expect the mail to take upto 3weeks for economy at this time of year.
02:17 PM Emil: You didn't buy tracking?
02:17 PM nuxil: cos im a cheap bastard :p
02:17 PM Emil: lulz
02:17 PM polprog: lol
02:18 PM nuxil: :)
02:18 PM polprog: some say the only way to dispose a body is to send it with the polish post service
02:18 PM polprog: so you are 100% nobody will find it
02:18 PM nuxil: hehe
02:18 PM polprog: sure*
02:18 PM polprog: meanwhile im waiting for my xmas gift... in customs since sat
02:19 PM nuxil: i ordered something else as express on door yesterday. 1 day delivery time.. that time has passed already :p
02:20 PM nuxil: hell its not even left oslo :p
02:23 PM nuxil: Jartza, i been reading the datasheet for the displays while i been waiting. do you use your own code to control the display or do you use some lib like st7032 ?
02:24 PM Emil: nuxil: highly likely own code
02:26 PM polprog: if there's a good datasheet then it should be simple to write own code
02:27 PM nuxil: yea the datasheet is good.
02:29 PM nuxil: i tried peeking at the tagsu at github. but all i see is the simple spi and modem stuff, so i guess the code for the display contol is embeded into the firmware "audio streem"
02:30 PM polprog: updated mu dotemacs file on the site
02:30 PM nuxil: polprog, and yea. i have started writing my own lib :)
02:35 PM Jartza: nuxil: I have my own code
02:35 PM Jartza: nuxil: and yea, norway is so far away so no wonder it takes 3 weeks ;)
02:38 PM nuxil: so the instructions for the display is embed in the audio and you use the simple spi as a i2c|twi to update the display ?
02:41 PM nuxil: atiny doesnt have i2c do i guess that whats youre doing, bitbanging it :)
02:46 PM nuxil: i really like the idea behind the tagsu. and i think there is a market for it. "the idea".
02:47 PM nuxil: as example, Name badges, make it smaller, replace the display with epaper, use a cr2032 so on., could be sold to supermarkerts.
02:48 PM nuxil: where the employees where these
05:23 PM Jartza: nuxil: audio is used to just transfer up to 42 screens to tagsu, they get stored to flash :)
05:23 PM Jartza: after that Tagsu works by itself, updating LCD via i2c
05:24 PM Jartza: attiny85 has USI, which can be used as i2c, but I'm using bitbanged i2c
05:25 PM nuxil: is this the current code you use ? https://github.com/Jartza/tagsu-avr-modem
05:26 PM Jartza: and tagsu target group is quite different. the main "sellers" are the blue display (visible), the audio update and the retro style :)
05:26 PM Jartza: badge with epaper would be totally different target group :)
05:26 PM Jartza: yeah, I'm using that audio, but with some additions
05:27 PM Jartza: like CRC and trasferring block at a time and waiting a while for block to be flashed
05:27 PM Jartza: the audio modulation and code is effectively the same though
05:28 PM Jartza: pretty much as simple as it gets :)
05:29 PM Jartza: that example code has the bit-banging SPI for no reason
05:30 PM Jartza: except showing the simplest send-only spi you can get
05:33 PM nuxil: yes epaper would be a different group. a much larger group. there is like tousands of supermarkets with millons of employees. goverment employees (post, heltpersonell, police etc,) . etc.
05:34 PM nuxil: you ignore the ack from the display ?
05:34 PM nuxil: dont event listen for it?
05:34 PM Jartza: yea
05:35 PM nuxil: ok
05:35 PM Jartza: there's anyway not much I can do if display doesn't answer :)
05:35 PM Jartza: at least in tagsu
05:35 PM Jartza: then it's just dead anyway
05:35 PM nuxil: ture
05:35 PM nuxil: *true
05:37 PM Jartza: nuxil: I mean, thw epaper market is saturated already
05:37 PM Jartza: there are lot of stores in finland that have pricetags on shelves that update constantly
05:37 PM nuxil: oh. yea no point in going into it if your last wagon on the train.. unless you got some real fancy
05:37 PM Jartza: and they are battery operated
05:38 PM Jartza: plus wireless
05:38 PM Jartza: and have existed for years :)
05:39 PM Jartza: tagsu is for people going to events, fairs etc.
05:40 PM Jartza: it's the best conversation opener I know so far :)
05:41 PM Jartza: my boss calls it "lead generator" as it has lead to multiple customer prospect talks :)
05:41 PM nuxil: yea. i was thinking about it the other day, like man, it would be a nice xmas gift for my nerdy friends :p , i might order one for their birthday tho :)
05:41 PM Jartza: yea, unfortunately no way to get new batch for christmas
05:42 PM Jartza: and old batches are all sold out
05:42 PM Jartza: not very profitable device with these small batches, but the main idea wasn't making profit anyway
05:43 PM Jartza: our profit comes elsewhere luckily :D
05:43 PM Jartza: originally it was meant for our company personnel nametag but so many wanted to buy one that we got two batches made
05:46 PM nuxil: :)
05:47 PM Jartza: hope your displays arrive soon
05:47 PM nuxil: me too :D
07:54 PM nuxil: question. uint8 is one byte. but a struct used as a bit field. will it have same size? struct foo { uint8_t b0:1 .... b7:1} , will the overall size of the struct be compressed to the same size as a byte in this case?
08:01 PM _ami_: Yes. it would 1 byte.
08:01 PM _ami_: because its min allocation size on that architecutr.
08:14 PM nuxil: hmm could you then access it as a unint8 ? unit8_t *meh = &foo; ?
08:19 PM nuxil: erm. ment more like did. struct foo blah; uint8_t *meh = (uint8_t*)&blah
08:20 PM _ami_: why not
08:20 PM nuxil: :)
08:21 PM tpw_rules: i'm not sure that's defined
08:21 PM tpw_rules: but you could use a union
08:23 PM Emil: nuxil: wot?
08:24 PM Emil: nuxil: struct field { uint8_t a:1; uint8_t b:1; uint8_t c:2 } asdf; and you would access them as asdf.a, asdf.b and asdf.c
08:24 PM nuxil: Emil, i know
08:25 PM Emil: the compiler is guaranteed to generate you the code required
08:25 PM nuxil: i was curiouse about the size about the stuct in that case. and if it was possible to to access it as a uint8, but that i would do it.
08:26 PM _ami_: nuxil,
08:26 PM _ami_: union bitfield
08:26 PM _ami_: {
08:26 PM _ami_: struct {
08:26 PM _ami_: uint8_t b0: 1;
08:26 PM _ami_: uint8_t b1: 1;
08:26 PM _ami_: uint8_t b2: 1;
08:26 PM _ami_: uint8_t b3: 1;
08:26 PM nuxil: *but i wount do it.
08:26 PM _ami_: uint8_t b4: 1;
08:26 PM _ami_: uint8_t b5: 1;
08:26 PM _ami_: uint8_t b6: 1;
08:26 PM _ami_: uint8_t b7: 1;
08:26 PM _ami_: };
08:26 PM _ami_: uint8_t x;
08:26 PM _ami_: } __attribute__((packed));
08:26 PM nuxil: pastebin pls :p
08:27 PM nuxil: yea.. _ami_ thats what i was curiouse about.. if it would add extra padding or remove them by default.
08:28 PM nuxil: do you really need to spesiy the packed attribute.? isnt the compile smart enuf to figure that out ?
08:30 PM nuxil: _ami_, there is also a flag you can use the gcc that will pack it. but iirc. it will pack all structs. may not be desired effect.
08:30 PM _ami_: it was not needed. i know that.
08:36 PM nuxil: umm.. wouldnt using a union corrupt the other values in the union?
08:36 PM Emil: nuxil: wat
08:36 PM Emil: of course you can access it as a uint8_t
08:36 PM Emil: but why would you do that
08:37 PM Emil: nuxil: no padding
08:37 PM Emil: this ain't no x64
08:37 PM Emil: nuxil: the uint8_t is there just to provide easy access to the data
08:44 PM * rue_mohr does NOT kill _ami_ for pasting in channel
08:45 PM rue_mohr: I wonder what asm that generates
08:46 PM rue_mohr: I wonder if it reduces to the x flag instruction
08:46 PM rue_mohr: s
09:19 PM Emil: so what _ami_ has pasted is the best way to do it, really
09:19 PM Emil: except you don't need the attribute
10:13 PM _ami_: rue_mohr, :)
11:06 PM day__ is now known as daey
11:40 PM daey: when my atmega has an external slave SPI chip that it communicates with and i also want to be able to write to the atmega via ISP, then i should not use the atmega SS pin to drive the external chips 'slave select pin' correct?
11:41 PM daey: otherwise my external chip will think during ISP communication, that the data is meant for itself and it might answer, correct?
11:43 PM daey: nvm. the isp doesnt even use the SS line :^) time to sleep