#avr | Logs for 2014-01-22

Back
[01:40:25] <rigid> hm ok, after some experimenting it seems i'm quite out of luck with the tiny11.
[01:41:08] <rigid> I can't checksum the RAM since it doesn't have RAM :-P ... also I can't sample floating inputs, since there are internal pull-ups. Those can only be disabled on tiny12.
[01:41:31] <rigid> Also the startup/timer is quite deterministic.
[02:41:04] <rigid> ah what the heck, i'll add a button :)
[02:48:36] <tzanger> tiny11 has no RAM? *coughbullshitcough*
[02:49:24] <moemoe> tzanger: yes, and only 1000 write/erase cycles on flash.
[02:50:04] <moemoe> 32 registers should be enough for anybody ^^
[03:10:42] <blathijs> tzanger: It actually seems to be true: http://www.atmel.com/Images/1006s.pdf
[03:15:39] <moemoe> of course it's true. but it's always others who are telling bullshit ;)
[03:15:52] <tzanger> interesting
[03:15:52] <tzanger> ok
[03:16:20] <tzanger> well then use some assembler right in crt0 to sum all the registers into one and use that... maybe you'll get lucky and a reset won't zero them all
[05:08:13] <Fleck> atmega2560, where's the problem, interrupt is never called: http://paste.opensuse.org/99490354
[05:08:52] <Fleck> 2560 runas at 16MHz, interrupt at around 37Hz
[05:09:59] <Fleck> sorry, at ~1KHz
[05:10:29] <Fleck> OC1A pin looks like this: http://im9.eu/picture/rw2541
[05:11:39] <Fleck> PortL Pin0 is never toggled!
[05:15:11] <Fleck> Atmel Studio 6.1, latest update
[05:48:06] <antto> Fleck is that about my timer troubles?
[05:48:17] <Fleck> yep
[05:48:36] <Fleck> morning antto! :D
[05:49:11] <antto> so what does all that mean?
[05:49:45] <Thrashbarg> Fleck: I've been going over the code and the datasheet for about ten minutes now and I'm not seeing anything wrong...
[05:50:02] <Thrashbarg> not that I've used the 2560 myself
[05:50:05] <Fleck> Thrashbarg: thank you for your time! :)
[05:50:21] <Thrashbarg> Fleck: well I saw it and it stumped me so I *had* to figure it out haha
[05:50:32] <Fleck> :P
[05:50:41] <Thrashbarg> the only thing I can think of is if you try CTC mode instead of PWM
[05:50:54] <Thrashbarg> so WGM[3..0] = 0100
[05:51:04] <Fleck> tried that
[05:51:07] <Fleck> did not help!
[05:51:11] <Thrashbarg> yea I thought as much
[05:51:12] <antto> i _am_ using CTC mode
[05:51:14] <Thrashbarg> very very weird
[05:51:17] <antto> yet, doesn't tick
[05:51:49] <Fleck> Ill try manually enable global interrupts, maybe something wrong with sei(), have you tried that antto?
[05:52:21] <antto> Fleck if i didn't have sei() - my other timer (timer0 running at 1kHz) wouldn't be ticking
[05:52:34] <antto> right?
[05:52:36] <Thrashbarg> what compiler and version?
[05:52:37] <Fleck> ohh, right!
[05:53:10] <antto> the other timer certainly ticks, i just wanted to move some of the code from that timer into a more dense timer
[05:53:22] <antto> so i haven't touched any other code, everything is the same
[05:53:56] <antto> Thrashbarg avr-gcc (WinAVR 20100110) 4.3.3
[05:54:05] <Thrashbarg> righto hmm
[05:59:23] <Thrashbarg> antto: the only thing I can think of now is if you change TIMSK1 |= (1<<OCIE1A); to TIMSK1 = (1<<OCIE1A);
[05:59:34] <Thrashbarg> shouldn't do anything really...
[05:59:55] <Fleck> tried that :) not helping!
[06:00:23] <Thrashbarg> gah
[06:01:48] <antto> tried it, doesn't tick
[06:06:40] <Thrashbarg> at this point I'd be running avr-objdump -d to check the assembly output
[06:07:06] <antto> i don't understand ASM..
[06:07:49] <Thrashbarg> could you dump the output of it and paste it to that site?
[06:07:56] <Thrashbarg> this is driving me nuts ;)
[06:08:10] <antto> the firmware is kinda big
[06:08:17] <antto> ~38kB
[06:08:35] <Thrashbarg> you should just be able to dump the .out file which contains the minimum
[06:09:11] <antto> i don't think .out files are being generated
[06:09:36] <antto> i'm building with a makefile which i don't understand either ;]
[06:10:25] <antto> i *do* have many .o files
[06:10:55] <Thrashbarg> ok sure objdump -d one of them
[06:11:10] <Thrashbarg> ideally the one which corresponds to the .c file containing main()
[06:12:24] <antto> that filled the console with sh*t O_o
[06:12:29] <Thrashbarg> lol
[06:12:44] <Thrashbarg> put '> dump.txt' on the end of it
[06:12:45] <antto> i don't see any file created
[06:12:52] <Thrashbarg> yea it dumps it to the console
[06:13:03] <Thrashbarg> that > thing redirects that output to dump.txt
[06:13:21] <Thrashbarg> it'll be quite a bit of text
[06:13:30] <antto> okay, that works
[06:13:37] <antto> the file is ~126kB
[06:13:45] <Thrashbarg> wow
[06:13:59] <antto> yes, there's plenty of sh*t going on ;]
[06:14:32] <Thrashbarg> is the whole project just that one file with the short main() thing here? -> http://paste.opensuse.org/99490354
[06:14:41] <antto> i can see in there the functions.. init_timer0, init_timer3 ...
[06:14:42] <Thrashbarg> or are there other files
[06:15:09] <antto> oh no, that paste is from Fleck
[06:15:13] <Thrashbarg> ah right
[06:15:20] <Fleck> m?
[06:15:27] <antto> this here is a big fat project with a bunch of .c and .h files
[06:15:41] <Fleck> ohh, sec Thrashbarg
[06:15:53] <Thrashbarg> what happens if you make a new project with just that example, compile it and dump it
[06:16:01] <Thrashbarg> and even try it on the ATmega
[06:16:22] <Thrashbarg> because if it works fine, it's something else in your code
[06:16:26] <antto> i don't even know how to start a new project myself
[06:16:37] <Fleck> http://paste.opensuse.org/17637455
[06:16:50] <Thrashbarg> ah
[06:16:57] <Thrashbarg> Fleck: and that doesn't work on an ATmega2560?
[06:17:09] <Fleck> yep
[06:17:25] <Fleck> interrupt is not called
[06:18:41] <antto> http://pastebin.com/iYMcwB9Z <- that's the first ~5000 lines from the dump
[06:19:12] <antto> init_timer3 is what i've been trying to put together, but it doesn't tick
[06:19:30] <Thrashbarg> antto: Fleck's paste is more helpful... we know it doesn't work on his hardware so I'll see if there's a problem with the assembler
[06:19:41] <Thrashbarg> failing that I have *no* idea why it wouldn't work
[06:20:39] <antto> i always assume it's my dumb code, and the fact that i know nearly nothing about avr and microcontrollers in general
[06:21:19] <Fleck> I have used interrupts on attiny13, w/o problems
[06:21:23] <antto> but from what i learnt about this timer - i can't see what am i missing, i stared at the datasheet, everything should be properly initialized - yet, nothing
[06:26:25] <Thrashbarg> well the disassembly looks fine in my opinion
[06:26:39] <Thrashbarg> it's storing the correct values to the correct memory locations
[06:26:59] <Thrashbarg> the only other thing I can think of is there's a bug in the hardware
[06:27:08] <antto> i didn't even thought about ASM.. i mean.. i know the C code, it should just work, right?
[06:27:19] <Thrashbarg> yes, theoretically :P
[06:27:24] <antto> or can the compiler generate *different* code O_o
[06:27:35] <Thrashbarg> yup a lot of it gets optimised out
[06:28:10] <Thrashbarg> PRR0 = (0<<PRTIM1); <-- for example. You're writing 0 to a location known to already contain 0, so it gets optimised out
[06:28:49] <antto> yeah, optimized-out is something i know about
[06:29:40] <antto> var = var; // probably will be thrown out
[06:29:52] <Thrashbarg> yea
[06:30:23] <antto> but the stuff in my init_timer3() doesn't contain such silly stuff, methinks
[06:30:51] <Thrashbarg> at a higher level of optimisation, var0 = 0; var1 = var0+1; if (var1>var0) would be optimised out to always execute the if statement
[06:31:46] <antto> you mean the if statement will be removed?
[06:32:10] <Thrashbarg> yeah because it already knows var1 will always be greater than var0
[06:32:13] <antto> and the code for when it's "true" will be slapped right on
[06:32:21] <antto> yeah, that makes sense
[06:32:42] <antto> and i'd use volatile in such case (if i want the compiler to watch it)
[06:32:46] <Thrashbarg> yup
[06:35:25] <Thrashbarg> well I'm stumped and it's 10:48pm so I'm giving up heh
[06:36:26] <antto> yeah.. i guess i can only try something stupid now, like using timer1 instead of 3, and recompile
[06:36:44] <antto> but somehow, i don't think it's gonna magically work then
[06:36:54] <antto> hope dies last tho ;]
[06:38:02] <Fleck> antto: I'm using timer1, no luck! :D
[06:38:16] <Fleck> Thrashbarg: thank you! Bye!
[06:38:19] <antto> ah, right
[06:38:22] <Thrashbarg> np g'night
[06:38:23] <antto> :/
[06:38:30] <antto> avr: y u no tick?
[06:40:26] <antto> well, what alternative way is there, to execute some chunk of code at a regular interval?
[06:48:57] <Fleck> antto: found it! :)
[06:49:07] <antto> oh?!
[06:49:12] <Fleck> BOOTRST fuse :D
[06:49:17] <antto> oh no
[06:49:25] <antto> what about it? :/
[06:49:49] <Fleck> check datasheet around page 109
[06:50:29] <Fleck> http://im9.eu/picture/xd2541 << nice toggle going on on PortL Pin0
[06:50:55] <antto> there's ASM code there
[06:51:06] <antto> i can't change the fuse settings, it's too late for that
[06:51:09] <antto> :/
[06:51:12] <Fleck> yeah but some txt in the middle :)
[06:51:21] <Fleck> why not?
[06:51:54] <Fleck> anyway, then you need to calc correct vector value afaik
[06:51:57] <antto> because this device is already out and into the hands of normal users
[06:52:13] <Fleck> out of what?
[06:53:01] <antto> "out" as in "released" and sold to users
[06:53:31] <antto> the fuse settings have been pre-flashed and were supposed to be ideal, as well as the bootloader
[06:54:01] <Fleck> paste timer0 vector please
[06:54:34] <antto> from the main.o dump?
[06:54:40] <Fleck> no, .c
[06:55:33] <antto> SIGNAL(SIG_OUTPUT_COMPARE0A)
[06:55:35] <Fleck> anyway - I don't understand how that's a problem, connect ISP and rewrite fuses... :D :D
[06:56:28] <antto> normal users of this device are far from knowing anything about ISP, fuses, and avr
[06:56:36] <antto> they press buttons and look at shiny leds ;]
[06:56:37] <Fleck> sure
[06:56:57] <Fleck> 14.3 Moving Interrupts Between Application and Boot Section
[06:57:01] <antto> so, what should be changed in the settings?
[06:57:21] <antto> uh, the interrupt vector.. i am changing it in the bootloader btw
[06:57:29] <antto> the bootloader uses interrupts
[06:57:48] <antto> but then, it is moved back for the firmware to also use interrupts
[06:58:52] <Fleck> well, now you know where to dig! :)
[07:00:49] <antto> Fleck http://pastebin.com/dnKaiJeF
[07:00:52] <antto> this is from the bootloader
[07:01:49] <Fleck> ok Ill try that
[07:02:51] <antto> the bootloader itself sets these at the top of main() to: MCUCR = (1<<IVCE); MCUCR = (1<<IVSEL);
[07:03:28] <antto> and then, after programming the firmware, the function i pasted is called to jump to the firmware
[07:04:00] <antto> i've reflashed the firmware via this bootloader probably hundreds of times, interrupts have been working both in the bootloader and in the firmware
[07:04:41] <Fleck> When the IVSEL bit in MCUCR is set, Interrupt Vectors will be moved to the start of the Boot
[07:04:41] <Fleck> Flash Section. The address of each Interrupt Vector will then be the address in this table
[07:04:42] <Fleck> added to the start address of the Boot Flash Section.
[07:07:16] <antto> but.. would timer0 work and timer3 not?
[07:11:00] <Fleck> antto: how big is your bootloader section?
[07:11:29] <antto> 8kB
[07:21:35] <antto> Fleck so did you manage to make your timer1 tick?
[07:21:55] <Fleck> timer yes, vector function - no
[07:22:13] <antto> vector _function_ ?
[07:22:36] <antto> is that the interrupt { ... } ?
[07:23:06] <Fleck> yes
[07:42:05] <Tom_itx> what interrupt?
[07:42:14] <Tom_itx> are you naming them properly?
[07:42:28] <Tom_itx> #define INT3_vect
[07:43:54] <Fleck> Tom_itx: sure
[07:44:04] <Tom_itx> what timer interrupt?
[07:44:16] <Fleck> TIMER1_COMPA_vect
[07:45:10] <Tom_itx> is that the right one for what you're doing?
[07:45:19] <Fleck> http://paste.opensuse.org/99490354 << COMPA never called, but, when I set BOOTRST to 1, working oK!
[07:45:52] <Fleck> 1 as unprogrammed
[07:46:46] <Tom_itx> TIMER1_CAPT_vect TIMER1_COMPA_vect TIMER1_COMPB_vect TIMER1_OVF_vect
[07:47:14] <Fleck> line 4 - ISR(TIMER1_COMPA_vect) {
[07:47:19] <Tom_itx> well that changes where it looks for code
[07:47:27] <Tom_itx> i didn't click
[07:48:16] <Fleck> ur bad! :D
[07:49:48] <Fleck> Tom_itx: yes, we figured that, so where to look if that fuse is programmed?
[07:49:56] <Fleck> as antto can't change it
[07:50:04] <Tom_itx> look at the memory map
[07:50:10] <Fleck> I did
[07:50:21] <Tom_itx> P.105 & P.335
[07:50:51] <Fleck> yep, tried different values, no luck! :D
[07:53:15] <Fleck> Tom_itx: maybe I need to provide AtmelStudio with flash segment etc?
[07:53:39] <Tom_itx> it should know based on io.h
[07:54:20] <Tom_itx> you can check to make sure it's right
[07:54:45] <Tom_itx> starting around P21
[07:55:19] <Fleck> well size differs when BOOTSZ1 is changed
[07:55:38] <Tom_itx> well sure it does
[07:55:39] <Fleck> but AtmelStudio has no clue what fuses are set and what not
[07:56:41] <Tom_itx> somehow you would include that in the makefile
[07:56:52] <Tom_itx> i haven't gotten into bootloader alot
[07:58:29] <antto> if it helps, the bootloader code is here: http://antonsavov.net/cms/wolf/plugins/counter/sub/download.php?id=7
[07:58:45] <Tom_itx> it has a clue if it reads the chip fuses before programming
[07:59:17] <Fleck> Tom_itx: it doesn't I programm with external app
[07:59:17] <Tom_itx> i don't know the in's and out's of studio
[07:59:40] <antto> but basically, when i added interrupts to the bootloader - i had to "change" the vector thing in order for them to actually work, and then i had to also set them back, for the firmware to work too
[08:09:58] <Fleck> now if I have no bootloader, BOOTRST can be 0 or 1, working ok anyway
[08:11:10] <Fleck> and I never had vector function in bootloader
[08:12:04] <Fleck> so I need IVSEL 0
[08:16:24] <Fleck> meh, I have no clue
[08:20:13] <Fleck> Tom_itx: does BOOTRST fuse moves all vectors from FLASH to BOOT section?
[08:20:52] <antto> Fleck, if i understand the question, using a bootloader doesn't automatically move the interrupts to the bootloader
[08:21:23] <antto> this bootloader didn't use any interrupts at first (before i poked my hands in it) and the firmware just worked fine
[08:21:28] <Tom_itx> i haven't messed with bootloaders enough to give you an educated answer
[08:22:01] <Tom_itx> i've had to move them on other platforms before though
[08:22:07] <antto> and there was no need to be touching the MCUCR in neither the bootloader nor the firmware
[08:22:10] <Fleck> antto: well, I have set boot section to 8KB, when BOOTRST fuse is set, TIMER1_COMPA_vect is not working, when not set - it's working!
[08:22:44] <Fleck> it's like all vectors then are in flash section
[08:23:04] <antto> don't you have to have an actual bootloader at (flash_size - 8kB) ?
[08:23:27] <antto> is it actually executing the firmware?
[08:23:32] <Fleck> I don't have anything there, just empty space
[08:24:05] <antto> okay let me get this a bit more clear..
[08:24:42] <antto> if the vector table, or however it's called.. if it's "moved" to the bootloader section - will *any* interrupt be working in the firmware at all?
[08:24:49] <Fleck> hmm, wait, maybe there was a arduino bootloader, sec
[08:26:40] <Fleck> nope, nothing there!
[08:31:31] <Fleck> antto: maybe not
[08:32:01] <Fleck> you can decide with IVSEL, where to use them I guess
[08:32:07] <antto> i can tell you..
[08:32:14] <Fleck> but as Tom, I am not sure
[08:32:41] <antto> at first, we had firmware and stk500v2 bootloader, the firmware used interrupts, the bootloader didn't
[08:32:59] <antto> there was not a single line of code that touched the MCUCR register, anywhere
[08:33:28] <antto> then, i wanted to pimp up the bootloader, and i wanted to use interrupts there, and that's where i learned about MCUCR
[08:33:40] <Fleck> :D
[08:34:00] <antto> so i managed to move the interrupts to work while in the bootloader, but then they didn't work in the firmware
[08:34:08] <antto> so i learned that i have to also set them back
[08:34:19] <antto> and at the end, i got them working in both places
[08:34:35] <antto> and now, i wanted to set up timer3 in the firmware - it doesn't work
[08:34:39] <Fleck> ok then, COMPA for timer 3 should work ok for you
[08:35:08] <antto> the firmware already uses timer0 with interrupt, that *works*
[08:35:45] <antto> so, as far as my understanding goes, i don't think it's MCUCR's issue
[08:35:51] <Fleck> is it defined only in flash or in booloader too?
[08:36:04] <antto> because, i would think that then timer0 won't be firing interrupts as well, but it does
[08:36:24] <antto> Fleck defined - what?
[08:49:41] <Zad0k> Hello
[08:50:02] <Zad0k> How can I retrieve/see the content of the EEPROM of an attiny85 with avrdude?
[09:00:31] <rue_house> use avrdude
[09:00:37] <rue_house> you can upload it as a .hex
[09:01:41] <antto> Fleck if i get the question right.. the firmware doesn't rely on any code from the bootloader, and the bootloader doesn't rely on any code from the firmware (it only erases and overwrites the firmware)
[09:02:43] <amee2k> i think he meant downloading it from the MCU to the computer
[09:03:28] <blathijs> Zad0k: Did you check the avrdude manpage? The magic is in the -U option.
[09:08:17] <rue_house> I think I have a tutorial
[09:09:11] <rue_house> http://eds.dyndns.org/~ircjunk/tutorials/prog/avrbf/main.html
[09:09:22] <rue_house> that has how to overwrite the eeprom
[09:56:02] <Fleck> antto: ok
[10:50:33] <aksnot> hello guys new to mc programming ..... here is this code correct http://fpaste.org/70705/08392139/ i am trying to make each pin on port c high.Thanks in advace.
[10:57:39] <Fleck> so antto, still nothing? :)
[11:41:40] <antto> Fleck nope
[11:50:25] <antto> the bootloader itself doesn't use any timers
[11:50:37] <antto> it uses only SIG_USART0_RECV
[11:52:00] <antto> could the initialization of some pin/port be related to this timer issue?
[12:00:17] <Fleck> antto: well, test with led, use same COM3A0 and A1 as I used, and you will know, is it vector or timer
[12:03:04] <Fleck> OC3A needs to be set as output...
[12:21:44] <Fleck> set a good/slow prescaler so that you see led blink
[13:59:18] <Timmy> is there any library available for dot matrix characters?
[15:20:01] <Fleck> so, anyone here who used bootloader and interrupt vector functions?
[15:48:34] <antto> except me?
[17:10:07] <rigid> a 3 level stack really is limiting :)