#avr Logs

Apr 10 2019

#avr Calendar

02:22 AM Tusker: heya guys, I am trying to program a bare atmega162, and have tried usbasp and avrisp (ie, arduinoISP sketch), and both are not able to identify the chip. from the data sheet, it looks like it has an internal oscillator, so shouldn't need any external clock source, so I am a bit confused as to what to try next. I only have the 6 ISP wires connected (ie, no resistors or capacitors or crystals).
02:27 AM polprog: if you took it out of some board, it might be programmed to use an external crystal
02:28 AM rue_mohr: ah lets see if I can fidn it
02:29 AM rue_mohr: Tusker, show us that avrdude command
02:29 AM Tusker: avrdude -p atmega162 -c avrisp -P /dev/ttyACM1 -b 19200
02:29 AM rue_mohr: avrsap
02:29 AM rue_mohr: er, no baud rate...
02:29 AM polprog: try 'avrdude -p atmega162 -c avrisp -v' first
02:30 AM rue_mohr: -P usb
02:30 AM polprog: yeha ^
02:30 AM Tusker: it says not in sync
02:30 AM rue_mohr: usbinstall:
02:30 AM rue_mohr: avrdude -c avrisp2 -P usb -p m162 -e -U flash:w:$(PRG).hex
02:31 AM rue_mohr: what does (adjusted) that say?
02:31 AM rue_mohr: avrdude -c avrisp2 -P usb -p m162 -e -U flash:w:main.hex
02:31 AM polprog: if it cant communicate to the chip then that will say the same thing
02:32 AM Tusker: avrdude: stk500v2_ReceiveMessage(): timeout
02:32 AM polprog: Tusker can you paste the whole output somewhere?
02:32 AM polprog: of either command
02:32 AM Tusker: sure, hang 5
02:32 AM rue_mohr: Tusker, show us your programmer
02:32 AM rue_mohr: pls say its not a dragon
02:32 AM polprog: why not :D
02:32 AM polprog: and if it was, the -c is dragon_isp
02:32 AM polprog: ;)
02:32 AM rue_mohr: if its a dragon, throw it in the trash and use something else
02:32 AM polprog: nope
02:33 AM Tusker: ah, interesting, it finally gave a response using that avrisp2
02:33 AM polprog: ragon is if you can tame it, dragon is the best friend of yours
02:33 AM rue_mohr: dragon is most of the problems people have...
02:33 AM Tusker: https://pastebin.com/4dhiYg8A
02:34 AM rue_mohr: show us your programmer
02:34 AM Tusker: i tried an usbasp, and now just tried an mega2560 with the arduinoISP loaded on it
02:34 AM rue_mohr: want to know what you ahve
02:34 AM rue_mohr: stop changing things
02:34 AM rue_mohr: do the M162
02:34 AM rue_mohr: tell us exactly what programmer your using
02:34 AM rue_mohr: pick on
02:34 AM rue_mohr: e
02:34 AM Tusker: sorry, because it wasn't working, I tried alternatives
02:35 AM rue_mohr: pick something, we will make it work
02:35 AM Tusker: I am only using the ArduinoISP loaded on an mega2560 right now
02:35 AM rue_mohr: how about the usbasp
02:35 AM rue_mohr: yea, go with the asp and the m162
02:35 AM rue_mohr: tell us when you ahve it all hooked up
02:35 AM Tusker: so, I switch back to the usbasp ? :)
02:36 AM rue_mohr: yes, and the m162
02:36 AM Tusker: OK, hang on
02:36 AM rue_mohr: polprog, http://paste.debian.net/1076932/
02:37 AM polprog: thanks
02:37 AM polprog: zippo, heh
02:38 AM polprog: ;)
02:38 AM rue_mohr: you realize I'm catting mouse to show you that...
02:38 AM polprog: :D
02:40 AM Tusker: rue_mohr: and now I am going to wonder what I was doing wrong when I was testing before
02:40 AM rue_mohr: :)
02:40 AM rue_mohr: -p usb
02:40 AM rue_mohr: Tusker, so, it works then?
02:40 AM polprog: ttyACM is some weird linux serial thing
02:40 AM rue_mohr: yea, the programmer is just -p usb
02:40 AM Tusker: https://pastebin.com/uU6C81Vd
02:40 AM polprog: https://rfc1149.net/blog/2013/03/05/what-is-the-difference-between-devttyusbx-and-devttyacmx/
02:41 AM polprog: acm hayes driver lol
02:41 AM rue_mohr: wait it didn't work tho
02:41 AM Tusker: well, it's much more output than I have had before
02:41 AM rue_mohr: Tusker, did you hook it up to the m162?
02:41 AM rue_mohr: turn off the -v, too much detail
02:41 AM rue_mohr: :)
02:42 AM Tusker: ah
02:42 AM Tusker: no wonder
02:42 AM Tusker: OK, yeah, it's hooked up
02:42 AM polprog: i had the same problem with usbasp
02:42 AM rue_mohr: uh, specify a file to flash tho
02:42 AM polprog: it had too old firmware on itself
02:42 AM polprog: you dont need to specify a file
02:43 AM rue_mohr: Tusker, avrdude -c usbasp -P usb -p m162 -e -U flash:w:main.hex
02:44 AM rue_mohr: I can give you a main.hex if you want
02:45 AM Tusker: I've got a hex file I was going to program to it anyway, but it is the same error
02:46 AM polprog: uspasp sometimes has the old firmware in it which doesnt work with avrdude
02:46 AM polprog: if you got that one sold by someone, then you wont get it to work
02:47 AM polprog: i had this exact same problem
02:47 AM Tusker: do you want me to try to load https://github.com/bperrybap/usbasp/tree/1.06-alpha/bin/firmware/usbasp-v1.06-alpha-2016-05-18 or similar on it ?
02:47 AM polprog: what other programmers have you got
02:47 AM polprog: you can try
02:47 AM polprog: im not sure if its the newet
02:47 AM polprog: newest*
02:48 AM rue_mohr: someohow I'm sure thats not the problem
02:48 AM rue_mohr: Tusker, your using a 10 pin interface to the asp?
02:48 AM polprog: whats the problem then?
02:48 AM polprog: bad connections?
02:48 AM polprog: you can give it a try, thats possible
02:48 AM rue_mohr: the erronious pinout or he needs to seperatly power the avr
02:49 AM rue_mohr: iirc, the asp cant power the avr while programming
02:49 AM nuxil: im still using my raspberry as a programmer.. pi ftw :p
02:49 AM Tusker: i am using dupont cables
02:49 AM rue_mohr: my other programmers can
02:49 AM polprog: i think the error for no power was different
02:49 AM polprog: or maybe its what dragon reports for no power
02:49 AM Tusker: i measured 5v on the VCC line
02:49 AM Tusker: using a multimeter
02:50 AM polprog: should be good. ouble check pinout
02:51 AM Tusker: I wonder if I can find an already programmed atmega162 somewhere so I can verify that it isn't a bad chip
02:51 AM Tusker: is it worth updating the usbasp to that version I pasted above ?
02:57 AM polprog: if you can, then yes
02:57 AM rue_mohr: Tusker, is the power for the avr comming from the programmer?
02:58 AM Tusker: rue_mohr: yes
02:58 AM rue_mohr: I do not suggest updating the programmer....
02:58 AM rue_mohr: the problems I'v seen are always soemthing else
02:58 AM rue_mohr: give it its own power supply
02:58 AM rue_mohr: the programmer power tends to dip *just* as it tries to program
02:59 AM rue_mohr: its a problem I'v had before
02:59 AM Tusker: ok, will power independently
02:59 AM polprog: remember to disconnect programmer power
03:06 AM Tusker: seems no difference, and I am being called by the wife for dinner
03:06 AM Tusker: back later sorry
03:08 AM Tusker: i am using a QFP44 to DIP40 adapter to hold the chip, but maybe I can solder the QFP44 onto a bare board in case the adapter has issues (first time using this adapter, so maybe it is the cause)
04:18 AM dunz0r is now known as ^d
04:19 AM ^d is now known as dunz0r
04:19 AM dunz0r is now known as ^}
04:19 AM ^} is now known as dunz0r
04:20 AM dunz0r is now known as ^|
04:20 AM ^| is now known as ^|_|^
04:21 AM ^|_|^ is now known as dunz0r
06:09 AM Tusker: OK, I have soldered up the QFP44 (damn my eyesight is bad)... will test it now with the usbasp
07:11 AM Tusker: still no luck with the atmega162, even on a breakout board, it just isn't wanting to be recognized by avrdude
07:12 AM Tusker: updated the usbasp, still the same issue
07:16 AM nohit: Damn
07:18 AM Tusker: i used the arduinioisp sketch to write the latest version of usbasp using the mega2560, so I can confirm that the arduinoisp is working as expected
07:19 AM Tusker: how can I rule out the possibility that I need some capacitor or external clock while programming ?
07:20 AM nuxil: can you read the fusebits ?
07:20 AM Tusker: the isp can't even connect and verify the chip... each time the chip signature is different... (even when I change the -B etc)
07:21 AM nuxil: Tusker, noramly the chips comes with the internal RC set. so no need for external clocks.
07:23 AM nuxil: you said you where using adapters? QFP44 to DIP40.. when you do this.. are the pins correctly? like miso,mosi scl ?
07:23 AM Tusker: that's what I was expecting... the data sheet says "The device is shipped with CKSEL = 0010, SUT = 10 and CKDIV8 programmed."
07:26 AM nuxil: do you have other programers to test with? a pi or something you can try instead?
07:27 AM Tusker: yeah, I have a pi in the other room
07:28 AM Tusker: install openocd or similar ?
07:28 AM nuxil: no.
07:28 AM nuxil: https://www.instructables.com/id/Programming-the-ATtiny85-from-Raspberry-Pi/
07:28 AM nuxil: just check the DS 1st to see if the chip can do low voltage. 3.3v else you need logics to get it to 5v
07:29 AM nuxil: gpio on pi is 3.3v
07:29 AM LeoNerd: 'tiny85 can definitely be ISP programmed at 3.3V
07:29 AM nuxil: i been using my pi for a couple of years now as a programmer.
07:29 AM nuxil: LeoNerd, indeed
07:30 AM nuxil: LeoNerd, basically every atiny series. atleast the ones i tried. 13,45 and 85
07:31 AM Tusker: looks like the atmega162 can do 3V
07:34 AM Tusker: do i need the bunch of 1k resistors in the setup ?
07:34 AM nuxil: yes you want resistors. just in case. you dont want to blow up the gpio.,
07:35 AM Tusker: *nods*
07:35 AM nuxil: that led is not needed to. its for his blink program.
07:35 AM nuxil: *tho.
07:45 AM Tusker: https://pastebin.com/N0r4KJhP < that's what I am seeing using the arduino mega2560 (the same as what I used to program the usbasp)
07:58 AM Tusker: any ideas why it would be like that? is there a way to reset the chip back to "factory" in case the seller shipped the chips expecting an external clock etc ?
08:08 AM nuxil: yes. there is a way to reset a chip. hwpp or hwsp you need to check the DS for that.
08:08 AM nuxil: *hv
08:08 AM nuxil: high voltage parallel/serial programing.
08:09 AM nuxil: did you try with you pi?
08:09 AM nuxil: also if you need a clock.. you can try using either a arduino or a pi as a clock source.
08:13 AM nuxil: why are you using -F
08:15 AM Tusker: nuxil: because the chip sig shows up as 0x0000000 so was seeing if there was more info
08:15 AM Tusker: (haven't used the pi yet, since haven't found my 1k resistor stash)
08:16 AM Tusker: clock source from the arduino is an interesting idea
08:16 AM nuxil: you can probably use resistors upto 4.7k or more.
08:16 AM LeoNerd: Are these just IO line drive-contention protection?
08:17 AM LeoNerd: If so you don't need anything more than 250ohm at 5V; that will limit things to the 20mA drive strength of the pins
08:17 AM LeoNerd: I usually put 330
08:39 AM Tusker: hmmm - why does this board have something special for the atmega162 - https://www.waveshare.com/m16-adpii.htm ?
08:40 AM Tusker: ah, maybe just for the external clock pins... the ISP pins are the same but the XTAL pins are different
08:47 AM nuxil: no idea.
08:48 AM nuxil: is your atmega in a TQFP44 package ? or dip?
08:50 AM Tusker: TQFP44
08:51 AM Tusker: i have a TQFP breakout board, and a TQFP44 socket, both behave the same way
08:51 AM Tusker: (sorry for being annoying about the pi... it is in a room I can't really access today)
08:54 AM nuxil: well try use an arduino as a clock source. make a fast, simple blink program on a pin. then feed it to the xtal1 pin on your chip then retry and program it.
08:58 AM Tusker: fast, as in delay(1); ?
09:08 AM nuxil: delay(1)? if that was ms. thats not fast at all. :p
09:10 AM nuxil: you probably want 50khz +++. _delay_us(N) instead of _delay_ms(N), iirc. i think polprog did this once using a 32khz crystal or something.
09:11 AM polprog: once youset your F_CPU then you can use _delay_ms and _us pretty much just like that
09:12 AM polprog: and that what i did was using the crystal as the timer source, and the chip ran on internal osc i think...
09:12 AM polprog: or maybe not
09:22 AM Tusker: _delay_us(N), N== ?
09:22 AM polprog: n is the number of us
09:22 AM Tusker: i can use a uno
09:22 AM polprog: microseconds
09:22 AM Tusker: (i get that, but what should I set)
09:22 AM Tusker: to be an external clock source for the atmega162 ?
09:23 AM polprog: how much delay do you need?
09:24 AM Tusker: i am going off the blink sketch idea, to be the external clock source, so if I need > 50khz, then what does that translate to in the nanosecond delay ?
09:24 AM nuxil: your using -b 19200 so you want atleast 2x times that.
09:25 AM nuxil: f = 1/n
09:28 AM nuxil: so 50khz is around 1/0.00002 . so you want 10us for pin on. then 10us for pin off. if im correct.
09:28 AM polprog: wohoo. the avr is in the rig
09:28 AM polprog: now time to hook up the lcd
09:28 AM polprog: time for a break
09:28 AM Tusker: let's try that
09:30 AM nuxil: Tusker, may i ask where did you order this chip from ?
09:31 AM Tusker: aliexpress
09:31 AM nuxil: o.O
09:31 AM Tusker: yes, I know
09:32 AM nuxil: just no :p order from proper sources :p mouser, digikey etc.
09:36 AM Tusker: nuxil: I think I will have to, just to rule out bad chips, rather than just bad method
09:40 AM nohit: https://i.postimg.cc/t4CLG2KB/elektor.png
09:40 AM nohit: these are pretty cheap
09:42 AM cehteh: i have the owon ds7102 the huge display is really neat
09:43 AM cehteh: firmware has some minor bugs and fuckups, but nothing which is really annoying
10:04 AM nohit: that psu looks cool
10:12 AM polprog: https://twitter.com/polprogpl/status/1115988283773812736
10:31 AM Tusker: thanks guys, I'm going to go to bed for now, maybe a dream will fix my chip for me, or maybe I'll go and salvage a working one off another board just to test
10:32 AM Tusker: ciao
12:43 PM gsi__ is now known as gsi_
12:54 PM polprog: https://i.ibb.co/XDx5bGp/IMG-20190410-185348.jpg
08:05 PM davor_ is now known as davor
10:59 PM gsi__ is now known as gsi_
11:42 PM day_ is now known as day