#avr Logs

Apr 22 2020

#avr Calendar

01:52 AM davor_ is now known as davor
02:09 AM rue_bed: Smidge204_, after digging, I found that software i2c is generally just as fast, and takes MUCH less code, than using the hardware systems
02:09 AM rue_bed: I use flurrys i2c
09:09 AM Smidge204_: rue_bed: I also use software I2C, having been very frustrated with the hardware TWI interface. Only downside is it needs to be tuned with a scope if clock frequency is critical since you can't configure the peripherial clock to control it
09:10 AM LeoNerd: Oddly, I find hardware I²C preferrable because of concurrency. I can leave it to do its thing while I do other stuff
09:10 AM LeoNerd: Whereas SPI is usually fast enough there's no real point
09:11 AM LeoNerd: Especially talking to 100kHz chips
09:11 AM Smidge204_: I just had a bad experience I guess
09:12 AM LeoNerd: Hardware I²C has had a few different peripheral types on AVR chips.. some of the hardware is... weird
09:12 AM LeoNerd: The modern 1-series UPDI chips are quite nice
09:12 AM LeoNerd: The older USI-based ATtiny chips were crazy and hardly counts as hardware at all.. more like hardware-accelerated bitbanging
09:13 AM Smidge204_: Maybe some day I'll give it another go :)
09:14 AM LeoNerd: Happy to share my HAL stuff if it helps
09:15 AM Smidge204_: Pretty happy with my I2C lib based on Fleury's lib :D For the current project the I2C traffic is fairly minimal
09:16 AM Smidge204_: But I'm gonna have I2C, SPI and UART all implemented, so now I'm out of pins and may need to consider other options
09:17 AM LeoNerd: What chip?
09:17 AM Smidge204_: Attiny814
09:17 AM LeoNerd: Ah.. yes it's a nice chip :) It's my new go-to favourite
09:18 AM LeoNerd: Though gotta admit I'm excited about the "Future Product" that appears to be the ATtiny162x series :)
09:18 AM LeoNerd: It looks like they're removing the TCD, but adding some new bits.
09:18 AM LeoNerd: Two USARTS!
09:18 AM Smidge204_: heh
09:19 AM LeoNerd: To be honest I won't miss TCD.. it seems a bit weird and very special-case. If you're not making a dual H-bridge motor driver, I don't really see what its point is
09:19 AM LeoNerd: But the A and B timer types are nice. Especially getting 6 PWMs out of TCA :)
09:19 AM Smidge204_: Since I'm bitbanging I2C maybe I can cheat and share with the UART pins
09:19 AM LeoNerd: Why are you bitbanging I²C on a tiny814? It has a lovely TWI peripheral
09:20 AM LeoNerd: This isn't the USI dark-ages
09:20 AM Smidge204_: As described above, it wasn't a good experience
09:20 AM Smidge204_: idk
09:20 AM LeoNerd: Hrm... probably some mistake somewhere then,.. I find it nice to use
09:20 AM Smidge204_: Surely was, but that's the way it goes
09:21 AM Smidge204_: BUT! it might be to my advantage if I can share the pins. The UART will only be used to update an external flash memory via PC, so basically never used
09:21 AM LeoNerd: But anyhow.. once you've used I²C, USART and SPI on a t814 you've still got PA5/6/7 spare :)
09:22 AM Smidge204_: yeah but I need... lemme run through this one more time just to check myself, one sec
09:22 AM LeoNerd: Well yeah.. soft I²C can use any pins
09:22 AM LeoNerd: Though I think the t814 has the remap registers... you can move TWI somewhere else
09:22 AM Smidge204_: Yeah there's alternate pins
09:22 AM LeoNerd: Oh.. but only onto PA1/2 where it'll collide with SPI
09:22 AM LeoNerd: Such is the way :/
09:23 AM Smidge204_: mmhmm
09:23 AM LeoNerd: I'm still waiting for any AVR chip to have a PIC24-style crossbar system
09:23 AM LeoNerd: any peripheral, any pin
09:23 AM LeoNerd: Even the fanciest of XMEGAs are fixed
09:24 AM Smidge204_: Okay so the user interface is three buttons and two switches. The buttons need to work on interrupts so they can't be multiplexed
09:25 AM Smidge204_: So out of 14 pins; Two for power, one for UPDI*, four for SPI, two for UART, two for I2C, that leaves me with 3. I'm two pins short.
09:25 AM Smidge204_: I can finagle the UPDI pin as a general IO but then I'd need to use high voltage programming to get that pin back
09:26 AM LeoNerd: Hah.. "can't be multiplexed" ;)
09:26 AM LeoNerd: I've muxed 3 buttons on a single ADC pin and still used interrupts, before
09:26 AM LeoNerd: The trick is to use one of the anacomp pins, and put the idle state on the other side of the anacomp trigger level from any of the buttons
09:27 AM LeoNerd: So you use AC trigger to know when a button is pressed, then sample ADC to find which
09:27 AM Smidge204_: I thought about that; but not using the AC. interesting.
09:27 AM LeoNerd: Also, get one of my 12V UPDI programmers, then you can just use GPIO mode
09:27 AM Smidge204_: The AC can operate independent of the DAC right?
09:27 AM LeoNerd: They're far more convenient than HVSP on the older chips
09:28 AM LeoNerd: 12V kicked UPDI is still regular UPDI, just with an initial pulse. So as far as programming software goes it looks the same
09:29 AM LeoNerd: anacomp pins are PA6/PA7 on this chip.. which are also ADC pins. So this technique could work
09:30 AM LeoNerd: And yes, you can mux the anacomp input directly from VREF rather than DAC
09:32 AM Smidge204_: Something to consider then. I'd be interested in some more details about that actually
09:33 AM Smidge204_: I originally shied away from using analog multiplexing because of power usage; running on 2xAA cells for as long as possible is one of the goals so every microamp is worth thinking about
09:35 AM Smidge204_: I'll probably fall way short but the device I'm trying to replicate lasts about 2 years on a pair of alkali AAs so that's the gold standard of performance
02:10 PM rue_mohr: Smidge204_,
02:11 PM rue_mohr: what if I told you a way to make the two buttons operate 1 interrupt , with a normal IO for you to tell which was pushed?
02:17 PM rue_mohr: oh, I like the comparator thing better
02:41 PM [1]MrMobius is now known as MrMobius
04:09 PM Smidge204_: rue_mohr: I'm listening anyway :D
04:23 PM rue_mohr: oh I had a diagram
04:23 PM rue_mohr: its still 2 pins, but only 1 interrupt
04:24 PM rue_mohr: you add a transistor and two resistors (one of them might be optional) the buttons come off the transistors base, so they both activate it, indicateing a button is down
04:25 PM rue_mohr: from there, you can monitor one of them by an io pin from the interrupt and know if it was one or the other
04:25 PM rue_mohr: diagram?
04:27 PM Smidge204_: I might need it, yeah.
04:27 PM Smidge204_: I guess each button activates the transistor a different amount and that's the basis of detection?
05:09 PM markasoftware: I know the new 0-series chips have a 150kbps, 10bit ADC, while most older AVRs have a 15ksps 10bit ADC
05:10 PM markasoftware: are there any pre-0-series ones with the faster adc?
05:10 PM markasoftware: apart from atxmega, which is doing its own thing
05:11 PM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/p1150781.jpg
05:11 PM rue_mohr: both buttons will trigger the interrupt, but only the one will also trigger the io
05:12 PM rue_mohr: you might be able to use the internal pullup in the avr for the io line
05:12 PM rue_mohr: I dont know if its strong enough to trigger the transistor
05:17 PM Smidge204_: rue_mohr: Ah, interesting.
05:18 PM Smidge204_: Two buttons on two pins, though, doesn't seem much an advantage
05:18 PM Smidge204_: markasoftware: 115ksps not 15ksps
05:19 PM Smidge204_: markasoftware: Microchip has a parametric search tool that you can dig through their many, many offerings
05:23 PM rue_mohr: 1 interrupt pin
05:23 PM rue_mohr: thats about it
05:24 PM rue_mohr: apr 21 he posts the image that looked like my diagram..
05:25 PM Smidge204_: hrm
05:26 PM rue_mohr: haha on apr20 I posted that drawing
05:26 PM Smidge204_: heh
05:27 PM Smidge204_: Things get lost in the buffer here, it moves too fast!
05:37 PM markasoftware: Smidge204_: indeed, you are right :) I only checked for the attiny84 and 85, which do have 15ksps, but most have 115 as you indicated
05:37 PM markasoftware: and unfortuantely that parametric search tool doesn't support filtering on adc speed
06:08 PM Smidge204_: What are you trying to do?
06:46 PM day_ is now known as day
06:49 PM Smidge204: Not entirely sure, but I think if I let the serial port streaming in data and there's nothing reading the port buffer, it may crash my computer eventually
06:49 PM Smidge204: :D
06:49 PM Smidge204: Or it could be some abusing of (improperly) opening and closing the serial port over and over that makes something unhappy, or a combination of both
06:51 PM cehteh: anything sensible would just report errors not crash
06:51 PM cehteh: as in anything but arduino :)
06:52 PM Smidge204: No arduino here, but I was working on my own VisualBasic program which is almost certainly the source of the problem
11:37 PM day_ is now known as day