#avr Logs

Apr 08 2020

#avr Calendar

02:01 AM rue_mohr: Evidlo, whats the range?
02:07 AM rue_mohr: Ipresume the scale is mm h2O?
05:35 AM aborazmeh_ is now known as aborazmeh
12:09 PM evidlo2: anyone know why I can read from an attiny with my usbasp, but not an atmega? https://termbin.com/4xak4
12:10 PM evidlo2: wait, I just tried another and it works
12:10 PM LeoNerd: Check connections, etc..
12:10 PM LeoNerd: Voltage drive can sometimes be very close
12:10 PM evidlo2: digikey sent me a bad atmega
12:10 PM LeoNerd: I've found the stupid 100nF capacitor of Arduino board auto-reset can sometimes upset some programmers
12:10 PM LeoNerd: but others are fine
12:10 PM LeoNerd: It's all a bit of a mess
12:11 PM evidlo2: this is a bare atmega and usbasp
12:11 PM LeoNerd: If you've got /a/ bare chip that doesn't respond to ISP it might have had the fuses changed
12:11 PM LeoNerd: Do you have an HVPP to fix it?
12:11 PM evidlo2: I only have a usbasp
12:12 PM evidlo2: These atmegas are from the same tube though
12:12 PM LeoNerd: Ah, tricky
12:13 PM evidlo2: well I'm glad I got 2, otherwise I'd be wasting the rest of the day wondering why my programmer isn't working
12:15 PM evidlo2: OK it seems its actually my fault. I tried Burn Bootloader in the Arduino IDE and I can no longer read from it
12:15 PM evidlo2: do I need a high voltage programmer to recover from this state?
12:18 PM evidlo2: so maybe the clock source got changed?
12:21 PM LeoNerd: Maybe..? Depends what the fuses were set to
12:21 PM LeoNerd: Find yourself an oscillator to apply to the clock pin
12:24 PM evidlo2: ok I fed it 12MHz from the crystal on the usbasp and I can read from it again
12:25 PM evidlo2: need to reset the fuses now
12:25 PM evidlo2: also is there a nice HAL that works for atmegas and attinys that's less bloated than arduino?
12:26 PM evidlo2: I mostly don't want to have to lookup register settings for simple things like setting pin mode, reading ADC, etc.
12:27 PM Fuchikoma: There's not much to "look up" for setting pin modes tbh just set the DIR bit
12:28 PM LeoNerd: I ended up writing my own HAL
12:28 PM LeoNerd: They're not tricky...
12:28 PM Fuchikoma: 9000?
12:28 PM evidlo2: so are there any popular HALs?
12:28 PM LeoNerd: Though mostly I'm concentrating on the AVR 1-series ATtiny chips these days
12:29 PM LeoNerd: Hah! Popular is a weird word. It says things about people's opinions
12:29 PM LeoNerd: Arduino is probably the most /common/ of the AVR HALs
12:29 PM evidlo2: its just slow and I've never been able to figure out how to get it to work with makefiles
12:29 PM Fuchikoma: Program everything in ASM :D
12:30 PM LeoNerd: Oh.. if you want Makefiles, use inotool
12:30 PM LeoNerd: You don't have to go near the Arduino IDE to use that
12:35 PM evidlo2: doesn't look maintained anymore
12:36 PM twnqx: i have 25 of 28k used without any HAL :P
12:36 PM twnqx: i wouldn't want to use anything that's bloated...
12:36 PM LeoNerd: Ah. Unfortunate
12:37 PM evidlo2: twnqx: https://i.imgur.com/n0MLn2Z.jpg
12:38 PM twnqx: that was quick :D
12:38 PM twnqx: do you etch yourself?
12:38 PM evidlo2: this was routed
12:38 PM twnqx: also, uh... isn't that the wrong way around? :S
12:38 PM Fuchikoma: I was gonna say that looks routed
12:39 PM evidlo2: is what the wrong way around?
12:39 PM twnqx: well, i usually would have the traces on the bottom side
12:39 PM evidlo2: the traces?
12:39 PM evidlo2: its 2 layer
12:39 PM twnqx: how do you do the contacting? rivets?
12:39 PM Fuchikoma: Quite nicely routed, too. What machine do you have?
12:39 PM evidlo2: solder both sides
12:40 PM twnqx: ah
12:41 PM twnqx: i can't even remember the last time i did a through-hole pcb (except for stuff like dsub connectors, etc)
12:41 PM twnqx: but yeah, pretty neat.
12:41 PM evidlo2: I think this was the router: https://www.youtube.com/watch?v=PWpUsra3Gh0
12:41 PM twnqx: how do you do anticorrision afterwards with the bare copper?
12:41 PM evidlo2: I don't
12:42 PM Fuchikoma: sexy
12:42 PM twnqx: mh
12:42 PM twnqx: while neat, i guess i won't be going back :)
12:44 PM evidlo2: are there any HALs that live entirely in the preprocessor step?
12:44 PM LeoNerd: I doubt it
12:44 PM LeoNerd: "preprocessor" isn't overly a /thing/ these days. Not really
12:44 PM LeoNerd: Flags like -flto mean that most of the compiler is .. sortof "preprocessor"
12:45 PM LeoNerd: I do all my AVR builds with -flto; it makes very nice output of HAL'ed functions
12:45 PM evidlo2: I ask because a design requirement is that the code is readable by those not very familiar with AVRs
12:46 PM Fuchikoma: Have you considered using comments to explain the code?
12:47 PM Fuchikoma: If you really need the project code to be "readable" by someone who isn't familiar with AVRs then IMHO you should have maybe two or three lines of comments for each line of code to explain, in simple language, what's going on and why
12:48 PM twnqx: i suppose that you really have to look at your components during design - that piezo won't be top-side solderable, so no through connecting there :P
12:49 PM evidlo2: if I eschew arduino entirely, can someone still build and flash my c program using the arduino IDE?
12:49 PM evidlo2: assuming I also provide a boards.txt
12:49 PM twnqx: why are the switches going off-board? something connected there?
12:49 PM twnqx: arduino calls avrdude in the end, so probably, yes
12:50 PM evidlo2: didn't have the right switches at the time. the Digikey order just came in
12:50 PM evidlo2: also this is just a prototype. for high volume we are using an external board house
12:50 PM twnqx: but i'd rather provide a .bat file and avrdude
12:50 PM Fuchikoma: I dno't use ArduinoIDE enough to be sure how compatable it is with, say, generic C compilers
12:51 PM LeoNerd: Probably objective, but I think my HAL is fairly readable
12:51 PM LeoNerd: E.g. USART0_setup(BAUDRATE(19200), USART_8bit, USART_noparity, USART_1stop);
12:52 PM LeoNerd: Pretty sure anyone can guess what that probably does
12:52 PM evidlo2: what devices do you support
12:52 PM LeoNerd: I have one for AVR 1-series tinies; and another for the older ISP-style chips... t13 85 84 841 m328p m328pb, ... a few others
12:52 PM twnqx: out of curiosity... are there through-hole microusb connectors?
12:53 PM LeoNerd: Adding new chips usually isn't tricky
12:53 PM LeoNerd: twnqx: I've used TTH miniB, but I've never seen a micro
12:53 PM twnqx: i'll switch to so-called THR (through-hole reflow) that have the case as though hole with so small holes you still put paste on/in, but the pins as smd
12:54 PM twnqx: so completely smd-process compatible, but more stability
12:54 PM evidlo2: yes, Wurth 6941 series
12:54 PM twnqx: heh
12:54 PM twnqx: i am using their micro-ab THR :P
12:55 PM twnqx: i like that ordering straight from them is much cheaper than digikey or mouser
12:57 PM Fuchikoma: twnqx: avrdude is just a utility for programming the device, it won't compile/link source code...
12:57 PM twnqx: ok, my understanding of "programming" was "putting the binary on", not "writing the code". my bad.
12:58 PM Fuchikoma: Fair enough
01:00 PM evidlo2: I'm trying to reset the fuses to use the internal clock. Should the defaults for atmega328p here work? http://www.engbedded.com/fusecalc/
01:01 PM twnqx: what i really dislike is that you can't do that without applying a clock
01:01 PM twnqx: i feel that at some point i'll use a different programming adapter/connector that also provides a clock, just for that purpose
01:01 PM Fuchikoma: lesse
01:03 PM LeoNerd: The UPDI chips don't have a clock-selection fuse
01:03 PM LeoNerd: It's basically impossible to kill those this way
01:03 PM LeoNerd: The chip always boots on the internal oscillator, and you just switch to a different one in code
01:03 PM Fuchikoma: CKSEL should be 0010 for the internal RC oscillator
01:04 PM evidlo2: well after trying to flash the arduino bootloader, it stopped communicating until I hooked up an external crystal
01:04 PM LeoNerd: Yeah, it will
01:04 PM LeoNerd: The Arduino boards all have a ceramic resonator on board
01:04 PM LeoNerd: So all the Arduino code things will be expecting it
01:05 PM Fuchikoma: The internal oscillator runs at 8MHz and the default prescaper is /8 for a 1MHz system clock, if that matters to you
01:05 PM evidlo2: I'm trying to undo that, but the fuse settings aren't working
01:05 PM evidlo2: still stops responding when I remove the crystal
01:05 PM Fuchikoma: Have you tried loading avrdude in terminal/interactive mode?
01:05 PM LeoNerd: "stops responding" ... to what?
01:05 PM Fuchikoma: A bit easier to see what's going on
01:06 PM evidlo2: avrdude gives me "target doesn't answer"
01:06 PM LeoNerd: avrdude talking how..?
01:06 PM LeoNerd: Also... if you're using ISP why are you bothering with the Arduino bootloader?
01:07 PM evidlo2: for now I'm just trying to fix the fuses
01:07 PM Fuchikoma: Right
01:07 PM LeoNerd: -U efuse:w:0xFF:m -U hfuse:w:0xD9:m -U lfuse:w:0x62:m
01:07 PM LeoNerd: is the default
01:08 PM * LeoNerd hugs avr-fuses
01:08 PM LeoNerd: avrdude -p m328p $(avr-fuses -p m328p) to write defaults
01:08 PM Fuchikoma: ooh that's a useful thing to know
01:09 PM LeoNerd: https://metacpan.org/pod/distribution/App-AVR-Fuses/bin/avr-fuses
01:10 PM evidlo2: while :; do sleep 1; avrdude -c usbasp -p atmega328 -U lfuse:w:0x62:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m; done
01:10 PM LeoNerd: Don't forget the p. atmega328p is not atmega328
01:10 PM evidlo2: so while thats running, I connect the crystal and get a success, but then it starts failing as soon as I disconnect
01:11 PM LeoNerd: You need to power cycle the chip before the clock fuse takes effect
01:11 PM LeoNerd: The usbasp will keep power on it
01:11 PM evidlo2: ok adding the p fixed it
01:13 PM LeoNerd: The only thing adding that p should do is fix a complaint about mismatched signature
01:13 PM Fuchikoma: Three cheers for voodoo debugging
03:57 PM evidlo2: should it be easy to replicate millis()?
06:10 PM Smidge204_: Question: Trying to get the DAC on an Attiny814 working. Best I can tell from the datasheet, it outputs on PS6 (pin 4), I set the control register bits to enable and output enable, and write data to the DATA register
06:10 PM Smidge204_: But I get nothing on pin 4. I'm clearly missing something...
06:11 PM Smidge204_: Peripheral clock is fine
06:12 PM cehteh: done by example as in dataasheet?
06:13 PM Smidge204_: There's no example in the datasheet
06:14 PM cehteh: hum ok ...
06:14 PM cehteh: well dunno never used that
06:15 PM * Smidge204_ headscratches
06:22 PM rue_mohr: hmm
06:22 PM rue_mohr: must be a microchip thing
06:22 PM rue_mohr: atmel always did examples
06:38 PM Smidge204_: Well, I wasn't setting the VREF for the DAC which was *a* problem, but not *the* problem. Still getting bupkis.
07:09 PM Smidge204_: I found this; file:///C:/Users/SMIDGE~1/AppData/Local/Temp/TB3210-Getting-Started-with-DAC-90003210A.pdf
07:10 PM Smidge204_: Though despite following the steps 1:1 it still doesn't work so idk
07:29 PM Thrashbarg: going to have a hard time accessing that URL
07:31 PM Smidge204_: pffft haha
07:31 PM Smidge204_: http://ww1.microchip.com/downloads/en/Appnotes/TB3210-Getting-Started-with-DAC-90003210A.pdf
07:32 PM Smidge204_: Anyway to isolate the problem I started a new project and now it's telling me I have an empty source file
07:42 PM Smidge204_: Jesus christ somehow a non-printable character got into the source file and was fucking everything up
09:10 PM JanC_ is now known as JanC
11:55 PM day_ is now known as day