#avr | Logs for 2014-12-23

Back
[04:14:44] <tavish_> i am using watchdog interrupt to wake up from deep sleep, it works okay but every randome hours later i goes into eternal sleep
[04:14:59] <Bright> :(
[04:15:41] <tavish_> debugging since hours
[04:26:17] <davor> this is a bit of a trivial question, but can I unset a bit using WDTCSR = (0<<WDCE); (as an example), in the same manner that I set it by using WDTCSR = (1<<WDCE); ?
[04:26:49] <davor> um... well that doesn't make much sense
[04:27:36] <apo> that's not how you toggle bits
[04:27:55] <davor> yes, it isn't
[04:28:00] <apo> you can set it by doing |= (1<<WDCE) and unset it with &= ~(1<<WDCE)
[04:28:42] <davor> ahh right that makes sense
[04:28:44] <davor> thanks apo
[04:30:58] <tavish_> maybe I am randomnly getting an wdt timer overflow, but after I disable interrupts and before I go to sleep?
[04:31:21] <tavish_> so it never wakes up
[04:32:13] <apo> tavish_: Can you try resetting it before you sleep?
[04:33:22] <apo> davor: (And you don't have to clear WDCE, it is automatically cleared after four cycles)
[04:33:26] <tavish_> apo: no, i need to keep state
[04:33:36] <tavish_> oh
[04:33:38] <tavish_> sorry
[04:34:10] <tavish_> apo: clearing the WDIF bit you mean?
[04:34:20] <apo> tavish_: No, resetting the watchdog
[04:34:38] <apo> wdt_reset()
[04:36:32] <tavish_> no. i have 3 sources of interrupts, i want to go_back_to_sleep() till WDT interrupt wakes me up, if woken by other two
[04:36:57] <tavish_> so as to keep time between wakes constant
[04:45:41] <davor> ah, gotcha apo. one more question, the 328 manual says: "To clear the WDE bit, and/or change
[04:45:41] <davor> the prescaler bits, WDCE must be set." let's say WDCE is unset, and I want to set the entire WDTCSR to 0, including WDE and prescaler bits. will WDTCSR = (1<<WDCE); do the job, or do I have to write 0 to WDE and prescaler bits again after flipping WDCE to 1?
[04:45:42] <davor> sorry about the line break
[04:48:24] <apo> davor: first set WDCE, then clear the register.
[04:54:39] <davor> gotcha, thanks apo
[04:56:26] <davor> apo, so that would basically be WDTCSR |= (1<<WDCE); followed by WDTCSR = (1<<WDCE); ?
[04:56:59] <davor> set it to one, and then set everything to 0 except WDCE which is to be set to 1?
[04:57:25] <apo> sure, that works
[04:57:50] <apo> you may be able to set it to 0, I'm not sure
[04:58:00] <apo> but after 4 cycles it'll be 0 anyway
[04:59:10] <davor> does WDT cycle even if WDE and WDIE are set to 0?
[05:00:58] <apo> I don't know
[05:02:36] <davor> hm, doesn't make much difference anyway. got another question, if I want to put the mcu to pwr_down for a WDT cycle, can I just do wdr, flip WDE to 1, put the chip into pwr_down and just flip WDE to 0 when it wakes up, and continue with my code?
[05:02:58] <davor> I don't want to use WDT for anything other than waking the mcu from pwr_down mode in 4 seconds
[05:07:03] <apo> You'll probably need to set WDIE
[05:07:18] <apo> and make sure it doesn't reset, etc
[05:07:30] <apo> but yeah, that should work
[05:11:16] <davor> oops, yeah. I meant WDIE, I want WDT to interrupt, not reset
[05:11:30] <davor> thanks man
[05:12:07] <twnqx> is that even possible?
[05:12:38] <twnqx> i thought the only purpose of a WDT would be to reset the chip if it fails to keep up
[05:12:49] <twnqx> there's normal timers to interrupt periodicall
[05:12:51] <twnqx> y
[05:16:31] <apo> twnqx: yes
[05:16:45] <apo> twnqx: The WDT can be set to call an interrupt instead
[05:16:52] <twnqx> how... useful
[05:17:00] <apo> twnqx: saves power :)
[05:17:16] * twnqx is reminded of the people who use a timer interrupt to tick the WDT
[05:17:37] <twnqx> hm, in my last project
[05:17:50] <twnqx> i had about 100% execution time ininterrupt handlers
[05:18:15] <twnqx> main() was basically { init(); while (1) { sleep (); }}
[05:18:34] <twnqx> i am still surprised it works.
[05:19:31] <davor> all other timers besides wdt are disabled in pwr_down mode I think
[05:19:54] <apo> davor: That depends on the settings.
[05:20:06] <davor> ah, right
[05:20:39] <davor> wdt is more power-efficient though, right?
[05:21:09] <apo> yeah
[05:22:18] <twnqx> when i went into that deep power down mode
[05:22:25] <twnqx> my chip auto-triggered ADC conversions >_>
[05:25:22] <apo> twnqx: the ADC is only enabled in idle mode or ADC noise reduction mode <_<
[05:28:50] <twnqx> "i wish"
[05:29:17] <twnqx> but you are right, i couldn't go all the way down since i needed timer/can/serial interrupts, still
[05:29:37] <twnqx> and the next best mode auto-triggered ADC conversions.
[05:30:07] <twnqx> apo: btw, what day(s) are you on 31c3
[05:30:08] <twnqx> ?
[05:32:27] <apo> twnqx: 26-30
[05:34:43] <twnqx> cool, 27-29 here :)
[05:37:06] <DO9XE> Hey there, can anyone tell me, whats wrong with this line of code? I get an error on this, saying USB was not declared before and is first used in this function.
[05:37:08] <DO9XE> USB.INTCTRLA |= USB_BUSEVIE_bm;
[05:38:41] <twnqx> what language is that?
[05:38:54] <DO9XE> its c
[05:38:59] <twnqx> if it's C, you probably miss some #include
[05:39:07] <twnqx> for a library that declares "USB"
[05:39:38] <DO9XE> hmm.. I got a lot more errors that are the familiar to this.
[05:39:50] <DO9XE> this particuar line is from here: https://github.com/abcminiuser/lufa/blob/master/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.h#L76
[05:40:42] <twnqx> so your chip is an xmega, i guess
[05:40:55] <twnqx> and you read the lines
[05:40:57] <twnqx> * \note This file should not be included directly. It is automatically included as needed by the USB driver
[05:40:57] <twnqx> * dispatch header located in LUFA/Drivers/USB/USB.h.
[05:41:11] <twnqx> and did exactly that?
[05:42:06] <DO9XE> no, i went into the GenericHID class driver example and only changed the makefile to xMega.
[05:42:07] <apo> yay, just got my E12 resistor set
[05:42:23] <apo> twnqx: I'll be with the bytewerk assembly :p
[05:42:30] <twnqx> ah
[05:42:31] <DO9XE> https://github.com/abcminiuser/lufa/tree/master/Demos/Device/ClassDriver/GenericHID
[05:42:36] <DO9XE> this one
[05:42:39] <twnqx> i am just there to meet up with a few people
[05:42:53] <twnqx> DO9XE: i am afraid i am not that familiar with LUFA
[05:43:01] <twnqx> abcminiuser is around every now and then though
[05:43:12] <twnqx> and the includes look a bit inconsistent to me :X
[05:43:26] <twnqx> as in, not every header file includes all that it needs itself
[05:43:41] <twnqx> apo: i'll just be there to meet people IRL
[05:43:47] <twnqx> and hand something to m
[05:43:49] <apo> twnqx: well yeah
[05:44:01] <apo> I'm certainly not there for the talks :p
[05:44:05] <twnqx> i am
[05:44:06] <twnqx> for a few
[05:44:20] <twnqx> or rather, i'll head to a few
[05:44:22] <apo> I could just watch them afterwards
[05:44:25] <apo> and usually I do
[05:44:26] <twnqx> as i am there already :P
[05:44:32] <apo> just a few that I actually visit in person
[05:44:33] <DO9XE> I allready wrote him a mail on thursday ;) Or I'll find some experts @31C3 ;)
[05:44:45] <twnqx> lol, see you there :P
[05:45:15] <DO9XE> Ill be with the Labor19.net assembly, right next to the POC and the elevators on floor 1 :)
[05:45:30] <apo> DO9XE: you and your xmega :p
[05:45:55] <twnqx> apo: guess i'll chat you up to meet there
[05:46:01] <DO9XE> apo, jipp, got to get my project running ;) I want to pass my examen ;)
[05:46:07] <twnqx> lol
[05:46:35] <twnqx> if it's that urgent
[05:46:40] <twnqx> here's what i would do
[05:46:54] <twnqx> find what header file delcares USBN for xmega
[05:46:54] <apo> twnqx: run in circles, scream, and shout?
[05:46:57] <twnqx> and include that
[05:46:58] <twnqx> :P
[05:47:03] <twnqx> USB*
[05:47:06] <apo> twnqx: and then get another atmega
[05:47:31] <twnqx> i have to make some pcb for 32u2 (and up)
[05:47:33] <twnqx> :X
[05:47:36] <twnqx> actually
[05:47:43] <twnqx> has to be done at latest... tomorrow
[05:47:47] <twnqx> i should start...
[05:47:59] <twnqx> but the lazyness is strong
[05:48:08] * apo just uses a breakout board
[05:48:10] * apo is lazy
[05:48:13] <DO9XE> funny thing is, that i only changed the makefile from the example, i didnt wrote anything by myself, I just wanted it for xmega.
[05:48:24] <twnqx> doesn't really work
[05:48:34] <twnqx> e.g. the example for cdc serial
[05:48:44] <twnqx> is bound to the at90 eval board
[05:48:51] <twnqx> due to the use of the joystick input
[05:49:00] <twnqx> (i am struggling with that one :P)
[05:49:06] <twnqx> even though i have said eval baord
[05:49:25] <twnqx> wanted to port it from at90usb to mega32u4
[05:50:28] <DO9XE> I am going to create a own board directory :) or kill a lot of the code snippets ;)
[05:51:54] * apo ponders p-channel vs n-channel fets for his project
[05:52:24] <twnqx> doesn't that simply depend on wether you want to drive from VCC or GND?
[05:52:48] <twnqx> because of the need for charge pumps otherwise
[05:52:54] <apo> pretty much
[05:52:55] <twnqx> to get above VCC to switch on :P
[05:53:16] <twnqx> whenever i design mosfet etc circuitry
[05:53:22] <twnqx> i always run spice simulations
[05:53:27] <twnqx> i am too afraid of failure :P
[05:54:22] <apo> coward! :D
[05:58:49] <twnqx> hey
[05:59:00] <twnqx> at least my design normally work from first PCB spin
[05:59:59] * apo installs ngspice, takes a look
[06:00:08] <apo> that's a lot of warnings
[06:43:20] <davor> huh. this code example for waking the 328p from pwr_down with wdt does sleep_enable(); sleep_mode(); sleep_disable();. I just took a look at sleep.h, and all sleep_mode(); does is call sleep_enable(); sleep_cpu(); sleep_disable();
[06:45:43] <davor> what a netsplit.
[07:38:40] <davor> I have a problem with this code http://pastebin.com/DsPHmDj0 I want the 328 to be woken up specifically by wdt, however it's being woken up by another interrupt. how do I disable all interrupts besides wdt? is there some register that controls this? the interrupt pages of the datasheet seem a bit confusing
[07:39:24] <davor> I suppose the code itself isn't really relevant, I just need to find a way to temporarily disable all interrupts except wdt
[07:40:32] <Tom_itx> i dunno if CLI does that or not
[07:40:36] <Tom_itx> you should check
[07:41:38] <Tom_itx> if you use it don't forget SEI when you need them back
[07:42:49] <davor> dunno if that disables the wdt interrupt too? I'll give it a shot
[07:44:51] <Tom_itx> since wdt is enabled with a fuse
[07:46:31] <Tom_itx> • Possible Hardware fuse Watchdog always on (WDTON) for fail-safe mode
[07:47:46] <davor> hm, not sure if that fuse is on
[07:48:21] <davor> ya it isn't apparently
[07:48:23] <Tom_itx> read the wdt section and also about sei cli
[07:48:31] <Tom_itx> gotta go
[07:48:42] <davor> awesome, thanks man
[08:12:10] <ecilop> Do you use ariduno?
[08:18:39] <gjm> >ariduno
[08:18:56] <davor> yes ecilop
[08:20:11] <davor> it seems weird. a 328 can be woken up from power down using int0, int1 and pin change, using a twi address something something and using wdt
[08:20:35] <davor> seems very odd that I can't disable the first two wakeups and only have it wake up on wdt interrupt
[08:20:45] <davor> doesn't make sense
[08:26:26] <twnqx> does it wake up even with those interrupts disabled?
[08:27:25] <davor> as far as I know, I can only do cli to disable interrupts (which includes wdt), and then it doesn't wake up at all, or not do cli, and then it wakes up instantly
[08:30:49] <davor> twnqx, this is my code http://pastebin.com/DsPHmDj0 . instead of being woken up after 4 s, it's woken up immediately, resulting in the LED always being on with a brief flash every second
[08:33:20] <twnqx> i don't see your main()
[08:33:27] <twnqx> i can't tell if you enable pin change interrupts
[08:33:32] <twnqx> or anything else
[08:34:25] <davor> ah, it's actually arduino code. it first runs setup(), and then loops through loop()
[08:34:44] <twnqx> so you complain that magic software does magic things
[08:35:14] <twnqx> how about you check if the arduino stuff enables the interrupts that wake your chip up?
[08:35:37] <davor> I'd first have to know how are specific interrupts enabled/disabled. which is what I was/am asking
[08:35:45] <davor> I can't figure it out for the life of me
[08:36:06] <twnqx> ... check the data sheet?
[08:36:26] <davor> so far I've been successful at finding stuff in there, but this I cannot find
[08:36:36] <davor> I can only see how to configure specific interrupts
[08:36:39] <davor> not enable/disable them
[08:37:40] <davor> moving interrupt vectors and stuff
[08:38:42] * twnqx read section 13, "external interrupts"
[08:39:08] <twnqx> particularly
[08:39:10] <twnqx> 13.2.2 EIMSK – External Interrupt Mask Register
[08:39:19] <twnqx> Bit 1 – INT1: External Interrupt Request 1 Enable
[08:39:27] <twnqx> Bit 0 – INT0: External Interrupt Request 0 Enable
[08:40:19] <davor> AH! damn it! thanks man
[08:40:27] <davor> sorry, must be blind or something..
[08:40:55] <twnqx> comes with using arduino ;)
[08:44:42] <davor> hahaha
[08:45:06] <davor> I like the RF24 library, I don't know how I'd be able to interface with the damn nrf24l01 otherwise
[09:02:30] <twnqx> write three functions: init() tx() and rx()
[09:31:32] <LeoNerd> I found the trickiest it of the nRF24L01 is purely hardware: mine doesn't work propedly without an external 1μF decoupling cap
[09:36:24] <twnqx> isn't that just normal?
[09:37:57] <LeoNerd> Is it? I didn't know
[09:38:21] <LeoNerd> My point being: everything else talking to it was easy
[09:40:45] <apo> \o/ got my diodes as well
[09:40:51] <apo> one step closer to a working USB MIDI keyboard
[09:41:03] <apo> just need the DC/DC converter and optocoupler now
[09:41:57] <DO9XE> apo, how many optocupllers do you need, got like 300 of them :D
[09:42:04] <apo> DO9XE: just one
[09:42:29] <DO9XE> If you want I can bring you a rail to the 31C3 :)
[09:42:40] <apo> already ordered it, but thanks
[09:42:51] <apo> however... if you can also get me a 9V source we can play around with the keyboard ;)
[09:42:52] <DO9XE> no problem ;)
[09:43:10] <apo> I guess I could just get a 9V block somewhere
[09:48:15] <apo> DO9XE: what do you do with all these optocouplers?
[09:48:51] <apo> DO9XE: or did you just get a batch from china for 5 bucks? ;)
[09:49:06] <DO9XE> thy were cheap :D I also got like 650 CMOS inverters in DIP here :D
[09:49:13] <apo> heh
[09:50:11] <DO9XE> I was at the HAM Radio in Friedrichshafen and bougt like 10 Roles of SMD (main reason) and the guy gave me like 1k microchips extra and oll for 30 bucks :)
[09:51:09] <apo> nice
[09:52:56] <DO9XE> Got a big car, I can bring 'em all and you can get some ;)
[09:54:56] <apo> just ordered some 100 FETs, too ;)
[10:22:58] <apo> DO9XE: Hmm, there should be plenty of assemblies with soldering irons
[10:23:23] <apo> Guess I'll bring my keyboard after all
[10:26:25] <DO9XE> I'll have my solering stuff, too :) also a frequency generator, 1GHz counter, Oscilloskop, RF-Generator (abgleichsender)
[10:26:40] <apo> \o/
[10:27:48] <apo> lugging this thing around will be a pain :)
[10:27:48] <DO9XE> also we will have a DC-supply from 0-12V and 0-2A
[10:27:53] <apo> cool
[10:28:03] <apo> I think it only needs 50mA
[10:28:08] <DO9XE> and 3 Servers :)
[10:28:35] <DO9XE> Labor19.net is known for the need to overkill ;)
[10:28:59] <apo> I'll only bring what I can carry in my backpack
[10:29:00] <apo> No car :p
[10:30:53] <DO9XE> I got a citroen Berlingo to fill up :) the fuel to Hamburg is my christmas present from my mom :D
[10:31:16] <apo> nice
[10:32:10] <DO9XE> something special you want, which i might have? :D last year we brougt 2 euro-paletten to our assembly :'D
[10:32:18] <DO9XE> with 3 people xDDD
[10:37:56] <apo> I don't think so
[10:38:09] <apo> unless you've got some TRRS cable extensions that you want to get rid of
[10:47:45] <DO9XE> i have cables with male to open end. 3.5mm, 3 Pin
[10:50:14] <DO9XE> c.a. 3-5m long :) you just need some plugs :)
[11:00:48] <apo> 3 pin is TRS, not TRRS
[11:02:03] <DO9XE> ah, dman :D
[11:04:09] <hamnstar> hello AVR folks! Anyone here well versed in USARTs?
[11:04:39] <hamnstar> I'm currently troubleshooting what seems to be an "erroneous error" but of course this is probably some form of ignorance on my part
[11:05:05] <Casper> do you use a crystal or the internal RC oscillator?
[11:05:09] <Casper> do you have an oscilloscope?
[11:06:06] <hamnstar> its running on a crystal
[11:06:21] <hamnstar> i have an oscilloscope :)
[11:06:27] <hamnstar> i've looked at SCLK and it looks clean
[11:06:28] <DO9XE> which controller do yu use?
[11:06:44] <DO9XE> SCLK at Usart?
[11:06:57] <hamnstar> its an atmega128rfa1 talking to a SAM3X8E. errors crop up on the SAM
[11:07:32] <hamnstar> i get data overrun errors.... so it thinks that I'm not reading bytes before the next one comes in
[11:07:36] <hamnstar> ostensibly
[11:08:23] <hamnstar> I've simplifed the USART ISR to just reading the RHR register to make it as fast as possible, and _should_ therefore not miss any bytes due to a long ISR routine
[11:08:37] <hamnstar> and of cuorse, the best part, is that sometimes it works. but most times it doesnt
[11:12:49] <Casper> hamnstar: do async or sync serial? you talk about sclk so sync, then there can not be clock rate issue
[11:26:55] <Casper> hamnstar: if you send a bunch of "U" you will get a squarewave on the data line, usefull to check the real speed
[11:27:10] <Casper> but be sure that the output is set to output... that can also be an issue
[11:27:18] <hamnstar> Casper yup it is synchronous
[11:27:31] <hamnstar> my theory was line jitter registering more bits than are intended
[11:27:36] <hamnstar> er, not jitter, noise
[11:29:51] <hamnstar> Casper: its super weird, the SAM device can transmit to the atmega just fine. and the atmega is sending data to the SAM.... but the sam is getting data overrun errors all the time :/
[11:30:11] <hamnstar> the atmega is a slower processor so it's the one driving SCLK
[11:30:20] <Casper> try to set the output of the mega (ddr) to output
[11:30:57] <hamnstar> for SCLK you mean?
[11:32:31] <Casper> no, the data line
[11:33:17] <hamnstar> yeah, its an output
[11:33:42] <hamnstar> sometimes it receives fine
[11:33:51] <hamnstar> *sometimes the SAM receives fine
[11:34:14] <Casper> scope the lines and see the rise and fall and the voltages...
[11:36:58] <hamnstar> will confirm that in a few mins here
[11:37:04] <hamnstar> Casper: thx btw :)
[14:20:32] <hamnstar> Casper: have returned from lunch and took some measurements. seems to be in the 0-3.3 range quite nicely when measured at the problematic processor
[14:20:54] <hamnstar> however TX is getting put out at 3.4V
[14:21:36] <hamnstar> I wonder if somehow the USART expects the same levels received and transmitted?
[14:22:25] <hamnstar> although a margin of .1v seems kinda anal if thats what breaks it
[14:29:03] <hamnstar> scratch that, i think that was just measurement error
[14:59:58] <Casper> hamnstar: what's the vcc of the avr? 5V or 3.3V?
[15:19:17] <hamnstar> Casper: both processors are 3.3
[15:19:26] <hamnstar> according to this schematic.... will measure
[15:29:30] <Casper> 5 -> 3.3, if the 3.3V is 5V tolerant then it's fine, else it could fry it, but in the mean time it will work fine
[15:30:01] <Casper> 3.3 -> 5V, it's borderline working, often a logic high is 2/3VCC, which is 3.3V...
[17:21:14] <hamnstar> yeah both are def 3.3
[17:21:41] <hamnstar> its gotta be some kinda conflicting interrupt or something
[17:21:48] <hamnstar> the physical signals all look perfectly good
[17:22:06] <hamnstar> and it does work like 1% of the time
[17:23:17] <N1njaneer> Yay 3d printer on order
[17:23:49] <hamnstar> which one?
[17:25:26] <N1njaneer> Stratasys UPrint SE Plus
[17:25:41] <DO9XE> twnqx, I searche the whole LUFA directory... there is no class which is called "USB"... the only "USB." i found was in those xMega files and in the python scripts :/ Maybe its a typo? but that often? :/
[17:47:08] <Jartza> hallo
[17:47:13] <Jartza> merry christmas all!
[17:48:23] <DO9XE> merry christmas :)
[18:26:11] <twnqx> DO9XE: don't inlcude the .
[18:35:55] <DO9XE> twnqx, i think its not lufa. i guess its the avr-libc :P
[18:37:16] <twnqx> possible
[18:42:46] <DO9XE> because in some code u use OSC.CTRL to change the oscillator settings. ans USB.XXX is for changing the USB settings. so my libc must be the problem