#avr | Logs for 2014-01-28

Back
[07:00:02] <Malinus> can I just count that the nrf library for m168 is gonna work with my m328p?
[07:00:19] <Malinus> It should, right? I mean, they even share the datasheet.
[07:08:39] <Tom_itx> it should yes
[07:18:48] <Malinus> All my life I've been relaying on microsoft®automagic_tool© (also called [...] studio). Do you guys actually make, makefiles for avr projects? I mean, it seems like a hassle since the projects are normally only a couple of files. So far I've just made a script that takes the mcu name as a parameter and finds all .c files in the current directory. What more would a makefile do for me?
[07:20:20] <Tom_itx> i do all mine with makefiles
[07:20:47] <dkordic> I don't use makefiles at all. Try Forth.
[07:21:04] <dkordic> It is Science Fiction compared to C.
[07:21:50] <Malinus> Tom_itx, mind explaining in short, what a makefile would do for me?
[07:22:35] <Malinus> dkordic, do you use Forth to program your avr's?
[07:22:36] <Tom_itx> give you a .hex file
[07:23:02] <Malinus> Tom_itx, haha :D. I mean, compared to simply using avr-gcc directly?
[07:23:29] <Tom_itx> you can find a bunch of example makefiles around in here: http://tom-itx.dyndns.org:81/~webpage/avr/
[07:23:38] <Fleck> Malinus: you can do many things, you can even set it up to upload after make :D
[07:23:45] <Tom_itx> most are similar or the same as i reuse them
[07:24:01] <Malinus> Fleck, but I can do that with my bash script too...
[07:24:02] <dkordic> Malinus: Yes.
[07:24:08] <Fleck> sure
[07:24:55] <Tom_itx> and using them in windows, i have it tied to a menu on my PN editor
[07:25:11] <Tom_itx> so it compiles from there
[07:25:16] <Malinus> Fleck, because I've been reading a couple of tutorials on makefiles, and I really can't see the upside of it. But probably just my limited knowledge.
[07:25:39] <Tom_itx> most ppl i know use them
[07:25:58] <Malinus> Tom_itx, but why :)?
[07:26:16] <Tom_itx> to each his own
[07:27:02] <Malinus> I just know very little about it, and my ignorance is probably due to that. I just wish somebody could enlighten me. But I guess I do some more reading.
[07:27:45] <Tom_itx> you know, studio will generate a makefile for you?
[07:29:14] <Malinus> Tom_itx, I know, and that's what I've been using for a long time. I've just been doing a lot of stuff on linux lately. With studio it's just "add files, code, press compile icon, press upload icon, done".
[07:29:52] <Tom_itx> that's pretty much what i do with notepad
[07:34:36] <dkordic> Malinus: Take look at OMake. It will analise header files.
[07:35:15] <Fleck> also check cmake :D
[07:37:11] <Tom_itx> or you can just learn about it and make your own :D
[09:31:52] <rue_house> I have a standard makefile that works for prettymuch all my projects
[09:32:15] <rue_house> little tweeks here and there, but generally all done the same
[09:34:01] <rue_house> Malinus, the upside of makefiles is their ability to only recompile the dependancy tree of whats been changed, which dosn't really apply to most avr projects, but its a bit more of a standard than using shell scripts
[09:34:15] <rue_house> the syntax of makefiles is horrible
[09:34:27] * PoppaVic sighs
[09:34:31] <rue_house> there is lots of automagic and implied stuff
[12:56:09] <carabia> I have a problem with master chef
[12:56:24] <carabia> at least here, they refer to the parts of the dish as "components"
[12:56:43] <carabia> it's so nice when everything has to have a fancy name
[12:57:58] <carabia> so i'm always thinking, this here dish consists of broiled op-amps served with bloated cap sauce with burned out ics on the side
[14:35:03] <Roklobsta> I have an http://www.atmel.com/tools/avrraven.aspx for sale if anyone wants. Barely used.
[14:38:34] <illumer> I have a situation
[14:39:08] <illumer> trying to get my system to work in two modes
[14:40:02] <illumer> now I find myself recompile each time I try to switch to the other mode
[14:40:17] <illumer> I want to make it switch using specific variable
[14:40:23] <illumer> while it is running
[14:41:04] <illumer> one more thing
[14:41:31] <illumer> the automated mode is defined in timer_interrupt routine
[14:43:01] <illumer> when I tried to define a global variable to be accessible from both the main and the interrupt routine it didn't work
[14:43:31] <illumer> any ideas?
[14:51:09] <illumer> hello
[14:51:17] <illumer> anybody there?
[15:00:23] <Tom_itx> volatile
[15:00:44] <illumer> didn't work too
[15:00:50] <Tom_itx> but you need that
[15:00:57] <illumer> it even effected the functionality
[15:01:31] <Tom_itx> volatile will update inside the interrupt where without it, it won't
[15:02:57] <illumer> look at this pseudo code
[15:03:28] <Tom_itx> i can't right now
[15:03:36] <Tom_itx> just passin thru
[15:03:49] <illumer> tim0_int{ if(mode){do the automted code} }
[15:04:04] <illumer> okk
[15:04:09] <illumer> may be next time
[15:04:35] <Tom_itx> you'd be ahead to set a var in the interrupt and do the code outside it
[15:05:22] <illumer> I would be ahead?!
[15:06:44] <illumer> main() { while(1) {if(!mode) {do the manual code} }}
[15:07:02] <illumer> I imagined something similar
[15:07:33] <illumer> then I declared 'mode' as global variable
[15:08:32] <illumer> but it didn't manage to switch between the modes
[15:09:44] <Tom_itx> you don't know where in the code the program is when the interrupt is triggered
[15:09:58] <Tom_itx> it could be anywhere
[15:11:26] <illumer> yes
[15:12:40] <illumer> most probably when it goes inside the interrupt it runs in infinte loop without checking 'mode' variable again
[15:13:23] <illumer> but how can I make it come outside the interrpt again
[15:13:25] <illumer> ?
[15:13:53] <illumer> or
[15:14:03] <illumer> I guess I missed it
[15:14:29] <illumer> everytime the counter overflow it reads the 'mode' variable
[15:14:56] <illumer> so it should work I guess
[15:15:06] <Tom_itx> first of all, you don't want an infinite loop inside an interrupt. you want to get in and get out as quick as possible
[15:15:08] <illumer> at least after completing state
[15:15:34] <illumer> you are absolutely right
[15:15:37] <illumer> (y)
[15:15:50] <Tom_itx> is the timer overflowing before the main loop loops again?
[15:16:25] <illumer> yes it's very frequent
[15:16:48] <illumer> as fast as I want the motors to rotate
[15:16:52] <illumer> servos
[15:18:09] <Tom_itx> so maybe the variable is being reset too fast
[15:18:40] <illumer> mode variable?
[15:18:47] <Tom_itx> i guess
[15:18:55] <Tom_itx> i have only seen sudo code
[15:19:03] <Tom_itx> but now i'm gonna go
[15:19:52] <illumer> okk
[16:52:27] <phinxy> is it easy to break the analog to digital part of the microcontroller if i dont use a resistor when doing capacative sensing?
[16:53:02] <phinxy> aka touch buttons
[16:54:12] <Tom_itx> try one and see
[17:37:56] <DanFrederiksen> anyone know how it's possible to switch a transistor so fast and clean that you can duplex an oscilloscope AD between two channels without distortion? what kind of transistor and circuit can do that at gigasample per second
[22:45:11] <scoy> good evening all. learning AVR interrupts in C. when one happens, everything else is stopped/frozen until after the interrupt completes/exits, right?
[22:45:55] <Casper> yes
[22:46:08] <Casper> beware of some issue that can happend however
[22:46:45] <Casper> like if your main code read some data from a variable that is updated in the interrupt that is a multi-bytes variable
[22:46:49] <Casper> or register
[22:47:24] <Casper> your code may read the first byte, the interrupt fire up, update the 2 bytes, your code resume and read the second (now updated) byte :D
[22:47:42] <Casper> if that can be an issue, you may want to reab about...
[22:48:03] <Casper> http://www.nongnu.org/avr-libc/user-manual/group__util__atomic.html
[22:49:48] <scoy> Casper, thanks a lot. right now i'm sending data back and forth over USI and I want to play around with waking up a slave through interrupts.
[22:49:56] <Casper> also, be carefull about the memory usage... most tend to ignore the extra memory usage that the interrupt can use
[22:50:08] <scoy> just wanted to make sure i knew what was, or wasn't, going on in the background
[22:50:36] <Casper> last, be aware that only 1 interrupt of each kind can be "queued"
[22:50:39] <Casper> actually
[22:50:48] <Casper> it's not queued, but flagged
[22:51:31] <Casper> so if you are in "uart rx data ready" interrupt, and another of the same happend at the same time, then the second one is ignored since the flag is cleared only at the exit of the interrupt
[22:51:44] <Casper> hence why you want the interrupt to be as fast as possible
[22:52:12] <scoy> Casper, hmmm. that's interesting because i'm using USART and USI buffer overflow interrupts.
[22:52:59] <scoy> now i want to add a third interrupt to wake up the slave in USI/SPI on attiny2313s
[22:53:10] <Casper> it can be fine
[22:53:35] <Casper> but just remember that the hardware set a bit in the register... and not a counter
[22:54:08] <Casper> and the "reti" instruction clear that flag (in case you don't know assembler, reti = return from interrupt)
[22:54:47] <Casper> a common issue is with the uart receive, people waste too much time in the rx interrupt, and lose bytes
[22:56:44] <scoy> so let's say if got USART and USI interrupts happening all around. what you're saying is that if I spend too much time in any of those functions that a different interrupt would have been triggered, but i missed it because i spent too much damn time in the current one?
[22:58:39] <Casper> it's been a while since I coded, so I forgot the interrupts... but if it share the same interrupt, then yes. but if you have a RX and TX interrupt, and you spend too much time in TX (and RX is clear) and the RX happend then it will be ok
[22:58:53] <Casper> but if you are in RX, and another RX come up, the second is ignored
[22:59:13] <Casper> it's really per interrupt
[23:00:04] <Casper> the way that the hardware deal with the interrupt is that... you can think of a table, where the hardware "check mark" when there is an interrupt that happened
[23:00:35] <Casper> when it happend, the hardware check if it is currently in an interrupt, if not it go from the top of the list and enter the first one that is checked
[23:01:08] <Casper> then at the exit, it remove that mark (clear the bit) and check from the top down if it have another one set
[23:01:39] <Casper> so since it's not a counter but a single bit... once set... you can't increase... it's 1 bit... on or off
[23:02:04] <scoy> yea, makes sense. i'll study the interrupts section of the docs.
[23:02:26] <scoy> i never would have thought about that, so thanks for the help!
[23:02:34] <Casper> it's simple, when you understand it