#avr | Logs for 2013-04-30

Back
[02:02:57] <holo> hi, I'm a newbie. I'd like to create soft pwm. So having an ISR which counts me a coutner variable on each timer step. But how do I get an interupt each timer step?
[02:06:05] <Xark> holo: Here, try the Newbie's Guide to AVR Timers -> http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=50106
[02:08:26] <holo> Xark thx
[02:09:01] <Xark> holo: No problem. Should have the code snippets you need. :)
[02:09:54] <holo> Xark I'll read it, thanks. =)
[05:50:03] <Valen> so I am seeing some odd behaviour in an attiny84A
[05:50:08] <Valen> this is the code http://pastebin.com/0XzyEDmZ
[05:50:36] <Valen> when I enable the timer0 PWM output (setting wgm bits) the timer 1 overflow seems to run all the time
[05:51:37] <Valen> IE timer0 off i get around a 1Hz flashing
[05:51:50] <Valen> with timer0 on flashing is random and about 10hz
[05:52:24] <Valen> I just noticed I'm setting ICIE1 in timer1 think that would do something?
[06:43:34] <skroon> hi all
[06:43:44] <Horologium> hello skroon
[06:45:01] <skroon> would I be able to just include the arduino lib's into my avr project?
[06:45:24] <Horologium> if you have to ask, probably not.
[06:45:43] <Horologium> although, why you would want to I have no clue, but it is possible.
[06:46:41] <Tom_itx> have a go and let us know how it went
[06:47:19] <Horologium> you should ask arduino questions in an arduino channel I would think.
[06:47:53] <Tom_itx> equal rights
[06:47:59] <Tom_itx> they sorta are avr too
[06:48:10] <Tom_itx> like a step child
[06:48:12] <Horologium> basic stamp is sorta pic too.
[06:48:32] <Tom_itx> i bet they get asked alot too
[06:48:45] <Horologium> actually, the pic channel is very quiet here.
[06:49:07] <Tom_itx> they got nothing to talk about
[07:01:21] <skroon> Horologium: well there are lot's of arduino libraries in existence that would be nice for reuse purposes
[07:15:12] <RikusW> http://www.buybuyfast.com/epm240-altera-max-ii-cpld-development-board_p920.html
[08:12:07] <tzanger> it certainly is cheap
[08:12:12] <tzanger> but MAXII isn't much to work in
[08:13:56] <tzanger> http://www.digikey.com/product-search/en?mpart=P0082&vendor=771 that's a much better board, mind you more expensive too
[08:49:30] <RikusW> anyone know where to get specs like say IEEE 1532 ?
[08:56:16] <tzanger> RikusW: web searching on sites that are questionable. sometimes you get lucky with usenet or torrents too
[08:56:21] <tzanger> what's 1532?
[08:56:36] <tzanger> looks like jtag?
[08:56:50] <tzanger> yeah boundary scan
[09:01:03] <tzanger> I didn't find the spec but I found an itneresting pdf: http://eprint.iacr.org/2012/296.pdf
[09:30:07] <twnqx> tzanger: so that's xilinx and actel now
[09:30:16] <twnqx> how about altera? :P
[09:31:12] <twnqx> hm, they say atmels are crackable within minutes
[09:31:15] <tzanger> don't know... I don't have anything needing that grade of protection
[09:31:29] <tzanger> yes, pic,avr/mega,msp430.. trivial
[09:31:29] <twnqx> really have to look into SCA
[09:31:45] <twnqx> all with SCA?
[09:31:46] <tzanger> I'm trying to find real examples of modern PICs being cracked
[09:31:51] <tzanger> yes apparently
[09:32:13] * twnqx puts another item on the todo list once this $§")"(§ here is done
[09:40:23] <tzanger> twnqx: http://www.dspcrack.com/Chip/
[09:43:02] <tzanger> twnqx: http://www.lorentzcenter.nl/lc/web/2010/383/presentations/Skorobogatov.pdf
[09:47:36] <RikusW> tzanger: extension of 1149
[09:47:41] <RikusW> bsdl
[10:03:01] <ptrkOP> Has anyone used Adafruits USBTiny AVR programmer?
[10:03:12] <ptrkOP> I am wondering if it works well
[10:03:28] <Kev-> It should work just fine
[10:03:43] <Kev-> I have a $4 programmer from ebay.com and it works great with avrdude :)
[10:03:50] <ptrkOP> Oh wow link?
[10:04:01] <ptrkOP> I could probably just google it
[10:04:32] <Kev-> http://www.ebay.com/itm/1PCS-USBasp-USBISP-3-3V-5V-AVR-Programmer-USB-ATMEGA8-New-/400476818256?pt=LH_DefaultDomain_0&hash=item5d3e474b50
[10:04:41] <Kev-> Mine looks like this one
[10:04:44] <Kev-> Probably the same
[10:05:10] <Kev-> Here's one with buy it now and free shipping http://www.ebay.com/itm/USBASP-USBISP-AVR-Programmer-Adapter-10-Pin-Cable-USB-ATMEGA8-ATMEGA128-Arduino-/310506909410?pt=LH_DefaultDomain_0&hash=item484ba76ee2
[10:05:11] <Kev-> $3.19
[10:05:25] <Kev-> I put mine in clear heatshrink and have used it for a while
[10:06:10] <Kev-> You may need the 10 to 6 pin cable separately.. I can't really tell from the auction specs..
[10:06:48] <ptrkOP> Yea it has a 10 pin cable
[10:07:26] <ptrkOP> What about a cheap dev board with 10/6 pin ISP? Reccomendations?
[10:28:45] <Tom_itx> ptrkOP what chips are you gonna program?
[10:30:03] <Tom_itx> just finished up a new batch of these this morning: http://tom-itx.dyndns.org:81/~webpage/commerce/USBTinyMkII_B_front.jpg
[10:32:13] <Tom_itx> ptrkOP, get a breadboard and a handfull of chips and you can make whatever you want
[10:35:16] <Kev-> Tom_itx access denied..
[10:35:26] <Kev-> hmm might be my squid setup tho
[10:35:58] <Tom_itx> port 81
[10:41:16] <twnqx> tzanger: cool stuff
[10:45:42] <ptrkOP> Tom: I am going to be doing the atmega and atiny
[10:45:56] <Tom_itx> mine will do all the 8bit avrs with studio or avrdude
[10:46:07] <Tom_itx> win osx or linux
[10:46:18] <twnqx> Kev-: i ran into that with my squid, too :P
[10:46:27] <ptrkOP> Awesome.
[10:46:43] <Tom_itx> my isp blocks port 80 so i gotta use something else
[10:46:53] <Tom_itx> inconvenient for some
[11:32:20] <halo> hi
[11:33:10] <halo> what happens if and ISR gets triggered while one is still aehm "processing"?
[11:34:33] <jadew> nothing, it will get processed after the current one finishes
[11:35:00] <jadew> on xmegas you have 3 priority levels and higher priority ones will interrupt an ongoing lower priority one
[11:35:16] <jadew> however interrupts of the same level will behave the same as what I said earlier
[11:35:55] <jadew> if the same interrupt gets triggered twice and it's not processed, only the last interrupt will be taken into account
[11:42:29] <Casper> also note that several interrupts won't be processed in the order it came, but based on the vector table...
[11:42:43] <Casper> so each interrupts have a different prio
[11:43:21] <Casper> what the avr actually do is: on interrupt, set a flag. If no other interrupt then process it. at the end it clear the fl;ag and check for other flags
[11:43:31] <halo> jadew Casper thanks
[11:43:33] <Casper> from top to bottom of the vector list
[11:43:57] <Casper> this is also why several of the same interrupt don't fire up all: it set a bit, not a counter
[11:44:03] <jadew> doesn't it clear the flag before doing the jump?
[11:44:35] <Casper> at the reti instruction afaik
[11:44:49] <jadew> my guess is that it does, otherwise the stack overflow issue when doing sei() wouldn't make sense
[11:45:18] <jadew> we have to test this
[11:45:55] * jadew can't do it until later tonigh, I'm doing actual work now
[11:46:16] <Casper> actual or "actual" ?
[11:46:47] <jadew> well, I'm working for my job :)
[11:47:09] <jadew> electronics is not part of it
[11:50:02] <RikusW> WTF ?!! array[40] == 40[array] in C/C++ !?
[11:50:07] <RikusW> it actually compiles
[11:50:14] <RikusW> http://madebyevan.com/obscure-cpp-features/
[11:55:05] <jadew> didn't know about that one
[12:54:11] <halo> hi on line 10 i get the error Error 1 called object '1' is not a function http://pastebin.com/4rEAeEVz can someone hint me in the right direction?
[12:56:33] <Tom_itx> are you sure those bits are in that reg?
[12:56:52] <Tom_itx> is OCR1A 16 or 8 bit?
[13:01:39] <halo> Tom_itx: yes timer1 is 16bit
[13:02:46] <Tom_itx> did you try OCR1AH OCR1AL?
[13:04:03] <Tom_itx> http://tom-itx.dyndns.org:81/~webpage/abcminiuser/articles/avr_timers_index.php
[13:04:07] <Tom_itx> read Part 4
[13:04:35] <Tom_itx> and 5
[13:06:33] <halo> Tom_itx: I'm using an atmega8, the code was developed for atmega32. if i checked the datasheet correctly, there shouldn't be a problem, but I'm new to this.How should OCR1AH/L solf this problem? Anyway using OCR1AL = 10; doesn't help. thanks I'll check it
[13:07:14] <Tom_itx> the code should be ok from one chip to the other. check the register names for sure
[13:07:22] <Tom_itx> in the io.h or data sheet
[13:07:35] <Tom_itx> don't have time to look into it right now
[13:08:19] <halo> Tom_itx: I'll thanks!
[13:45:01] <RikusW> halo: a hint, always write to OCR1AH before writing to OCR1AL
[13:45:20] <RikusW> and read OCR1AL before reading OCR1AH
[13:45:51] <RikusW> halo: or use OCR1A gcc will handle the rest
[13:46:36] <halo> RikusW: thanks. Does someone have an soft-pwm tutorial? very simple nothing special, just for a little led or something. RikusW the error occurs anyway.
[13:47:11] <RikusW> its because H is a temp register shared by all timer H registers btw
[13:47:57] <asteve> aint no party like an OCR1AH party cause an OCR1AH party don't looooowwwwwww
[13:48:10] <OndraSter> :
[13:48:11] <OndraSter> :)
[13:49:23] <RikusW> https://lh6.googleusercontent.com/-sxTuMgmOQCU/UX9dZ5Hma2I/AAAAAAAANdM/O-CQXvZe-YQ/w600-h509/562360_523634971006710_180897652_n.jpg
[13:49:28] <RikusW> hacker problem :-P
[13:49:32] <asteve> hah
[13:49:45] <asteve> future use http://i.imgur.com/MZfsH6Q.png
[13:49:53] <tzanger> heh
[13:54:25] <OndraSter> that is how students look at the end of second semester :P
[13:56:56] <RikusW> lol
[14:49:34] <halo> if I have pwm like this: http://pastebin.com/UzMthr9e I have to connect my LED to OC1A, is it possible to "copy" my pwm signal to 2 other pins without changing a lot?
[14:53:54] <Tom_itx> you could toggle the pins inside the interrupt
[14:55:13] <Tom_itx> halo, tutorials: http://tom-itx.dyndns.org:81/~webpage/how_to/atmega168/mega168_howto_main_index.php
[15:01:23] <halo> Tom_itx: your tutorial can't be used for several pins right? I need 3 but I'm really failing at this task
[15:02:41] <Tom_itx> just toggle a pin in the interrupt
[15:03:38] <Tom_itx> PORTB ^= 0x01;
[15:03:49] <Tom_itx> will toggle that pin every time it's called
[15:04:13] <Tom_itx> don't forget to set your DDRB to output for that pin too
[15:17:44] <halo> Tom_itx: which interrupt? Do you mean I should add one like http://pastebin.com/bZdkh84G ?
[16:21:24] <jigoe> Hey, my ISR for twi only works for one interrupt. Am I right in thinking TWIE gets reset everytime it is interrupted?
[16:56:49] <jadew> jigoe, TWIE doesn't sound like the flag
[16:57:01] <jadew> the sounds would be named something like TWIF
[16:57:18] <jadew> TWIE is interrupt enable, it doesn't get changed after each interrupt
[16:57:42] <jadew> TWIF would get set when an interrupt occurs and cleared when the interrupt is called, unless otherwise specified
[16:58:17] <jigoe> Well, I set TWIE after after I have finished what I was doing each time and it fixed it.
[16:58:25] <jigoe> There isn't a TWIF on this chip
[16:58:44] <jadew> what chip is that?
[16:58:48] <jigoe> 644p
[17:00:40] * jadew has a feeling you're doing it wrong
[17:01:07] <jadew> I might be mistaken tho
[17:01:17] <jigoe> OK, so I enabled Twie in my i2c init.
[17:01:27] <jigoe> and global interrupts.
[17:01:34] <jadew> yeah and then I don't think you need to touch TWIE anymore
[17:01:58] <jigoe> That's what I thought, but it appears to reset after each interrupt.
[17:02:21] <jadew> how do you know that?
[17:02:23] <jigoe> It would interrupt fine for the first i2c byte.
[17:02:45] <jigoe> Now it's fixed if I reenable it after I have ACKed or NACKed
[17:03:10] <jigoe> So bleh, documentation wasn't that clear.
[17:03:53] <jigoe> When this bit is written to one, and the I-bit in SREG is set, the TWI interrupt request will be activated for as long as the TWINT Flag is high.
[17:04:01] <jadew> who knows, maybe that's how it's supposed to work
[17:04:08] <jigoe> Ahh, found this nugget. Anyway, thanks for your help.
[17:04:17] <jadew> npp
[17:04:27] <jadew> TWINT is the interrupt flag
[17:05:06] <jadew> and it still doesn't explain the behavior you described
[17:05:29] <jadew> if it wasn't working before, there's really no reason for it to work after you set, the already set to 1 TWIE
[17:05:48] <jadew> that's why I think you're doing something wrong, it might be working for the wrong reasons
[17:09:47] <jigoe> I'll send you the code.
[17:10:11] <jadew> again, not familiar with i2c via interrupts
[17:10:27] <jadew> it's just that what you're describing seems a bit weird
[17:10:57] <jigoe> Yeah, it's strange. I will ask my lecturer.
[17:16:48] <jigoe> Ahh, I know what's happened.
[17:17:09] <jigoe> The guy who I was using code from made his ACK and NACK defines really strange.
[17:17:31] <jigoe> So it was doing TWCR= instead of TWCR |=
[17:17:42] <jadew> there you go
[17:17:58] <jigoe> Anyway, cheers. I was doing something stupid all along lol
[17:18:07] <jadew> :)
[17:20:17] <jigoe> Look at what he did lol, http://pengu.student.utwente.nl/wordpress/?p=136
[17:22:01] <jadew> jigoe, he's pooling
[17:22:09] <jadew> that's the difference
[17:22:30] <jadew> he doesn't need twie
[17:22:54] <jigoe> Yes, I didn't see that he put = and not |=
[17:23:39] <jigoe> So whenever ack was called it reset twie..
[17:23:48] <jigoe> See what I mean?
[17:23:55] <jadew> I know :)
[17:24:03] <jadew> my point was that for him it didn't matter
[17:24:10] <jigoe> Yeah.
[17:25:17] <jigoe> Weird that someone would write polling i2c though
[17:26:40] <jadew> I do that too
[17:27:05] <jadew> too many states to take care of by interrupt
[17:28:38] <jigoe> I guess it's fine in lowspeed.
[17:28:50] <jigoe> But when I tried it at 100kHz it was pretty unreliable
[17:29:08] <jadew> why?
[17:29:15] <jadew> it works just the same
[17:29:31] <jigoe> In slave mode it wasn't that good.
[17:29:41] <jadew> ah, haven't tried it in slave mode
[17:29:48] <jadew> I guess I would do it by interrupt in slave mode
[17:30:03] <jigoe> Yeah, polling in master is fine.
[17:30:29] <Qantourisc> ?stl
[17:30:32] <Qantourisc> !stl
[17:30:37] <Qantourisc> no bots ? :)
[17:30:52] <Tom_itx> are you a bot?
[17:31:03] <Qantourisc> no
[17:33:33] <Qantourisc> i'm wondering if it's overhead to run STL C++
[17:34:01] <Qantourisc> Might not need it, but it would be more comfy
[17:34:49] <jadew> depends on what you want to use from it
[17:35:14] <jadew> std::swap won't be an overhead
[17:35:20] <jadew> std::string, will
[17:35:29] <Qantourisc> jadew: vectors, list i think, just to get around manual container handling in C
[17:35:37] <jadew> then yeah
[17:35:40] <Qantourisc> And then I also know i can use templates :)
[17:35:58] <jadew> templates are fine, classes, not so much
[17:36:00] <Qantourisc> I don't like missing templates or having to write absf() :)
[17:36:10] <Qantourisc> jadew: how are classes a lot worse ?
[17:36:19] <jadew> you're usually confined to a very small space, so unless you're using a beefy chip, you should stick with the C way of doing things
[17:36:49] <jadew> Qantourisc, instantiating objects
[17:37:02] <Qantourisc> ow, yea
[17:37:07] <Qantourisc> no no plans on that :)
[17:37:15] <jadew> so why would you need classes?
[17:37:27] <jadew> std::string is a class, std::vector is a class
[17:37:37] <Qantourisc> on reason i can imagen right now, and if I do it, it's just to abstract things a bit
[17:37:44] <Qantourisc> not to make a ton of instances :)
[17:38:26] <jadew> I guess it depends a lot on the chip, but on mega and tiny, you generally don't want to do that
[17:38:27] <Qantourisc> jadew: also classes aren't bigger then structs ?
[17:39:08] <jadew> that's true, however I didn't say it's ok to instantiate structs either :)
[17:39:19] <Qantourisc> haha ;)
[17:39:22] <Qantourisc> then i should be fine
[17:39:27] <jadew> as for strings, what kind of string processing are you planning to do?
[17:39:29] <Qantourisc> I use C++ in a lean way not a bloat way
[17:39:36] <Qantourisc> jadew: none
[17:39:40] <jadew> how about vector?
[17:39:57] <jadew> std::vector is pretty resource intensive, even on a modern machine
[17:40:12] <jadew> so unless you know how to use it efficiently, avoid using it
[17:40:19] <Qantourisc> jadew: maybe store a array of the output, pins i'll be using ... but well a C array would do here :)
[17:40:22] <jadew> for example, if you don't reserve the memory it needs in advance
[17:40:32] <jadew> and it allocates 5 bytes and then you add another one
[17:40:33] <Qantourisc> the biggest drain will be the communiction bus
[17:40:51] <jadew> it will have to relocate the whole thing, if there's not enough memory after the inital 5 bytes
[17:41:07] <Qantourisc> jadew: howmany bytes do you have ?
[17:41:12] <jadew> because std::vector guarantees that the data will stored in an array like fashion
[17:41:24] <jadew> what do you mean?
[17:41:39] <Qantourisc> a wait misread :)
[17:42:05] <jadew> now let me take your next item on the list
[17:42:07] <jadew> std::list
[17:42:24] <Qantourisc> yea, i'd use lists where arrays don't fit :)
[17:42:28] <Qantourisc> but no reason
[17:42:32] <Qantourisc> just mainly options
[17:42:33] <jadew> std::list works by allocating memory, somewhere in the ram and also storing a pointer to it
[17:42:37] <Qantourisc> don't even think i'll NEED them :)
[17:42:53] <Qantourisc> If i need them i should make the bus protocol more simple :)
[17:42:56] <jadew> in addition, it also stores two more pointers to the next and previous element
[17:43:02] <Qantourisc> yea i know
[17:43:47] <jadew> generally speaking, you won't have more than 2k RAM at your disposal and that's in a good situation
[17:44:03] <Qantourisc> I can work with that
[17:44:16] <Qantourisc> all i need to do is communicate on a bus, and readout/set I/O pins
[17:44:22] <Qantourisc> basicly IO on a bus :)
[17:44:34] <jadew> well, if you know your application is not time intensive and you can spare the memory / cpu cycles, go for it
[17:44:44] <Qantourisc> I'll need 1 interface, to connect the bus to a PC, or a bigger uC to do the controlling
[17:45:00] <Qantourisc> jadew: it should run on a 8051 :)
[17:45:14] <Qantourisc> unless i turn up the communication-bus speed tomutch
[17:46:45] <Qantourisc> i should go to bed :)
[17:46:53] <jadew> night
[17:47:08] <Qantourisc> thanks for info, i should be fine on a mini avr
[17:47:16] <jadew> np
[17:47:17] <Qantourisc> night