#avr | Logs for 2015-09-11

Back
[01:33:16] <O0ddity> Does AVR not have native Modulo operator?
[03:23:48] <Xark> O0ddity: Nope, nor a divide.
[03:56:41] <Jartza> and tiny doesn't even have multiply
[03:57:36] <Xark> Right (and a few other ops, IIRC).
[07:26:28] <Martin90> hmm writting value to timer counter is valid right ? Like i.e TCNT2 = 0;
[07:32:39] <Martin90> so basically is it possible to change timer counter from program ?
[07:41:15] <kraiskil> yes
[07:44:20] <Martin90> thanks
[07:44:36] <Martin90> anyway is there timer hierarchy
[07:44:49] <Martin90> like timer 0 interrupt is above timer 2 inter.. ??
[07:45:59] <Tom_itx> look at the interrupt table
[07:46:52] <LeoNerd> The interrupt list tends to vary between devices
[07:47:25] <Martin90> but changing timer counter like TCR0 = 255 is valid for all ?
[07:48:14] <Tom_itx> some timers are 16bit
[07:48:18] <Tom_itx> some are 8
[07:48:35] <Martin90> I know
[07:49:00] <Tom_itx> 255 would be valid for all i know of
[07:49:20] <Martin90> ;p
[07:49:24] <LeoNerd> timer0 is usually an 8bit timer
[07:49:33] <LeoNerd> In fact I don't know of an AVR device in which timer0 is a 16bit timer
[07:50:31] <Tom_itx> tiny 10
[07:50:33] <Tom_itx> is one
[07:59:56] <Martin90> where do you see that interrupt hierarchy table for atmega16a ?
[08:00:03] <Martin90> Table 11-1. Reset and Interrupt Vectors ?
[08:00:06] <LeoNerd> In the datasheet I would imagine
[08:01:07] <Tom_itx> or look at the device header file
[08:01:18] <Tom_itx> data sheet would be your best bet
[08:01:37] <Martin90> LeoNard, I would never have guessed
[08:01:39] <Martin90> ;)
[08:02:04] <Martin90> there is no table labeled as hierarchy
[08:02:19] <Martin90> so I guess ut will be the first table in interrupts chapter
[08:02:32] <Martin90> which shows "Reset and Interrupt Vectors"
[13:12:11] <O0ddity> can anyone tell me why this isnt working?
[13:12:12] <O0ddity> https://gist.github.com/anonymous/e222555ad4b7473399b5
[13:13:16] <O0ddity> Line 55 in the ISR, if uncommented, creates the correct behaviour
[13:13:23] <learath> do you need to kick off the timers?
[13:13:59] <O0ddity> line 34, does that does it not?
[13:14:33] <learath> it says "enable overflow interrupt"....
[13:14:42] <learath> I really have no particular deep knowledge of this code
[13:14:48] <learath> or what it's running on
[13:15:17] <learath> I just recall having to kick off a timer before it would run
[13:17:11] <O0ddity> On line 55 if uncommented, it toggles the ports. And that inside the timer overflow interrupt. So the timer is running
[13:19:20] <O0ddity> When i looked at the generated binary in IDA, it looks like the "if" on line 44, when false, ends up on a reletive jump to itself.
[13:37:52] <O0ddity> ...
[13:39:28] <O0ddity> I don't think i can trust this compiler
[13:40:59] <O0ddity> This is stille not working: https://gist.github.com/anonymous/e222555ad4b7473399b5
[13:41:31] <O0ddity> This (now with body of while loop in a function) works: https://gist.github.com/anonymous/96b75aba39286bc9a175
[13:42:50] <O0ddity> GG GCC optimiser... GG
[13:43:15] <gorroth> did you use -Os ?
[13:43:57] <O0ddity> yes...?
[13:44:16] <O0ddity> apparently
[13:45:10] <gorroth> hmm
[13:45:25] <gorroth> well, what if you do -O0 (i think that disables the optimizer)
[13:47:01] <O0ddity> Once I'm finished banging my head agianst the wall
[13:48:29] <O0ddity> Hey, magic!
[13:48:50] <O0ddity> gorroth: Are you a magician?
[13:49:06] <gorroth> lol
[13:49:29] <gorroth> so you probably did find a bug in the optimizer if that worked
[13:53:48] <O0ddity> It hurt
[14:01:28] <jacekowski> actually, it is a known behaviour
[14:01:34] <jacekowski> and is to be expected
[14:01:39] <jacekowski> because you are only writing and not reading
[14:01:46] <jacekowski> to that variable in the interrupt
[14:01:51] <jacekowski> so the whole thing is optimised out
[14:02:10] <jacekowski> add a volatile keyword to the declaration
[14:02:12] <jacekowski> and it should work
[14:21:04] <gorroth> oh
[14:21:09] <gorroth> yeah, you need to use volatile for that stuff
[14:21:13] <gorroth> i didn't read closely enough what you were doing
[14:49:22] <Jartza> evening
[16:36:47] <Darkwell> anyone know a small formfactor programmer for attiny that could both upload bootloader and programs?
[16:37:50] <Darkwell> need to be able to run it from Linux raspberry pi so usb should be ok
[16:40:13] <Lambda_Aurigae> Tom_itx makes one.
[16:40:31] <Lambda_Aurigae> although I hate to say it, any of the v-usb based usbasp type programmers will do it.
[16:40:40] <Darkwell> ive found this one but not sure about bootloaders uploads https://www.sparkfun.com/products/11801
[16:40:46] <Lambda_Aurigae> although the last v-usb thingie I tried on a rPI didn't work so well.
[16:40:52] <Lambda_Aurigae> a bootloader is just a program
[16:41:00] <Lambda_Aurigae> nothing special about it except where it resides in the memory.
[16:41:01] <Darkwell> hmm
[16:42:10] <Lambda_Aurigae> now, you do have to set some fuses to configure bootloader mode.
[16:42:37] <Lambda_Aurigae> those fuses are all dependent on the size of your bootloader and where it starts in memory and whether it needs the interrupt vectors moved and such.
[16:43:50] <Darkwell> so if I purchase chips w/o bootloaders it will work just to upload programs anyways w attiny85? w the atmega 328 I recall different wiring depend on the way to go bootloader/program
[16:50:03] <Lambda_Aurigae> all depends on the bootloader
[16:50:25] <Lambda_Aurigae> I have some that go into bootloader mode no matter what, wait 5 seconds, then boot normally if no bootload data.
[16:50:38] <Lambda_Aurigae> others I have that require a certain line be held high or low to start bootloader.
[17:01:04] <Darkwell> hmm
[17:02:38] <Darkwell> just want to make sure I can upload a working bootloader if I purchase chips that doesn't want to get programmed directly
[17:03:36] <Darkwell> at least w the atmega328 it has happened to me that there were no bootloader or it was fault somehow
[17:05:27] <Lambda_Aurigae> atmega328 does not come with bootloader
[17:05:42] <Lambda_Aurigae> only AVRs that come with bootloader from the factory are the ones with hardware USB...and atxmega maybe.
[17:05:55] <Lambda_Aurigae> so, like the atmega32u2 and similar.
[17:06:56] <Lambda_Aurigae> uploading a bootloader is just like uploading any other program...you have a .hex file and send it to the chip with the ISP programmer.
[17:07:10] <Darkwell> Ok. .
[17:07:12] <Lambda_Aurigae> the .hex file has entries on each line that tell where the data is to be written to the chip.
[17:07:29] <Lambda_Aurigae> once it's loaded then you have to make sure the fuses are set correctly for that particular bootloader.
[17:07:45] <Lambda_Aurigae> your isp programmer should be able to be used for setting fuses as well.
[17:07:57] <Darkwell> ok
[17:08:37] <Lambda_Aurigae> you just can't set fuses from within a bootloader..you have to have an external programmer like an ISP, HVSP, HVPP, JTAG, PDI, or TPI programmer...depending on the programming interface(s) on your chip.
[17:10:10] <Lambda_Aurigae> most chips have 2 external programming interfaces....some have 3.
[17:10:28] <Lambda_Aurigae> oh, I forgot DW in that list.
[17:10:37] <Lambda_Aurigae> not sure if you can do programming with DW though...never used it.
[17:15:53] <Darkwell> my idea is to use an attiny85 hook it to a ds8b20 temp sensor... but does the sensor give stable values or would it be good to have a kalman filer ?
[17:17:53] <Darkwell> ds18b20
[18:10:16] <Jordan_U> How can I determine the maximum time that might be taken by eeprom_write_dword() (if eeprom_is_ready() returns true)? I have a watchdog timer configured to trigger after 15ms, and it seems like eeprom_write_dword() takes pretty close to that long. I can currently run eeprom_write_dword if I call wdt_reset() immediately before and after it, but I want to be sure that a change in temperature, voltage, or other factor wouldn't ...
[18:10:22] <Jordan_U> ... cause the watchdog to still be triggered (which would be wrong in this circumstance).
[18:10:47] <Jordan_U> This is an ATMega64M1.
[18:10:49] <Lambda_Aurigae> turn off the watchdog while doing eeprom writes.
[18:13:49] <Jordan_U> I guess I could do that, but I would rather not.