#avr | Logs for 2015-12-25

Back
[04:28:13] <NicoHood> how can i use progmem within printf()?
[04:28:22] <NicoHood> the f() makro doesnt seem to work
[04:36:48] <Thrashbarg> NicoHood: I was curious too. It seems the AVR printf() function has a %S (capital letter) tag which directs printf to PROGMEM
[04:37:13] <Thrashbarg> http://deans-avr-tutorials.googlecode.com/svn/trunk/Progmem/Output/Progmem.pdf
[04:37:14] <Thrashbarg> last page
[04:37:26] <NicoHood> but what if i want to use the identifiers in progmem too?
[04:39:04] <NicoHood> the first param of printf() i mean. in this case "The value of %S..."
[04:40:22] <NicoHood> this combination seems to work: printf_P(PSTR(
[04:44:19] <NicoHood> wasnt there a makro like "flash" that does all that automated, but only in c, not c++?
[05:59:34] <NicoHood> I want to measure the stack usage. I used this code:
[05:59:34] <NicoHood> http://www.avrfreaks.net/forum/soft-c-avrgcc-monitoring-stack-usage
[06:00:12] <NicoHood> however sometimes it works and after a reupload it uses the last stack measurement. this means the stackpaint function does not start always. any ideas why?
[06:06:02] <NicoHood> the init1 attribute seems to cause problems. with manual calling it works fine
[09:49:12] <NicoHood> there are 4 versions of the 644 here:
[09:49:12] <NicoHood> http://www.atmel.com/products/microcontrollers/avr/megaAVR.aspx
[09:49:44] <NicoHood> which version should I use? Two of them have 1 usart, 2 2usart. I read something about power consumption and quality, but what is really better now?
[09:52:16] <Lambda_Aurigae> use what fits your project and whatever is current.
[09:53:49] <Lambda_Aurigae> the p versions have picopower capability.
[09:55:10] <Lambda_Aurigae> the baseline 644 is an old chip..not sure if it's even still in production.
[09:56:20] <Lambda_Aurigae> 644p is no longer in production it seems either.
[09:56:58] <Lambda_Aurigae> so I would go with the 644pa
[09:57:13] <NicoHood> but there is also a P and a PA version. both have 2 usarts, but one can operate at lower power
[09:57:14] <Lambda_Aurigae> it is the newest,,has all the functionality of the earlier models plus
[09:57:26] <Lambda_Aurigae> P is an older model.
[09:57:46] <Lambda_Aurigae> functionally, P and PA should be very similar...however, P is no longer made.
[09:57:50] <Lambda_Aurigae> PA replaced the P
[10:00:02] <NicoHood> there were some issues with 256kb, right? because some opcode doesnt work then. what was the limit again? 64kb or 128kb?
[10:00:20] <NicoHood> i remember that it was 128kb for opcode and 64kb for progmem
[10:00:47] <Lambda_Aurigae> if you are writing in assembly, yes, you have to jump through some hoops to go beyond 128K words....however, a 128K chip is 64K words actually.
[10:01:04] <Lambda_Aurigae> so, it's actually going to the 256K chips from earlier chips you have to deal with that.
[10:01:19] <Lambda_Aurigae> anything up to 128K chips is not an issue as you are working in words,,generally.
[10:01:25] <Lambda_Aurigae> it's kind of confusing.
[10:01:38] <Lambda_Aurigae> if you are working in C then there is no issue..the compiler handles it for you.
[10:01:52] <NicoHood> so you only have the problem if you jump from the upper to the lower 128kb?
[10:02:02] <Lambda_Aurigae> yes.
[10:02:13] <NicoHood> i remember to have some weird issues with the mega2560 in the arduino ide
[10:02:22] <Lambda_Aurigae> it's not a problem, just a different command setup..you have to use an external register to deal with it.
[10:02:33] <Lambda_Aurigae> no clue about ardweeny crap...it's horribly written anyhow.
[10:02:41] <NicoHood> now i want to write with bare c and a makefile. however i want to avoid those problems before i buy the chip. so the question is now 644pa or 1284p
[10:02:52] <Lambda_Aurigae> I use the 1284p chips all the time.
[10:02:59] <Lambda_Aurigae> no problems with the gcc compiler on it.
[10:03:16] <Lambda_Aurigae> it handles the memory boundary crossover just find as it only has 64K words of flash.
[10:03:51] <Lambda_Aurigae> atmega1284p chip is my favorite AVR.
[10:04:00] <Lambda_Aurigae> second favorite being the attiny85 thanks to Jartza
[10:04:13] <NicoHood> why because of jartza?
[10:04:29] <Lambda_Aurigae> because of what he has done with the attiny85 generating vga video with one.
[10:04:37] <NicoHood> yeah i remember
[10:04:46] <Lambda_Aurigae> https://drive.google.com/a/bethnray.com/file/d/0B2dTzW9TMeBxbXlTZUN5QUgzYzQ/view
[10:04:52] <NicoHood> so does the compiler has to jumpt for 128kb? or only for 256kb?
[10:05:26] <Lambda_Aurigae> https://www.youtube.com/watch?v=G1QWNDck0yU
[10:05:47] <NicoHood> i know this vicdeo already
[10:05:55] <Lambda_Aurigae> the expanded jump is only needed on the 256K flash chips...which have 256K bytes or 128K words of flash..
[10:05:55] <NicoHood> he showed me 2 days ago
[10:06:10] <NicoHood> so the magic limit is 128kb/64words?
[10:06:15] <Lambda_Aurigae> atmega1284p only has 128K bytes or 64K words of flash.
[10:06:19] <Lambda_Aurigae> yup.
[10:06:24] <NicoHood> great
[10:06:26] <NicoHood> where do i get those chips best from? how can china vendors sell arduino mega for 10$ if the chip itself costs >10$?
[10:06:51] <Lambda_Aurigae> when I last bought atmega1284p chips I paid $6.00 USD each for them.
[10:07:02] <Lambda_Aurigae> I've also gotten free samples from atmel.
[10:07:33] <NicoHood> why?
[10:07:42] <Lambda_Aurigae> because I asked for them?
[10:07:51] <NicoHood> it costs 8,8€ at reichelt (who are normally cheap)
[10:08:17] <NicoHood> but not everyone is getting free samples i think
[10:08:23] <Lambda_Aurigae> probably.
[10:08:30] <Lambda_Aurigae> you have to know how to sweet talk your atmel rep.
[10:08:37] <NicoHood> XD
[10:08:50] <NicoHood> and where did you order them for 6$?
[10:10:06] <Lambda_Aurigae> http://www.futurlec.com/cgi-bin/search/search.cgi
[10:10:20] <Lambda_Aurigae> futurlec.com has them for 6.90 USD
[10:10:44] <NicoHood> im in germany, i think the shipping will be too high
[10:10:57] <NicoHood> are there also fakes out there?
[10:11:00] <Lambda_Aurigae> http://www.futurlec.com/Atmel/ATMEGA1284P-PUpr.shtml
[10:11:06] <Lambda_Aurigae> probably are fakes out there.
[10:11:15] <Lambda_Aurigae> I only buy from reputable dealers so don't have a problem with it.
[10:11:49] <Lambda_Aurigae> digikey has them for $8.51 USD in quantity 1...as low as 4.73 for 1000 quantity.
[10:11:56] <Lambda_Aurigae> I usually buy in 10 to 50 quantity
[10:14:10] <NicoHood> well i dont need that much
[10:14:42] <NicoHood> i mean i have tons of arduinos here, but i only have one running for a real use. the others are just for trying things out^^
[10:17:21] <Lambda_Aurigae> to each their own.
[10:17:34] <NicoHood> i think i am going to buy it from a local store
[10:17:43] <Lambda_Aurigae> futurlec is not too bad shipping wise around the world...but can take 2 to 3 weeks to get something.
[10:18:06] <NicoHood> we have a store which sells those stuff (more expensive though). but 6€ shipping is also a lot, so who care
[10:18:17] <Lambda_Aurigae> yeah..it can even out.
[10:18:31] <Lambda_Aurigae> nothing local here sells anything like that so I order everything online.
[10:18:49] <Lambda_Aurigae> generally I do 100 to 200 dollar orders once a year or so.
[10:20:05] <Lambda_Aurigae> anything else I need is usually either gathered as samples or ripped out of copiers, printers, TVs, computers, or other electronic devices.
[10:20:21] <Lambda_Aurigae> dozens of motor controllers in the motor controller bin...
[10:20:36] <Lambda_Aurigae> I spend a couple of weekends a year desoldering STUFF.
[10:21:00] <NicoHood> yeah XD
[10:21:12] <NicoHood> i really like this one: www.thaieasyelec.net/archives/Manual/The%20Arduino%20Diecimila%2028-40%20PIN.pdf
[10:21:13] <Lambda_Aurigae> stuff that I collect all year long.
[10:21:32] <NicoHood> i have all my stuff at home. sadly i am at home about 30 days a year
[10:22:00] <Lambda_Aurigae> nothing on that board that I can'd do without the arduino name attached.
[10:22:09] <NicoHood> sure
[10:22:11] <Lambda_Aurigae> all on solderless breadboard even.
[10:23:19] <Lambda_Aurigae> I've even started making my own breadboarded usb adapters with usbPIC chips.
[10:23:38] <Lambda_Aurigae> pic16f1454 chips make an awesome usb-serial adapter.
[10:24:25] <Lambda_Aurigae> no external components needed
[10:25:32] <NicoHood> is this dip compatible?
[10:25:38] <Lambda_Aurigae> it is a dip chip, yes.
[10:25:54] <Lambda_Aurigae> https://hackaday.io/project/6258-two-component-usb-temperature-data-logger
[10:26:02] <Lambda_Aurigae> I modded this to do usb-serial.
[10:26:25] <Lambda_Aurigae> it is more compatible, and faster, than an avr running v-usb too.
[10:26:48] <Lambda_Aurigae> I still prefer avr overall
[10:27:00] <Lambda_Aurigae> but sometimes you gotta use the best chip for the project.
[10:29:02] <Lambda_Aurigae> I used to do it with attiny85 running v-usb but ran into quite a few compatibility and speed issues.
[10:29:19] <NicoHood> vusb isnt made for cdc serial
[10:29:26] <Lambda_Aurigae> yeah
[10:29:40] <Lambda_Aurigae> cdc by spec requires full speed usb
[10:29:44] <Lambda_Aurigae> v-usb is only low speed
[10:30:03] <Lambda_Aurigae> most OSs have a patch or workaround to use CDC on low speed.
[10:30:29] <Lambda_Aurigae> but I've run into a few issues with CDC on low speed as well as v-usb in general.
[10:32:34] <NicoHood> how can i use the jtag interface? which programs on linux support that? doesn anyone really use this?
[10:32:43] <Lambda_Aurigae> dunno on that one.
[10:32:46] <Lambda_Aurigae> I don't use jtag.
[10:32:49] <NicoHood> I only know people debugging via I/O and logic analyzer or via serial
[10:33:03] <Lambda_Aurigae> I'm sure jtag with a jtag-ice works on linux using avr-gdb.
[10:33:15] <Lambda_Aurigae> not sure how, however.
[10:33:43] <Lambda_Aurigae> never had a program I couldn't debug using old methods.
[10:46:34] <NicoHood> the first (promesing) arduino board that was NOT founded on kickstarter!? https://www.kickstarter.com/projects/663438947/mini-duino
[10:47:57] <Lambda_Aurigae> still don't see a need for it myself.
[11:25:47] <NicoHood> if i want to run an avr with crystal i need 2 caps. how big should they be? ive seen 22pf and 0,1uF
[11:31:47] <Lambda_Aurigae> 18 to 22 pf
[11:31:50] <Lambda_Aurigae> depending on the crystal.
[11:31:55] <Lambda_Aurigae> generally 22pf works well.
[11:40:42] <NicoHood> how are they labled?
[11:41:18] <Lambda_Aurigae> depends on the cap.
[11:41:23] <NicoHood> 22pf
[11:41:23] <Lambda_Aurigae> mine have a 22 on them.
[11:42:39] <NicoHood> mine too
[11:42:51] <NicoHood> at least i think its 22
[11:43:18] <NicoHood> it looks like in 10 years i cannot read the numbers anymore. they seem to disappear
[11:43:30] <Lambda_Aurigae> it happens.
[11:43:55] <NicoHood> so what do i need? 2x 22pf, 1 crystal, 1 RST pullup. anything else?
[11:44:02] <NicoHood> the atmega itself of course
[11:44:07] <Lambda_Aurigae> on solderless breadboard I've had crystals start oscillating without any caps on them...the breadboard actually provides quite a bit of capacitance.
[11:44:19] <Lambda_Aurigae> to make the chip run, that's all you need.
[11:44:54] <Lambda_Aurigae> really, you don't need the caps and crystal as AVRs are set default to 1MHz using the internal RC oscillator at 8MHz with the div/8 fuse programmed.
[11:45:28] <NicoHood> but i want to run at 20mhz later
[11:45:32] <Lambda_Aurigae> but to get the chip to run at a stable frequency for things like UART comms and such you need a crystal.
[11:45:50] <NicoHood> yep
[11:46:40] <Lambda_Aurigae> I have run them without the crystal and done autobaud adjustments with the internal RC oscillator and made them run more or less reliably.
[11:48:34] <NicoHood> at how much MHz?
[11:48:46] <Lambda_Aurigae> 8MHz +/- a few KHz
[11:55:22] <NicoHood> a 20mhz rated MCU, how much can i overclock this without any problems?
[11:56:47] <Lambda_Aurigae> I've overclocked the atmega1284p to 32MHz...but the ADC doesn't work for shit at that speed.
[11:57:00] <Lambda_Aurigae> 25MHz is ok and everything seems to work.
[11:59:48] <NicoHood> seems i should use usart with 250k at 20mhz without errors
[11:59:56] <NicoHood> however linux doesnt support that...
[12:00:11] <Lambda_Aurigae> nope.
[12:00:34] <NicoHood> what nope?
[12:00:48] <Lambda_Aurigae> nope, linux doesn't support it.
[12:01:00] <NicoHood> but why? serial is ages old
[12:01:16] <Lambda_Aurigae> and 2Mb/s connection is new..not supported by old..
[12:01:34] <Lambda_Aurigae> heck, the uart on a PC probably won't support more than 115K.
[12:01:42] <Lambda_Aurigae> but the avr can support up to 2Mb/s
[12:01:45] <NicoHood> i think ftdi chips can only handle 250k
[12:01:48] <Lambda_Aurigae> 250K is not a problem.
[12:02:07] <NicoHood> but ive got my own Serial-USB firmware that can handle 2M
[12:02:27] <Lambda_Aurigae> I do too...it runs on a pic32.
[12:03:29] <NicoHood> still wondering why this doesnt work after resets: http://www.avrfreaks.net/forum/soft-c-avrgcc-monitoring-stack-usage
[12:03:42] <NicoHood> the init1 and naked attribute seem to cause problems
[12:04:04] <NicoHood> if i call it manually in main() at the beginning the construct works fine
[12:05:44] <NicoHood> "For devices with > 64 KB of ROM, .init4 defines the code which takes care of copying the contents of .data from the flash to SRAM."
[12:05:53] <NicoHood> do they mean words or bytes?
[12:13:15] <Jartza> evening
[12:22:29] <NicoHood> if i want to tell an mcu to stop sending, should i pull down RTS or CTS?
[12:22:46] <NicoHood> i dont want to pull down the wrong line, thats confusing
[12:28:54] <rue_bed> RTS = request to send
[12:29:02] <rue_bed> CTS = clear to send
[12:29:10] <NicoHood> i pulled CTS down. however my ftdi chip still sends data to the serial HW
[12:29:15] <rue_bed> most microcontrollers dont implement either
[12:29:30] <NicoHood> i was thinking of implementing it
[12:29:38] <NicoHood> however then my usb-serial needs this too
[12:29:40] <rue_bed> you will not find (or, I couldn't) ANY timing diagrams for the handshaking signals
[12:30:08] <rue_bed> so, there's nothing saying if you finish the byte your transmitting or not
[12:30:18] <NicoHood> cant i just pull the line low to forbit sending?
[12:30:29] <rue_bed> hu?
[12:30:52] <NicoHood> if i pull CTS low i expect my ftdi to not tranmit data from the pc to the HW
[12:31:03] <NicoHood> but it still does, so it ignores the CTS signal
[12:31:05] <rue_bed> in theroy, the reciever changes the cts line to stop transmittion
[12:31:25] <rue_bed> it seems it usually depends on what the software on the other end is too
[12:31:25] <NicoHood> so my ftdi chip just gives a fuck about cts?
[12:31:50] <rue_bed> pretty sure its up to the software
[12:32:10] <rue_bed> esp for onboard uarts
[12:32:15] <rue_bed> windows or linux?
[12:32:27] <NicoHood> linux
[12:33:02] <rue_bed> hmm, I , no, depends on the software sending....
[12:33:16] <rue_bed> the software can turn off/ignore the handshaking
[12:34:08] <NicoHood> usb protocol only defines RTS and DTR
[12:34:10] <NicoHood> not cts
[12:38:27] <Lambda_Aurigae> most of your cheap usb-serial adapters don't even implement cts/rts/dtr lines.
[12:38:57] <Lambda_Aurigae> I have 5 commercial ones here...only 1 of them supports the hardware flow lines like that.
[12:40:03] <NicoHood> which one?
[12:40:09] <NicoHood> i guess its more expensive?
[12:40:17] <Lambda_Aurigae> the ftdi chips support it.
[12:40:23] <Lambda_Aurigae> it's just not implemented on most devices.
[12:40:42] <Lambda_Aurigae> the one I have that implements it was about 45 dollars and I bought it specifically because it did.
[12:41:47] <Lambda_Aurigae> there are cheaper ones out there now that do.
[13:06:12] <Jartza> yea, my FTDI cable supports CTS/RTS if I enable it from the PC side
[13:13:00] <rue_house> its got the signlas, dosn't mean anything happens with them
[13:14:31] <Lambda_Aurigae> yup...comms software at both ends has to implement them properly.
[13:21:31] <Jartza> then I have about 10 chinese crappy ftdi-ones, which probably are mostly clones
[13:21:36] <Jartza> none of them implement rts/cts
[16:08:37] <Jartza> well this is a bit weird
[16:09:14] <Jartza> if I ever reset my attiny85 with a watchdog (just enable watchdog and let it expire) it hangs in eternal loop
[16:09:29] <Jartza> and the funny thing is, it doesn't even wake up by reflashing
[16:09:36] <Jartza> it wakes up after flashing AND power-cycling
[16:09:44] <Jartza> but without power-cycle, it's doing Nothing.
[16:11:05] <cehteh> yes that could be expected
[16:12:10] <cehteh> watchdog doesnt get disabled on reset, if your watchdog is fast enough and you dont ping or turn it off at first on initialization it may go straight into a reset loop
[16:15:33] <Jartza> but it's the first thing I do at boot, disable watchdog
[16:15:50] <Jartza> also, even if I just reflash the chip with led blinker, it still doesn't start
[16:15:58] <Jartza> needs a power-cycle
[16:19:29] <Jartza> something strange there
[16:20:10] <Jartza> http://pastie.org/10652583
[16:20:20] <Jartza> and this is the first thing that gets ran after reset
[16:20:51] <Jartza> also tried without the WDIF-bit
[16:22:06] <Jartza> ...and tried adding wdr as a first instruction
[16:23:41] <Jartza> argh
[16:24:46] <Jartza> of course I need to _clear_ the WDRF bit, not set it
[16:25:01] <cehteh> haha :D
[16:25:16] <Jartza> some flags are cleared by writing 1 to the, but seems MCUSR bits are not like that
[16:25:18] <Jartza> d'oh
[16:25:42] <Lambda_Aurigae> oops.
[16:25:43] <Jartza> I just didn't know that even flashing the chip doesn't disable watchdog
[16:25:49] <Jartza> that was new to me
[16:27:08] <cehteh> persistent dog :)
[16:27:17] <Jartza> it is
[16:27:36] <Jartza> if software doesn't disable it correctly, it stays on even after reset AND chip reflash
[16:27:55] <Jartza> checked with saleae, the chip actually tried to flash led, but it was just so brief that I didn't see it :D
[16:28:01] <Jartza> the led stayed on for like 3 clock cycles
[16:28:01] <cehteh> be lucky that it didnt trigger *while* flashing .. that would be major pita
[16:28:03] <Jartza> @20MHz
[16:28:25] <Jartza> cehteh: heh, that would actually count as a major design flaw in my opinion :D
[16:28:51] <Jartza> but yea. I just wanted to implement "full reset"-escape command to my VGA to
[16:28:52] <cehteh> and dont forget you can force on the watchdog with a fuse too
[16:29:08] <Jartza> of course yeah, but that would not work for me :)
[16:29:58] <cehteh> in another project i used the watchdog osc as clock source and watchdog interrupt as timer
[16:30:15] <cehteh> want low power .. there we are
[16:30:50] <Jartza> yep
[16:31:10] <Jartza> my Tagsu uses watchdog + sleep a lot
[16:31:20] <Jartza> basically ~97% of the time the CPU is in sleep
[16:31:24] <Jartza> or more
[17:01:28] <FelixVi> hi, is anybody familiar with jtag programming of an atmega644?
[17:15:37] <ferdna> FelixVi, what is the problem?
[17:22:11] <FelixVi> ferdna: I can read IDCODE but don't seem to get into programming mode
[17:22:27] <FelixVi> ferdna: I bitbang JTAG with an arduino
[17:22:52] <FelixVi> FelixVi: Can you get to JTD in MCUCSR somehow?
[17:23:07] <ferdna> its better if you ask your problem instead... of asking if someone uses jtag with atmega644
[17:23:41] <FelixVi> yeah, but people who know jtag programming of avrs most likely know
[17:28:21] <FelixVi> ferdna: so you don't happen to know?
[17:28:30] <ferdna> i dont
[17:28:38] <ferdna> but someone here must know
[17:40:10] <FelixVi> ferdna: thx! I hope somebody had similar issues before
[18:57:37] <FelixVi> I am bitbanging jtag from an avr, but can't seem to get into programming mode - reading IDCODE and boundary scans work fine, but I can't get into programming mode. Does anybody know anything about this?
[18:58:49] <theBear> if boundary scans and stuff work, i'd say the thing you are trying to get into programming mode is much more relevant than what you using for the jtag/adapter
[18:59:33] <theBear> unless you mean yer not using it as just an adapter i spose
[19:00:35] <theBear> either way, i think yer should ask harder not just more
[19:02:55] <FelixVi> I reset the TAP, then write 0xC to the IR register, then 0x1 in the data register, then 0x4 in IR, 0xa370 in data, 5 in IR, 0x2308 in data, go to run-test/idle, write 0x0300 in data, 0x3200 in data and finally 0x3300 in data - what I read back is 0x1b but not the signature byte (address 0x00)
[19:03:24] <FelixVi> according to the datasheet, I should read the low byte of the signature
[19:03:41] <FelixVi> ISP can read it correctly, but I don't get it read correctly
[19:04:32] <FelixVi> theBear: any idea what the problem might be?
[19:05:12] <theBear> nah, i never had a avr fancy enuf to jtag, or if i have i didn't know it
[19:05:58] <FelixVi> hehe, that's why I was asking about jtag first
[19:06:08] <FelixVi> looks like nobody here ever used jtag
[19:06:44] <theBear> i can't remember a "programming mode" in jtag world, figured that was an avr specific thing
[19:06:59] <FelixVi> yeah
[19:07:15] <FelixVi> they keep em locked so that people don't reprogram by accident
[19:07:33] <FelixVi> I'm sure the problem is really simple - I just can't seem to see it
[19:08:03] <theBear> mm