#avr Logs

Apr 12 2017

#avr Calendar

02:03 AM daey_ is now known as daey
02:39 AM julius: morning
02:39 AM daey_ is now known as daey
02:49 AM tacmot: morning
02:58 AM tacmot: morning, i am gathering information on how to connect a GSM module to my xmega a1 explained today.
02:59 AM tacmot: and you ?
03:05 AM julius: ah got it, the maxembedded tutorial did write and read uint8_t to the rtc device.....but actually it is talking bcd
03:06 AM johnny is now known as Guest78240
03:06 AM Guest78240: g'morning
03:12 AM polprog: hello
03:12 AM Guest78240: hi
03:13 AM polprog: what's the module number? it might come in handy for me
04:39 AM Emil_: julius: hege
04:39 AM Emil_: julius: that would explain it
04:45 AM enhering is now known as Guest94664
04:55 AM julius: Emil_, lesson learned....if a person writes 0x10, 0x40, 0x00 and behind that // 10:40:20 dont trust the rest of the code either
04:56 AM polprog: classic ;)
04:56 AM Emil_: ;)
04:58 AM julius: we should make a wiki where avr code gets shows that is simple and works....theres so much out there for arduino these days
04:58 AM julius: but a clear and slim example for i2c is missing, pure avr that is
04:59 AM polprog: yeah,
04:59 AM polprog: that's called datasheets /s
05:00 AM polprog: i think it's a good idea, since the datasheets show just snippets
05:00 AM polprog: sometimes theese aren
05:00 AM polprog: aren't enough
05:00 AM julius: for a newbie a datasheet is not the easiest way to begin
05:01 AM polprog: yeah
05:01 AM julius: its far easier to have something that works and change/break it from there
05:01 AM julius: i bet thats why arduino is so popular...its more ready to go
05:01 AM polprog: you could combine it with simple ciruit examples, like a pwm lowpass etc.
05:01 AM polprog: arduino hides the hard stuff
05:02 AM polprog: under their HAL
05:02 AM polprog: also, there's a lot of those premade shields, which come with ready code examples
05:02 AM Emil_: polprog: you have acquired sassiness on this channel
05:02 AM julius: true...the "typedev uint8_t binary" i found in Arduino.h...it was the third file
05:02 AM Tom_itx: what rtc chip is this?
05:03 AM julius: ds1307
05:03 AM polprog: in fact it could be programmed by dragging and dropping squares like the LEGO mindstorms was
05:03 AM julius: the cheap and not so precise one
05:03 AM polprog: Emil_: what do you mean?
05:03 AM Emil_: polprog: that joke about datasheets
05:03 AM Emil_: I am proud
05:03 AM Tom_itx: http://tom-itx.no-ip.biz:81/~webpage/misc_stuff/RTC3.jpg
05:03 AM polprog: i'm always like that
05:03 AM Tom_itx: like that?
05:04 AM julius: Tom_itx, i used the arduino prebuild board
05:04 AM julius: but yes
05:04 AM polprog: i cant make that number out
05:04 AM julius: bbl
05:04 AM Tom_itx: http://tom-itx.no-ip.biz:81/~webpage/avr/Dallas%20RTC%20Code/
05:05 AM polprog: thanks
05:06 AM Tom_itx: i used parts of that for mine
05:13 AM Thrashbarg_ is now known as Thrashbarg
05:55 AM merethan: Hi all
05:56 AM merethan: I need some help understanding Intel Hex format. I currently struggle grasping the 02 ¨Extended Segment Address¨ records.
05:57 AM merethan: They are for defining an offset, but how these records do that isn´t described all too clearly on wikipedia.
06:02 AM Lambda_Aurigae: http://www.interlog.com/~speff/usefulinfo/Hexfrmt.pdf
06:03 AM Lambda_Aurigae: we all know wikipedia is the end-all-be-all of information.
06:03 AM Lambda_Aurigae: never read things like the specification docs.
06:18 AM polprog: Lambda_Aurigae: my eyes hurt, ascii art in variable-width serif font
06:18 AM polprog: that's like the ugliest PDF ive ever seen
06:24 AM Lambda_Aurigae: I didn't write it!
06:24 AM Lambda_Aurigae: I do everything in fixed width typewriter type fonts.
06:25 AM polprog: `i do everything in sans serif, except for coding
06:25 AM polprog: i don't remember which font ive set in the editor
06:26 AM polprog: dejavu sans mono
06:48 AM Lambda_Aurigae: no clue what the font is I use.
06:48 AM Lambda_Aurigae: it just looks like a nice typewriter.
06:49 AM Lambda_Aurigae: Monospace
06:49 AM Lambda_Aurigae: apparently
06:55 AM polprog: its a nice font
06:56 AM Lambda_Aurigae: it works for me anyhow.
07:44 AM polprog: i liked making PCBs at home so much, i'll make some tiny4313 board for learning assembly
09:02 AM Emil_: polprog: pls
09:02 AM Emil_: why would you do that? :D
09:02 AM Emil_: Learn on a good developmentboard
09:03 AM polprog: i cant afford it
09:03 AM polprog: kek
09:03 AM polprog: :D
09:07 AM LeoNerd: The thing I usually can't afford is the time
09:07 AM LeoNerd: So it's overall cheaper for me to buy stuff other people have made
09:07 AM polprog: that too, sometimes
09:07 AM polprog: i have soldered that 4313 on a SMD-rasterboard (i forgot to order some DIP ones)
09:07 AM polprog: so i'll hook some leds and stuff to it and done
09:08 AM polprog: maybe a 74hc595
09:14 AM Emil_: polprog: No I mean on a regular arduino board
09:14 AM Emil_: The m328p has a good amount of peripherals and you can actually design things with it
09:17 AM polprog: for now i picked 4313 and i wanna design some led thingie, i have also a multi channel pwm driver chosen
09:18 AM polprog: for the closer future i just wanna to blink a led in assembly
09:21 AM Emil_: s/wanna/want
09:21 AM Emil_: or lose the to
09:21 AM Emil_: wanna==want to
09:22 AM polprog: yeah, i know
09:22 AM polprog: i'm just tired
09:22 AM polprog: :/
09:22 AM Emil_: but really, bliking a led asynchornously is nothing different from C
09:23 AM polprog: yes, but the aim is to write a working assembly program
09:23 AM Emil_: and syncrhonously you just implement delay yourself (but I think that
09:23 AM Emil_: 's provided also)
09:23 AM LeoNerd: Large multichannel PWM is better done with dedicated chips - e.g. I've just been playing with the TLC5940
09:23 AM Emil_: hmm, true
09:23 AM Emil_: LeoNerd: true
09:24 AM polprog: that tlc rings a bell, it might be what i found
09:24 AM polprog: gtg, o/
09:24 AM LeoNerd: It's not the easiest of chips to use - it needs 6 digital control lines to properly drive it
09:24 AM LeoNerd: There's simpler ones - like some of the I²C chips
09:25 AM Emil_: Something like a 16bit 100MHz pwm driver provides nice results
09:25 AM Emil_: But really constant current sources are the best
09:25 AM LeoNerd: Depends what you're driving
09:25 AM LeoNerd: Into servos: you want logic level outputs, like the PCA chip
09:25 AM Emil_: Leds was specified
09:25 AM Emil_: were*
09:25 AM LeoNerd: LED chains or cascading into larger transistor banks for even more LEDs: you probably want the opencollector ouputs of theTLC
09:26 AM LeoNerd: Ahyes; then for LEDs the TLC is definitely good. It has 16 open collector outputs, tolerant to.. hrm.. actually I'm not sure.
09:26 AM LeoNerd: 17V
09:26 AM LeoNerd: (I'm using them at 12V)
09:27 AM Emil_: I really only use addressable leds anymore
09:27 AM polprog: hmm
09:28 AM polprog: the one i found had a simple serial interfcae
09:28 AM polprog: *interface
09:28 AM Emil_: If the overhead is too much dedicating a chip to drive them is not hard
09:28 AM Emil_: https://www.youtube.com/watch?v=ewGBwGAeAtk daily funstuff
09:28 AM LeoNerd: Addressible LEDs are good for some kinds of display
09:29 AM LeoNerd: Most of the work I'm using this for involves big fixed-colour panels, so a simple 12V LED tape with gels on it works better
09:29 AM NoHitWonder: ive used pca9685 with raspberry pi, it has 16 pwm channels and i2c
09:29 AM polprog: there was some macroblock thing
09:29 AM polprog: letme find the datasheet
09:30 AM LeoNerd: NoHitWonder: Ahyes that's the one I meant. I just forgot its number
09:30 AM polprog: MBI5031
09:30 AM polprog: that was the easy one
09:32 AM LeoNerd: This looks like a macroblock rather than an actual real chip you can actually buy
09:32 AM LeoNerd: Oh hangon maybe I misread it
09:33 AM LeoNerd: Ahhh; yes this chip looks /very/ similar to the TLC5940
09:33 AM LeoNerd: Same SPI input of greyscale data (which they even name the same), same GSCLK pin input. Just this one is missing the BLANK pin
09:34 AM polprog: oh, really? great, since tme doesnt have that mbi
09:34 AM polprog: i guess i'll order that tlc
09:35 AM LeoNerd: The use of the BLANK pin lets you synchronise update of the GS data with starting a new PWM cycle, so you avoid counting glitches
09:35 AM polprog: 44pcs in the warehouse
09:37 AM LeoNerd: Wow this chip (the MBI5031) has a weird commanding scheme to it. It almost reminds me of JTAG
09:40 AM LeoNerd: Ooh, but the dithered PWM output is nice, possibly more what you want for LEDs than the straight 12bit counter of the 5940
09:42 AM Hfuy: Afternoon
09:42 AM LeoNerd: Oh, though I see it does double-buffer the data for nice synchronisation of output
09:42 AM LeoNerd: Mm.. maybe it is a nicer chip
09:43 AM Hfuy: When the ATmega328P datasheet says "configure the port pin as input with the internal pull-up switched off," this means set the DDR and PORT to 0, yes?
09:46 AM ^Richard: there's a pullup register as well isn't there?
09:46 AM Hfuy: I'm not sure.
09:47 AM LeoNerd: Not on the 328P
09:47 AM ^Richard: ok, no, just use port
09:47 AM LeoNerd: Some of the newer chips have a separate PUEx register
09:47 AM ^Richard: If PORTxn is written to '1' when the pin is configured as an input pin, the pull-up resistor is activated. To
09:47 AM ^Richard: switch the pull-up resistor off, PORTxn has to be written to '0' or the pin has to be configured as an output
09:47 AM ^Richard: pin. The port pins are tri-stated when reset condition becomes active, even if no clocks are running.
09:47 AM ^Richard: datasheet page 98
09:47 AM LeoNerd: Older ones use the combination of having the PORT bit high while DDR low, to indicate input with pullup resistor
09:48 AM Hfuy: I think that more or less equates to my first impression.
09:52 AM * Hfuy fiddles with the analog comparator
09:59 AM julius: Lambda_Aurigae, hey i got that i2c ds1307 rtc working...
10:00 AM julius: it was sending data in bcd, not decimal...thats why the seconds looked funny
10:00 AM LeoNerd: Ah :)
10:00 AM LeoNerd: Yes that one
10:13 AM Lambda_Aurigae: one must remember to read the manual!
10:33 AM Emil_: LeoNerd: don't say "older ones", it's not representative of the current market
10:33 AM Emil_: The "newer" chips are not in widespread use
10:33 AM Emil_: confuses people :D
10:35 AM LeoNerd: Well,... yah
10:36 AM LeoNerd: I'm still waiting for any AVR chip with one of those atomic read-and-reset instructions
10:36 AM Lambda_Aurigae: to me, older chips is at90s series.
10:36 AM Emil_: LeoNerd: precisely
10:37 AM Emil_: sorry
10:37 AM Emil_: Lambda_Aurigae: *
10:41 AM Hfuy: In a register map, the datasheet says ADTS[2:0]. This presumably refers to the 3 LSB of the register - yes?
10:42 AM LeoNerd: That's usually the notation, yes
10:42 AM Hfuy: OK. If the table then specified "001 Analog Comparator" do I assume that means set bit 2 and clear bits 0 and 1, or set bit 0 and clear bits 1 and 2?
10:48 AM polprog: yes
10:49 AM polprog: wait no, set bit 0, clear 1 & 2
10:56 AM Hfuy: Forget it, I'll just use the ADTSn defines :)
10:59 AM Hfuy: Uhoh. That's a Bad Smell.
11:10 AM polprog: magic smoke?
11:11 AM Lambda_Aurigae: magic smoke is a good smell...lets you know you screwed up something.
11:11 AM Lambda_Aurigae: it's a training aid.
11:12 AM Hfuy: I'm not sure what the problem is
11:13 AM Hfuy: Unless I blew up the two port pins to the point where they don't work at all anymore.
11:13 AM Hfuy: Which possibly is feasible.
11:15 AM LeoNerd: I like to keep a little test program for suspect chips like that, which turns every GPIO pin into a pullup-enabled input, turns on the UART, says a hello message, then just prints the name of every input pin that gets pulled low
11:15 AM LeoNerd: So you can easily test if the UART can transmit (you get a boot message), and then see every pin by just rubbing along the pins with a grounded wire... best to use one on a moderate resistor (1k) in case of shorting a power pin
11:16 AM Hfuy: Well yes.
11:16 AM LeoNerd: 1k vs. the 10k pullup still reads close enough to ground for the digital input
11:17 AM Hfuy: What's confusing me slightly is that this is an Arduino Nano board, and port D6 is in fact marked D6. I think.
11:18 AM LeoNerd: That sounds odd
11:18 AM Hfuy: Well, digital pin 7 is in fact pin 13, PD7.
11:18 AM LeoNerd: Ohwait no I think that's right. The original Arduino pin mapping is almost reasonable against the chip
11:19 AM LeoNerd: D0 to D7 really are PORTD bits 0 to 7, then D8 to D13 are PORTB bits 0 to 5
11:19 AM Hfuy: Well, it is for PORTD, anyway.
11:19 AM LeoNerd: PB6/PB7 are oscillator
11:19 AM LeoNerd: Then A0 to A5 are PC0 to PC5
11:19 AM Hfuy: I'm wondering if I need to turn off some feature associated with PD6/7 for this to work.
11:20 AM Hfuy: Some arduino feature, that is
11:20 AM LeoNerd: ((It's the 32U4-driven Arduino Mini that's the *really* crazy board)
11:20 AM LeoNerd: They attempted to put the same peripheral units in the same places on the arduino pin numbers, with the result that the Atmel <-> Arduino mapping is crazy
11:20 AM LeoNerd: Also not one of the GPIO ports has all 8 bits represented by pins :(
11:21 AM Hfuy: I noticed that.
11:21 AM LeoNerd: This wouldn't be so bad if there was literally /any/ other reasonable 32U4 breakout board available anywhere in the world
11:21 AM LeoNerd: The only other one is Adafruit's very nice but very expensive one
11:21 AM Hfuy: I'm not sure that Adafruit are that great an outfit, in some ways. They seem to take Chinese ideas and duplicate them for seven times the price, which strikes me as a dubious business model. Somehow they succeed.
11:22 AM Hfuy: Furthermore, if gender doesn't matter, why are they making such a big deal out of it?
11:22 AM LeoNerd: I suspect it's more the converse; Adafruit are often earlier to make breakout boards than most other people
11:23 AM LeoNerd: I did consider making my own 32U4 breakout boards and selling them on Tindie, but by the time I've actually made it it's not a lot cheaper than Adafruit's
11:23 AM LeoNerd: I do sell a 328PB board though :)
11:23 AM Hfuy: We've been asked if we're going to make boards for this current project. Short answer: no. Manufacturing anything outside China is craziness.
11:24 AM LeoNerd: Eh; depends. If you're making small-run really custom stuff that you just wouldn't get anywhere else, it can be worth it
11:25 AM LeoNerd: I agree there's no point making something you could commercially buy; but if the choice is between custom PCB and custom strip/matrixboard, I often pick the former if I'm in particular hurry
11:25 AM Hfuy: I'm fairly sure this is not a big enough deal for China.
11:25 AM Hfuy: We could buy this. For $1500.
11:25 AM LeoNerd: Most of my Tindie products I sell started off as one-shot things I made for myself
11:26 AM Hfuy: There's also patent issues with this. Or at least we suspect there are, and we can't possibly afford to find out.
11:27 AM * LeoNerd nod
11:28 AM Hfuy: This irks me.
11:28 AM Hfuy: The purpose of patents appears to be to ensure that only very rich people can make anything.
11:28 AM LeoNerd: Yah :/
11:29 AM Hfuy: I can't get PD6 and 7 to do anything at all.
11:30 AM Hfuy: even if I set DDRD |= (1<<7) & (1<<6); and PORTD = DDRD, which should make them go high, they seem to be floating.
11:30 AM LeoNerd: Hmmmmmm
11:30 AM LeoNerd: PD6 and PD7 are the AINn pins for the anacomp
11:30 AM Hfuy: That's the idea.
11:30 AM LeoNerd: Make sure you turn that unit off, or they'll steal them
11:30 AM Hfuy: I thought it'd drive them high regardless, but let me check
11:31 AM LeoNerd: Other than that I can't see any other reason than hardware damage. :/ PD7's only other function is the input-only PCINT ability
11:31 AM Hfuy: I have plenty of nanos.
11:31 AM Hfuy: They're very very very cheap.
11:31 AM LeoNerd: ((Also, yay for 328P for having PCINT on every GPIO pin YES ATMEGA32U4 I AM LOOKING AT YOU))
11:31 AM LeoNerd: Oh quite; I usually keep a stock of them. They're practically a consumable :)
11:31 AM Hfuy: I noticed that. But I think you can still only actually get an interrupt per port. No?
11:32 AM LeoNerd: Only one interrupt per port, but with a bit of programming you can dispatch that out per pin
11:32 AM Hfuy: Quite so.
11:32 AM LeoNerd: I quite often do ISR(...) { static uint8_t was_pin; uint8_t pin = PINx; then various xor logic comparing the two }
11:32 AM LeoNerd: But what I mean is, the 32U4 has only a single PCINT bank, on PORTD. None anywhere else
11:33 AM Hfuy: Oh dear.
11:33 AM LeoNerd: It also puts its regular interrupt pins in STUPID PLACES
11:33 AM LeoNerd: Like.. seriously. Two of the interrupt pins are shared with the I²C module
11:37 AM Hfuy: Odd choice.
11:38 AM Hfuy: This does all raise the issue as to how I killed these port pins anyway.
11:39 AM Hfuy: I wonder if it's some arduino strangeness.
11:39 AM Hfuy: This is an arduino board and I am using the arduino IDE.
11:45 AM Hfuy: Crikey. Using digitalWrite() explodes the binary size rather.
11:46 AM LeoNerd: Yyyyup
11:46 AM LeoNerd: It's terrible
11:46 AM Hfuy: Now here's the thing. asking for digitalWrite(6, HIGH) makes the pin go high, so this is some Arduino strangeness.
11:46 AM LeoNerd: I don't go near the Arduino software side of things
11:46 AM Hfuy: Me either, I'm simply treating it as a convenient IDE and dev board.
11:46 AM LeoNerd: The hardware boards make excellent ATmega chip breakouts, but other than that I just avoid the rest of the ecosystem
11:46 AM Hfuy: My approach precisely.
11:47 AM Hfuy: However, THIS does happen.
11:47 AM Hfuy: Er, I'm not making any fundamental error with DDRD &= ~((1<<7) & (1<<6)) am I?
11:47 AM Hfuy: (or conversely DDRD |= (1<<7) & (1<<6))
11:48 AM LeoNerd: You wanted |
11:48 AM LeoNerd: _BV(7) & _BV(6) is all bits zero ;)
11:49 AM Hfuy: Oh. Yes.
11:49 AM Hfuy: That fundamental error there is the sort of fundamental error I was talking about. Fundamentally.
11:50 AM LeoNerd: It's one of the standard ones everyone makes from time to time :)
11:50 AM * Hfuy lashes self w/birch branches
11:51 AM Emil_: LeoNerd: you can't really break the pullup on avrs but you can break the sourcing/sinking fets
11:51 AM * LeoNerd nod
11:52 AM Hfuy: The manufacturing process for these things must be an absolute nightmare. FETs, flash, EEPROM, presumably thick film resistors, etc.
11:52 AM Emil_: It happens milliards of times a second
11:53 AM Emil_: Hfuy: do you want to know something good?
11:53 AM Emil_: well
11:53 AM Emil_: I mean
11:53 AM Hfuy: Well of course.
11:53 AM Emil_: it makes you a better person
11:53 AM Emil_: but is an absolutely horrible finding
11:53 AM Emil_: https://emil.fi/jako/koodi/overhead.cpp
11:53 AM Emil_: related to your digitalwrite
11:54 AM Emil_: https://www.aliexpress.com/store/product/Orange-Pi-2G-IOT-ARM-Cortex-A5-32bit-Support-ubuntu-linux-and-android-mini-PC-Beyond/1553371_32802458477.html damn I want to buy this
11:54 AM Emil_: Or five
11:54 AM Hfuy: Emil_: Oh, I'm very, very aware. Hence my dedication to native code only.
11:55 AM Hfuy: We just spent a lot of time on an nRF24L01 library for this reason.
11:55 AM Emil_: I have been trying to write my own NRF24l01+ driver for quite some time now
11:55 AM Hfuy: It wasn't entirely straightforward, but we did it. If I can help, I will.
11:56 AM LeoNerd: Mmmm
11:56 AM LeoNerd: Do either of you want a copy of mine?
11:56 AM Emil_: Hfuy: Share the code?
11:56 AM Emil_: LeoNerd: sure
11:56 AM LeoNerd: Straight AVR C, no Arduino
11:56 AM Hfuy: Just a moment.
11:56 AM Emil_: LeoNerd: you should know in this channel we look down to Arduino ;)
11:56 AM LeoNerd: Quite
11:56 AM LeoNerd: Hence my confirming
11:56 AM Emil_: AVRC <3
11:57 AM * LeoNerd wonders what everyone's favourite multifile paste site is, now that pastie.org seems to be permadead :/
11:58 AM Hfuy: If anyone can point out why this is broken, I'd be grateful: https://hastebin.com/xapegaroda.cpp
11:59 AM Hfuy: I have pots on PD6 and PD7 and can wind them up and down relative to one another.
11:59 AM LeoNerd: http://paste.debian.net/927284/ anyhow
11:59 AM Hfuy: Our nRF code is fairly basic. We overlook a lot of features we don't need. Use LeoNerd's if it works for you.
11:59 AM Emil_: Hfuy: what is the expected thing
11:59 AM Emil_: and what happens
12:00 PM Hfuy: Emil_: Expected: serial output when one AIN pin crosses the level of the other. Actual: Nothin'.
12:00 PM Emil_: Also Hfuy, use PDN macros
12:00 PM Emil_: instead of straight numbers
12:00 PM LeoNerd: Did you remember to sei()
12:00 PM Hfuy: No.
12:00 PM * Hfuy facepalms
12:00 PM LeoNerd: :)
12:00 PM * Hfuy reaches for the birch
12:00 PM LeoNerd: Don't wear it out too much in one day
12:01 PM Emil_: oO DDRD &= ~((1<<7) | (1<<6)); becomes DDRD&=~((1<<PD7)|(1<<PD6));
12:01 PM Hfuy: Your code is significantly smaller than hours.
12:01 PM Hfuy: Ours, too.
12:01 PM Emil_: Hfuy: also
12:01 PM Emil_: your pullup is wrong
12:01 PM Emil_: oh I can't read
12:01 PM Emil_: nvm
12:01 PM Emil_: :D
12:02 PM LeoNerd: Also for initial hardware setup, I tend to like plain writes into the register to set all the required bits in one go
12:02 PM Emil_: yeah
12:02 PM LeoNerd: Rather than lots of individual bit-twiddling, that might still leave some untouched
12:02 PM Emil_: I agree
12:02 PM Hfuy: Well yes. I was doing my best not to stomp on things unnecessarily, but I take your poit.
12:02 PM Emil_: But yeah remember to call sei() and check the register descriptions
12:03 PM Emil_: Hfuy: one write to a register is better than multiple consequtive ones
12:03 PM LeoNerd: In theory the hardware should come up in a known state after reset, but I like to just splat it all at startup time just to be sure
12:03 PM Hfuy: Something is wrong, because this thing is getting warm again, even though I can't meter any serious current flowing in any of the pins that are connected to my pots.
12:03 PM Hfuy: I'm drawing 0.5mA through the pots, but that's it.
12:04 PM Hfuy: (Only warm. It's not an emergency, but it's odd.)
12:04 PM Emil_: check your connections
12:04 PM Emil_: if it gets warm you have a wrong connection
12:04 PM Hfuy: I have, repeatedly.
12:06 PM Hfuy: I'm using the 5V and GND across the pots, which as I say draws about 0.5mA though two 20K pots, and AIN0 and AIN1 on the wipers.
12:06 PM Hfuy: That's it.
12:06 PM LeoNerd: What is warm - the pots or the AVR chip?
12:06 PM Emil_: Hfuy: every freshman always says: "yeah I checked the conns!"
12:06 PM Hfuy: It's on the nano.
12:06 PM Hfuy: Eh, maybe I'm imagining things.
12:07 PM Emil_: And then the TA comes over and says "you have an error there"
12:07 PM Hfuy: It's only four pins ffs.
12:07 PM Hfuy: I have a bunch of stuff going off to an nRF board, but that's known good.
12:07 PM Emil_: I have seen errors with less ;)
12:08 PM Hfuy: Oh, me too.
12:09 PM Hfuy: I'm sure my USB power will stand half a milliamp of bias current.
12:10 PM LeoNerd: Hfuy: my nRF code?
12:10 PM LeoNerd: (being shorter)
12:11 PM Hfuy: It's shorter than ours.
12:13 PM Hfuy: It depends to some extent what level of services you're providing in your API, of course.
12:13 PM LeoNerd: Hmm.. well, I'm not doing any understanding of config fields, for example
12:13 PM Hfuy: Yes, exactly.
12:13 PM LeoNerd: I say "hey, caller, you have to understand the layout of the config registers" currently
12:13 PM Hfuy: All perfectly fair, it's a choice of course.
12:13 PM LeoNerd: Yah; I was writing this for an ATtiny also
12:13 PM Hfuy: Over-automate things and you end up with - well - Arduino.
12:14 PM LeoNerd: Generally I find that the caller just sets up some constants at boot time then leaves the config alone
12:14 PM LeoNerd: So I didn't see much need to dynamically fiddle with it
12:14 PM Hfuy: Oh, absolutely.
12:16 PM Hfuy: Looks like it works. However, instead of saying "interrupt!" it's saying "error in ISR setup," which means it's ending up in ISR(BADISR_vect){...}
12:16 PM Hfuy: Should I not be using ISR(ANA_COMP_VECT){...} then?
12:17 PM Emil_: Hfuy: _vect*
12:17 PM LeoNerd: Surely lowecase vect
12:18 PM Hfuy: That was my typing into IRC error.
12:18 PM Hfuy: Some sources have ANALOG_COMP_vect
12:18 PM LeoNerd: The namings of these things are often a fun guessing game
12:18 PM Emil_: It's always lowercase
12:18 PM LeoNerd: TIM verses TIMER as well
12:18 PM Emil_: http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html
12:18 PM Emil_: for reference
12:19 PM Emil_: But yeah it's strange that the naming isn't standardised
12:19 PM Emil_: Perhaps it is for easier code factorisation
12:22 PM Hfuy: This all seems fine. I am getting usually more than one interrupt per what-I-think-is-a-comparator-event. I assume that's essentially the potentiometer equivalent of switch bounce.
12:23 PM LeoNerd: You need more hysteria
12:23 PM LeoNerd: .. er.. hysteresis
12:23 PM Emil is now known as Guest76964
12:23 PM Emil_ is now known as Emil
12:24 PM Guest76964 is now known as Emil_
12:24 PM Hfuy: I'm not sure I'm allowed any hysteresis.
12:24 PM LeoNerd: Then you'll be subject to the usual analog noise
12:25 PM Hfuy: It's OK. I'm connecting a pseudo-audio signal, anyway.
12:25 PM Emil: Hfuy: if you are not allowed hysteresis or time based filtering your only option is to double down on the analogue filtering
12:25 PM Emil: But I cannot understand why you couldn't do time based filtering
12:25 PM Hfuy: What I mean is that I wasn't aware there was programmable hysteresis.
12:25 PM Emil: Hfuy: there isn't
12:25 PM Hfuy: I see.
12:26 PM LeoNerd: Ohreally? I thought the anacomp has a hystersis option
12:26 PM Hfuy: The basic comparator setup seems to be correct, in any case. I want to use the automatic timer capture feature, since I'm attempting to decode a serial bitstream.
12:26 PM LeoNerd: Or maybe some do but not the 328P's
12:26 PM Hfuy: Do they make the 328P in DIP?
12:26 PM Emil: yes
12:26 PM Hfuy: Excellent.
12:26 PM Emil: matey do you even :D
12:27 PM Emil: also don't go dip
12:27 PM Emil: tqfp is easy to solder
12:27 PM Hfuy: It's that or I just solder a nano in.
12:27 PM LeoNerd: DIP package misses ADC6/7 pins, don't forget
12:27 PM Emil: yeah
12:27 PM LeoNerd: I'd just use the nano.. it's a convenient little cheap board that has the clock and also gives you a nice USB-CDC bridge ;)
12:27 PM LeoNerd: ((unlike, say, the pro mini))
12:27 PM Emil: LeoNerd: well I mean, the input capture has a selectable filtering option
12:27 PM LeoNerd: But yah you're right, the 328P's anacomp does not have hysteresis
12:27 PM Emil: LeoNerd: in which case 4 consequtive samples need to be equal
12:28 PM Hfuy: Quite. I have one using a U-suffix AVR here which is a nightmare, since the USB goes down whenever you crash it.
12:28 PM Emil: But htat's not hysteresis
12:28 PM Emil: Hfuy: that's why using a dedicated chip for usb is the best imho
12:29 PM Hfuy: Well, there may be a desire to have this thing emulate a USB keyboard, which I understand is possible on a U-suffix AVR. In which case, we'll simply put another nano in, with the U-suffix chip, and treat it as a peripheral.
12:29 PM LeoNerd: AHhhhI remember - the ATtiny841's anacomp units have hysteresis; that's what I was remembering. The HSEL/HSEV bits in ACSR0B
12:29 PM LeoNerd: Hfuy: I've taken to using multicore AVR layouts more lately. My current project is a dual 328P + tiny841 with the latter doing DMX offload
12:29 PM LeoNerd: It acts like an SPI slave
12:30 PM Hfuy: I was going to look into SPI slavery on the U-suffix chips for that exact reason.
12:30 PM Emil: LeoNerd: well those have those new pic peripherals T.T
12:30 PM Hfuy: Presumably they're capable of being a slave?
12:30 PM LeoNerd: The real AVR SPI unit can be a slave, yes
12:30 PM LeoNerd: Also the USI on a smaller ATtiny can be a slave with enough pushing
12:31 PM Hfuy: I mean, people complain about power consumption, but when these things are mainly asleep, what is the real draw? Half a milliwatt?
12:31 PM LeoNerd: Though if anything I'd say put all your real logic in the 32U4, and have some other chips for sensors and whatnot
12:31 PM Emil: Hfuy: if you are only using it for keyboard then using the u-series is fine
12:32 PM Hfuy: I may have yet another reason to have a separate core as I'd like to use one of those very small OLEDs as a status and menu interface. As such it would be convenient to emulate a 20x4 LCD, and it would be worth using an AVR as a display controller to do all the font handling.
12:32 PM Hfuy: At least, I don't see a problem with doing that.
12:33 PM LeoNerd: Mmmm
12:33 PM LeoNerd: I've been playing with OLEDs. Honestly I prefer to treat them as a real pixel display
12:33 PM Hfuy: Well, possibly. I haven't looked into it too closely.
12:33 PM LeoNerd: Proportional fonts, draw lines, ...
12:33 PM LeoNerd: They're nice
12:33 PM Hfuy: The issue is speed.
12:33 PM * LeoNerd can share (more) code if req'd
12:33 PM LeoNerd: Yah.. they're I²C so usually you want to interrupt those
12:33 PM LeoNerd: Especially for banging out the framebuffer
12:34 PM Hfuy: I have some I2C OLEDs. Frankly I've just ordered some SPI ones, for simplicity's sake.
12:34 PM Hfuy: I just noticed that they're almost exactly the right resolution to be a 20x4 character display. Actually, it's 21x4.
12:35 PM LeoNerd: Usually they're the same chip internally ;) The good ol' SSD1306, or the SH1106
12:35 PM Hfuy: The former, I believe.
12:35 PM Hfuy: Presumably the PCB layout determines the interface.
12:35 PM LeoNerd: For reasons I've never worked out, usually the 0.96" ones are SSD1306, and the 1.3" ones are SH1106
12:35 PM LeoNerd: They require *slightly* different driving code
12:35 PM Hfuy: I suspect we'll do our best to come up with a from-scratch driver.
12:36 PM LeoNerd: Yah - the chip itself can do I²C or SPI or some parallel IO, and it just has config pins to set it
12:36 PM LeoNerd: Adafruit even sell a combined SPI or I²C configurable board
12:36 PM Hfuy: I looked at parallel I/O versions, but the AVR doesn't really have the resources to framebuffer it.
12:36 PM LeoNerd: No.. also not *really* needed to be honest
12:36 PM LeoNerd: The framebuffer isn't that big
12:36 PM Hfuy: Quite.
12:37 PM Hfuy: My project now is to get this thing to record the state of a timer on interrupt, and probably reset said timer.
12:38 PM LeoNerd: The main reason I like the I²C version of these, is that you can shove an I²C accessed PCF8574 chip up close next to the display and read that for some front panel buttons
12:38 PM Emil: a framebuffer is only good if you redraw the whole screen
12:38 PM LeoNerd: You can transfer only part of it if you want
12:38 PM Emil: otherwise you can use normal logic to draw segments based on conditions
12:38 PM Emil: LeoNerd: yeah but no need
12:38 PM LeoNerd: But you do need to buffer it yourself, because you can only write entire 8bit bytes at once
12:39 PM Hfuy: I assume they're written in vertical 8-pixel stripes, like a lot of things?
12:39 PM LeoNerd: So drawing arbitrary line segments needs you to remember the other 7 bits next to it
12:39 PM Emil: A framebuffer is quite wasteful for ram
12:39 PM LeoNerd: Yes
12:39 PM Hfuy: Handy for drawing text.
12:39 PM LeoNerd: Emil: it *is*, but it's a necessary evil because you can't read VGRAM back out of these things :( So you can't even do RMW operations
12:39 PM LeoNerd: ... some of the fancier modules let you
12:39 PM Hfuy: Presumably the module has some SRAM and implements that onboard.
12:40 PM LeoNerd: WEllyes, the display matrix needs SRAM to store the buffer in anyway. It's just that the SSD1306 doesn't give you a way to read it out of the chip
12:41 PM Emil: LeoNerd: No I mean, I implemented a controller for an audio processor
12:41 PM Emil: It's an interactive serial display
12:41 PM Emil: I store program state and draw by logic
12:41 PM LeoNerd: I find that the display buffer isn't *too* expensive on a 328P; 128 columns at 8 bytes per column is only 1024 bytes.. that's... only *half* of the RAM on the chip ;)
12:43 PM Hfuy: Timer/Counter 1 is a complex piece of hardware.
12:44 PM Hfuy: It has what we on the internet refer to as "a features."
12:44 PM LeoNerd: Hah!
12:44 PM Emil: Hfuy: eh?
12:44 PM LeoNerd: Yes; AVR timers are a fun and interesting topic :)
12:44 PM Emil: It's quite enicely documented
12:44 PM LeoNerd: The many many (oh so many) variations
12:44 PM LeoNerd: Emil: I wouldn't say "nicely"
12:44 PM LeoNerd: If it was nicely documented, it would have a version name/number/something so that I could see what chips were identical
12:44 PM LeoNerd: I hate that Atmel don't dot hat
12:44 PM Hfuy: I assume that a lot of the variations in AVR devices are down to binning - "which parts of this one work?"
12:44 PM Emil: LeoNerd: I mean, that would be nice
12:45 PM Emil: LeoNerd: but there is no problem imho
12:45 PM Emil: If you need to port to another chip, rtfm :D
12:45 PM LeoNerd: Right
12:45 PM Emil: There are only a limited number of registers ;)
12:45 PM Emil: But indeed
12:45 PM Emil: if they were the same that would be kawaii :3
12:45 PM Emil: Would help it
12:45 PM LeoNerd: But if the manual said "Hey, this is the same as the 328P" then I can just add one extra line of #ifdef and get on with my life
12:46 PM Emil: Indeed
12:46 PM LeoNerd: But no, I have to carefully reread *all* of the docs to see if the code I've already written happens to match here
12:46 PM LeoNerd: Oh randomly while we're on the subject of AVR timers being crazy - do you know what's up with 32U4's timer3? It has 3 output compare modules, but only 1 of them is brought out to a physical pin
12:47 PM LeoNerd: OC3B and OC3C physically do not exist
12:54 PM Emil: LeoNerd: could it be modulation?
12:54 PM Emil: Like with m328pb
12:54 PM LeoNerd: The 32U4 doesn't have a modulation unit I do'nt think
12:54 PM Hfuy: Is the I/O clock equal to F_CPU under normal circumstances, or is this something I need to go and look up?
12:54 PM LeoNerd: Though actually let me look
12:55 PM LeoNerd: Hfuy: offhand I can't think of any situation on an ATmega where they differ
12:55 PM Emil: LeoNerd: hmm
12:55 PM Emil: perhaps you can use them as independent internal clocks?
12:55 PM LeoNerd: Ohsure you can use them interanlly
12:55 PM LeoNerd: But then why do the OCM bits in the control register still exist? ;)
12:56 PM Emil: To select the type of counter
12:56 PM Emil: ?
12:56 PM LeoNerd: That's not what those do
12:56 PM LeoNerd: These are the output control mode bits - the ones that tell the OCnx pin how to behave
12:56 PM LeoNerd: The pin that doesn't exist
12:56 PM Emil: LeoNerd: they affect the interrupts also
12:56 PM LeoNerd: Really?
12:59 PM LeoNerd: I see the WGM bits affecting interrupts, I don't see a description for how the OCM bits do
01:01 PM Emil: Perhaps they just copypasted the blocks
01:01 PM Emil: and copypasted the configs
01:01 PM LeoNerd: Yeah, possibly
01:01 PM Emil: But that's just 2 additional 16 bit registers :3
01:01 PM LeoNerd: Not sure why they'd not bother bringing the bits out to real pins though... there's enough spare pins around not doing too many other jobs
01:02 PM Emil: yeah
01:02 PM LeoNerd: Ahah.. the 32U4 *does* have an output compare modulator unit, but it uses timer0 + timer1, not 3
01:03 PM Hfuy: Did I read somewhere that there's a way to make timer/counter 1 automagically store its value somewhere and reset on interrupt?
01:03 PM LeoNerd: You mean input capture mode?
01:03 PM Hfuy: I think so.
01:03 PM LeoNerd: Read the "Input Capture Unit" part of the doc
01:03 PM Hfuy: I've enabled ICIE on the timer.
01:03 PM Hfuy: Presumably inside the ISR, I simply read the input capture registers.
01:04 PM Emil: Yes
01:04 PM Emil: And preferably as first thing in your routine
01:04 PM Hfuy: Well,yes.
01:04 PM Emil: LeoNerd: oh the u4 also has modulator? Interesting
01:05 PM Emil: What's that, 8 bit modulation on 16 bit timer? :D
01:05 PM Hfuy: It's not the end of the world if the timing is corrupted. It simply means I'll misread the incoming serial stream.
01:05 PM LeoNerd: Yeah; it's a weeeird chip. A shame it's also the only USB-talking ATmega
01:05 PM Emil: LeoNerd: also u2 and u8
01:05 PM LeoNerd: I don't count the U2 :P
01:05 PM Emil: :D
01:05 PM LeoNerd: OH but I've not seen this U8.. is it new?
01:05 PM Emil: nO
01:05 PM Emil: No
01:06 PM LeoNerd: Hm... part name? I don't see it
01:06 PM Emil: it's as old as the u4
01:06 PM Emil: it's just with moar ram imho
01:06 PM Hfuy: Anyone remember what the input capture interrupt is called?
01:06 PM Emil: Hfuy: check the link I posted earlier
01:06 PM LeoNerd: The 32U2 is an /even/ stranger chip. It talks USB but has no ADC
01:06 PM Emil: Hfuy: or just google "avr interrupt"
01:07 PM Hfuy: Was my first trick.
01:07 PM LeoNerd: Emil: I'm not seeing anything around, about an "ATmega32U8"
01:08 PM Emil: LeoNerd: yeah I was wrong apparently
01:09 PM * LeoNerd tries parametric search
01:10 PM Emil: Dunno where I was pulling that u8 from :D
01:11 PM Hfuy: I get the feeling this is a rarely-used function.
01:11 PM LeoNerd: Input Capture? Yah.. I for one have never used it
01:12 PM Hfuy: Makes sense, I think, for timing an arbitrary serial stream.
01:13 PM Hfuy: I believe I have everything configured correctly. I simply can't find out what the name of the interrupt vector is.
01:14 PM Emil: Input capture is really useful imho
01:15 PM Emil: Hfuy: what? input capture for m328p?
01:15 PM Hfuy: Yes.
01:15 PM Emil: TIMER1_CAPT_vect
01:15 PM Emil: http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html
01:15 PM Hfuy: Cracking, thanks.
01:15 PM Emil: matey do you even rtfm? :D
01:16 PM LeoNerd: Ugh I give up. Microchip's "parametric search" page is useless
01:16 PM Lambda_Aurigae: Emil, it's your job to read it and interpret it and tell us how it works. We elected you while you weren't looking.
01:16 PM LeoNerd: CPU spins firefox. Renders terribly in chrome so you can't read the column headings
01:16 PM LeoNerd: Impossible to dismiss the "show/hide columns" menu
01:17 PM Emil: LeoNerd: gib op powah and I'll do it with less whining :D
01:18 PM Hfuy: I would point out that the string "TIMER1_CAPT_vect" does not appear in the datasheet.
01:18 PM LeoNerd: No, not with _vect
01:18 PM LeoNerd: The _vect part of the name is an invention of avr-libc
01:19 PM LeoNerd: However, "TIMER1 CAPT" does appear in the datasheet, in the "Interrupts" table which is section 12
01:20 PM Hfuy: For some reason, it isn't firing. The analog comparator ISR is working, but I apparently haven't configured things correctly for it to grab the timer state
01:21 PM LeoNerd: There's quite a few bits to twiddle on the timer to make it use the anacom
01:22 PM Hfuy: I noticedf.
01:30 PM Emil: Hfuy: calling sei()?
01:31 PM Emil: And it's only like 4 bits to set
01:31 PM Emil: Installing bash (linux sub-system/ubuntu) on Win10 now
01:31 PM Emil: This will be interesting
01:32 PM Emil: I should find a new laptop/make my own shit one
01:35 PM Hfuy: I'm zeroing TCCR1A, setting ICNC, ICES and bits for clk/1024 in TCCR1B, and setting ICIE in TIMSK1.
01:36 PM Emil: Hfuy: it is ICNC1
01:36 PM Emil: and ICES1
01:36 PM Hfuy: Yes.
01:36 PM Hfuy: Though I suspect ICNC2 is the same actual bit.
01:36 PM Emil: ICNC2?
01:36 PM Emil: What is that?
01:36 PM Hfuy: If any!
01:36 PM Emil: There is no ICNC2
01:36 PM Hfuy: I assume since there's an ICNC1 there's probably an ICNC2, no?
01:37 PM Emil: mate wat
01:37 PM Emil: do you even rtfm?
01:37 PM Hfuy: Why number it, then. Anyway, doesn't matter.
01:37 PM Emil: Because of consistency
01:38 PM Emil: But yes those are the bits you should be setting
01:39 PM Hfuy: Eventually, as I understand it, I'll actually have both ANALOG_COMP and TIMER1_CAPT firing, ideally.
01:39 PM Hfuy: OK all seems to work now.
01:41 PM Hfuy: This avr.h seems to omit ICIE, but using the literal value of 5 seems to work OK.
01:41 PM Emil: ICIE1
01:41 PM Emil: not ICIE
01:41 PM Hfuy: There is, however, only one of them.
01:42 PM Emil: It is per timer unit
01:42 PM Emil: named
01:42 PM Emil: if you have issues with it, do a fork :D
01:42 PM Emil: Otherwise don't complain about facts
01:43 PM Hfuy: I, like Trump, have alternative facts!
01:43 PM Emil: Still better than shillary
01:43 PM Emil: ;)
01:43 PM Emil: Both are horrible
01:43 PM Emil: But let's not move to politics
01:43 PM Hfuy: All professional politicans are horrible, and I quite agree.
01:45 PM Hfuy: It doesn't mention zeroing the timer at the point of input capture.
01:45 PM Hfuy: I assume I have to do that manually.
01:47 PM Emil: iirc yes
01:47 PM Hfuy: Yes, I do. The Atmel app notes do it.
01:54 PM Hfuy: Welp, it's noisy as hell, but it's giving me a stream of numbers.
01:55 PM Emil: what is noise as hell?
01:55 PM Hfuy: Theoretically, this serial stream contains bit periods of two durations - long and short.
01:56 PM Hfuy: As such, the time between transitions should be (roughly) x and 0.5x
01:56 PM Hfuy: x in this case is something like 35
01:56 PM Hfuy: I'm also getting a lot of periods shown near zero, though.
01:56 PM Emil: f_cpu(1024?
01:56 PM Emil: f_cpu/1024 cycles?
01:57 PM Emil: Or direct unscaled cycles?
01:58 PM Hfuy: I'm using /256.
01:58 PM Hfuy: It's only a 2KHz (for the shorter cycles) stream.
01:58 PM Emil: Well as long as it isn't /1
01:58 PM Hfuy: I'd rather not end up with 16-bit numbers.
01:58 PM Hfuy: There's no need, anyway. I only need to be able to tell long from short.
02:01 PM Hfuy: When we did this on a computer in C#, I calculated the median period from a history of the last couple of hundred bit periods. That's probably too heavy for a microcontroller, so I'll simply pick a value that should work for most frame rates.
02:16 PM Hfuy: Something strange is happening.
02:16 PM Emil: Well explain that
02:17 PM Hfuy: Given the two possible transition periods, I would expect my transition timings to cluster around two main points.
02:17 PM Hfuy: One twice the length of the other.
02:17 PM Emil: And?
02:17 PM Hfuy: However, I actually see three. One around a value of 32, one around 48, and one around 64.
02:17 PM Emil: well have you checked your input source?
02:17 PM Emil: With a scope?
02:17 PM Hfuy: I'm looking at it on a scope.
02:18 PM Hfuy: It's not a storage scope so I can't be completely certain, but it looks clean enough. Certainly readable.
02:18 PM Emil: And if it is a low changing signal just sample the ADC and push it through UART
02:18 PM Hfuy: I suspect I'm overflowing the timer.
02:18 PM Emil: you can sample 8bit@48000kHz through uart directly
02:19 PM Emil: I suspect your input source is acting up
02:19 PM Emil: 48=32+16
02:19 PM Hfuy: It's not a large signal, only around 0.4V peak to peak.
02:19 PM Emil: so?
02:21 PM Hfuy: I can see what's happening, as you say - it's getting mathematically screwed somewhere. But I'm not sure where.
02:26 PM Hfuy: The problem remains even if I add some pretty aggressive low-pass filtering.
02:26 PM Hfuy: I get values around 16, values around 32, and values around 64.
02:27 PM Emil: have you checked your input source?
02:27 PM Emil: And also
02:27 PM enhering is now known as BullSheet
02:27 PM Hfuy: I'm looking at it on a scope. Looks reasonable.
02:27 PM Emil: I recommend you attempt to dump raw data
02:27 PM Hfuy: Bear in mind I'm not ADCing. I'm comparator-ing.
02:27 PM Emil: If you can see your input is clear then proceed to debugging the code
02:28 PM Hfuy: I'm as close to dumping raw data as I reasonably can be.
02:28 PM Emil: And so this is from the analog comparator?
02:28 PM Hfuy: Yes. These are timings between edges.
02:29 PM BullSheet is now known as BowlSheet
02:30 PM BowlSheet is now known as bullshiit
02:30 PM Emil: Do you want to capture both AIN and ICP?
02:30 PM Emil: because you can choose AIN as input for the ICP?
02:30 PM Hfuy: I have.
02:30 PM Hfuy: I may need to capture the analog comparator interrupt in future for precision timing.
02:31 PM Emil: But most importantly, do you reselect the interrupt mode on trigger?
02:31 PM Hfuy: Ah. Do I need to do that?
02:31 PM bullshiit is now known as bullcheat
02:31 PM Hfuy: I'm just zeroing TCNT1.
02:31 PM Emil: Hfuy: mate if you want precision timing on AIN then use AIN with ICP
02:31 PM bullcheat: Finding a good nickname is soo difficult
02:31 PM Emil: mate do you even rtfm? :D
02:31 PM Emil: bullcheat: true
02:31 PM Hfuy: I'm using input capture right now.
02:31 PM Emil: bullcheat: I got lucky
02:32 PM Hfuy: However, I also need to know exactly when the transition occurs for other reasons.
02:32 PM bullcheat: indeed, Emil.
02:32 PM Emil: Hfuy: AIN table 23-2
02:32 PM Emil: Hfuy: mate, what part of this do you not understand :D
02:32 PM Emil: Hfuy: you can use AIN for trigger for the ICP
02:32 PM bullcheat is now known as enhering
02:32 PM Emil: you get best timing that way
02:32 PM Hfuy: As I say - I have. That's what I'm doing.
02:32 PM Emil: if you use ICP for something different then my bad
02:33 PM enhering is now known as bs
02:33 PM bs is now known as enhering
02:34 PM Emil: Hfuy: if you want edges then you need to first disable the interrupt, then reselect the trigger and again enable interrupt
02:34 PM Emil: Or if output toggle works then that's fine also
02:34 PM Emil: yeah that should also work
02:34 PM Hfuy: I have toggle selected, but as I say, this is not behaving as I'd want.
02:35 PM Hfuy: I wonder if it's just my uart_send function.
02:36 PM Emil: https://emil.fi/jako/koodi/spimic.c
02:36 PM Emil: Adapt as needed
02:36 PM enhering is now known as gabuleu
02:36 PM Emil: It has both SPI and UART
02:36 PM gabuleu is now known as enhering
02:36 PM Hfuy: The concern I had was about the int-to-ascii function. Happily, it outputs a unit16_t with the value 300 quite correctly.
02:37 PM Hfuy: Depending on unknown factors, sometimes it splits into four groups - 16, 32, 48 and 64.
02:37 PM Hfuy: Something fishy is going on here.
03:54 PM julius: is it just me or is it impossible to find a example that shows how to use a smt32 to read a usb stick?
05:15 PM Jan-: has anyone here ever used the analog comparator in the mode where it can set off a timer capture event
05:25 PM xentrac: unit16_t, heh
05:26 PM xentrac: Jan-: I haven't; what are you planning to do with it?
05:26 PM xentrac: julius: reading a USB stick is a pain in the ass because you have to implement several layers of the USB protocol stack, which is a lot more like TCP/IP than it is like RS-232 or SPI
05:27 PM julius: is there maybe a chip that does that for you?
05:28 PM julius: got this arduino mp3 board which reads from a micro sd card, it works but i would rather get the data from a usb stick
05:30 PM xentrac: there might be (although as a programmer instead of a hardware guy my tendency is instead to look for a library that does things for me, since libraries don't add to my BOM or get damaged by overvoltages) but I don't know of one
05:30 PM xentrac: maybe someone on youtube has done a teardown of one of those stereos that take USB sticks to see what they use to talk to the USB stick
05:31 PM NoHitWonder: http://www.st.com/content/ccc/resource/technical/document/user_manual/cf/38/e5/b5/dd/1d/4c/09/DM00108129.pdf/files/DM00108129.pdf/jcr:content/translations/en.DM00108129.pdf
05:32 PM xentrac: that URL needs to be taken out back and shot
05:32 PM xentrac: it does look like it is intended to solve julius's problem though :)
05:33 PM xentrac: mass storage, which is what you need for a USB stick, is on p.32
05:36 PM xentrac: no, this seems to be to implement a mass storage device (e.g. providing USB access to a μSD card), not to talk to one
05:37 PM julius: they say that this makes it easier, but than they present a 34 page manual to it
05:37 PM NoHitWonder: https://stm32f4-discovery.net/2015/08/hal-library-21-multi-purpose-usb-library-for-stm32fxxx/
05:38 PM NoHitWonder: this might work for you
05:38 PM xentrac: julius: you're going to have to read a heck of a lot more than 34 pages if you're going to implement USB yourself :)
05:38 PM xentrac: the manual sort of sucks though. it sort of seems like reading the source code might be preferable to reading this manual
05:38 PM julius: oh yes, page 32
05:39 PM Jan-: Is there a good way of shifting a ten byte array up bit by bit, so that things all overflow properly one to the other in a continuous stream
05:40 PM xentrac: it's fairly easy in assembly. in C it's kind of a PITA: a[i] <<= 1; a[i] |= a[i+1] >> 7;
05:40 PM Jan-: Yeah :/
05:40 PM xentrac: in a loop with maybe a special case for the last byte
05:40 PM Jan-: there's no native ten byte type, is there
05:41 PM xentrac: what's especially silly is that GCC actually has code to generate exactly this loop in order to do bit shifts of multibyte native types
05:41 PM Jan-: well exactly
05:41 PM xentrac: but you can't use it for the ten-byte case because, no, there isn't
05:41 PM Jan-: I guess I could do most of it as an 8 byte type
05:41 PM Jan-: which exists, doesn't it?
05:41 PM xentrac: also make sure that a is unsigned if you're going to use the code as I wrote it above ;)
05:41 PM xentrac: yeah, but that isn't going to simplify your code
05:42 PM xentrac: that's going to make it more complicated
05:42 PM xentrac: maybe more efficient
05:42 PM Jan-: Gah. This has to happen in an interrupt servicing routine :/
05:42 PM xentrac: it's only like five lines of assembly
05:42 PM Jan-: do tell.
05:42 PM xentrac: which you can copy, paste, and modify from gcc output
05:42 PM julius: NoHitWonder, that seems to be a lot more hands on, thanks
05:42 PM * Jan- cups hand behind ear and inclines it toward xentrac in an exaggerated manner
05:42 PM * Jan- is all ears
05:43 PM xentrac: also probably you can just do it in C; it's also going to be only like five lines. be careful about the first and last bytes and about sign-extension
05:43 PM Jan-: it's all unsigned.
05:43 PM xentrac: and it might be fast enough
05:43 PM Jan-: Actually.
05:44 PM Jan-: The last two bytes are the sync word.
05:44 PM xentrac: The sync word?
05:44 PM Jan-: SMPTE linear timecode. The last 16 bits are the... eh... magic number.
05:44 PM Jan-: So I could have one 8 byte type, and one 2 byte type, and the only special shenanigans is moving a bit from one to the other.
05:44 PM Jan-: or is that worse :/
05:44 PM Jan-: that's worse, isn't it
05:45 PM xentrac: it's probably slightly more complicated than doing the ten-byte-array loop
05:46 PM Jan-: I guess what I'm asking for is rotate-left-with-carry.
05:46 PM xentrac: I mean you could have a bug that only affects one of the two
05:46 PM xentrac: yup
05:46 PM xentrac: do you know how to get assembly listings out of gcc?
05:46 PM Jan-: Hellz to the no. I'm doing this in the arduino IDE.
05:46 PM Jan-: http://www.dreamincode.net/forums/topic/357893-writing-assembly-code-to-rotate-left-with-carry-confused-by-c-main/
05:46 PM xentrac: I always have to look at http://canonical.org/~kragen/light_sensing/ to remember
05:47 PM xentrac: write a small C program and compile it with avr-gcc with -Wa,-adhlns=foo.lst
05:47 PM xentrac: and then you can look at the assembly output
05:47 PM Jan-: also I can't think of a way to do it without having a temporary buffer.
05:48 PM xentrac: I don't think the i386 assembly code in there is going to help you very much ;)
05:48 PM xentrac: if you shift left starting from the leftmost byte, you don't need a temporary buffer to shift by one bit
05:49 PM Jan-: oh no.
05:49 PM Jan-: right.
05:49 PM xentrac: and the AVR doesn't have a shift-multiple-bits instruction that you can use usefully for this kind of thing, at least if avr-gcc's output is to be believed
05:49 PM xentrac: so your best option if you need to shift multiple bits (4 or less anyway) is to iterate a shift-one-bit loop
05:50 PM Jan-: I guess it's just looping over ltc_buf[i] = (ltc_buf[i] << 1) | (ltc_buf[i+1] & 0x80); except for the last byte.
05:50 PM xentrac: yeah, except you don't want the shifted-in bit to be the MSB; you want it to be the LSB
05:50 PM Jan-: argh
05:50 PM xentrac: that's why I wrote >> 7 instead of & 0x80
05:50 PM * Jan- hates endianness
05:50 PM * Jan- waves her arms
05:50 PM xentrac: no endianness involved!
05:50 PM xentrac: well, I guess in a certain sense yes
05:51 PM Jan-: Only a software engineer could decided that the biggest-valued bit goes at the left.
05:51 PM xentrac: you care which bit is on which end :)
05:51 PM xentrac: haha
05:51 PM Jan-: Wrong, computer science. WRONG.
05:51 PM xentrac: I think putting the biggest-valued digit on the left can probably be blamed on Fibonacci
05:51 PM Jan-: hmm this still doesn't actually work.
05:52 PM xentrac: In Arabic, the biggest-valued digit is last; you write the number eightscore and eight as 8, followed by 6, followed by 1
05:53 PM * Jan- does some more arm waving
05:53 PM xentrac: But because Arabic is written from right to left, that means that the 1 is on the left
05:53 PM Jan-: for reference this is the core of what I'm doing, I hope it isn't too much: https://pastebin.com/Z7QZPyjj
05:53 PM xentrac: And when Fibonacci and his ilk managed to persuade the Europeans to adopt the Hindu-Arabic numbering system, they kept the 1 on the left, even though Latin is written left to right, so suddenly the 1 came first
05:54 PM Jan-: ohh I just noticed a huge bug.
05:54 PM * Jan- indicates size of bug by placing both hands as far apart as they'll go
05:54 PM Jan-: it was THIS BIG.
05:54 PM xentrac: :D
05:54 PM xentrac: Hooray! now you can remove it :)
05:54 PM * Jan- fetches RAID
05:55 PM xentrac: Anyway, so we need to blame putting the MSB on the left on, like, Gerbert of Aurillac and Leonardo of Pisa
05:55 PM Jan-: I think it was different on Amigas, or something
05:56 PM xentrac: I think Amigas were little-endian when it came to bytes, but still normally big-endian when it came to how you would write down bits and which direction was "left" or "right"
05:56 PM xentrac: But I never programmed one!
05:57 PM xentrac: are you &~-ing or |-ing in the new LSB before shifting there?
05:58 PM Jan-: Yes.
05:58 PM xentrac: Oh, yes, and that's okay
05:58 PM Jan-: But I'm also shifting whether or not it's a complete bit.
05:58 PM Jan-: Which is the big, eight-legged fear machine of DOOM.
05:58 PM xentrac: DOOM!
05:59 PM Jan-: https://www.youtube.com/watch?v=s2jvANh2aEc
05:59 PM xentrac: I think I have to go now unfortuantely
06:00 PM xentrac: A trick you can do to eliminate the special case for the last byte is to allocate 11 bytes for the buffer and always leave the 11th byte zero
06:00 PM Jan-: Ooooo. He clever.
06:00 PM * Jan- admires xentrac's extra brains in jars out back
06:01 PM xentrac: :D
06:01 PM Jan-: anyway thanks for the help and nini
06:01 PM xentrac: I think you could reasonably argue that either way was better
06:01 PM Jan-: it's in an ISR
06:01 PM Jan-: I'll spend the byte
06:02 PM xentrac: see if you can compile the C file with the magic flags I mentioned above to see what the assembly looks like
06:02 PM xentrac: hopefully it uses ROL and not like some kind of soup of fifty zillion OR and AND instructions for the inner loop
06:02 PM Jan-: I might ask you to do that at some point
06:20 PM arij is now known as arij_work
08:29 PM arij_work is now known as arij
11:26 PM daey_ is now known as daey