#avr Logs

Oct 05 2019

#avr Calendar

01:49 AM nohit: --
08:05 AM Kliment: anyone know what I have to do to make the 0-series wake up from standby when a byte comes in on the usart?
08:05 AM LeoNerd: If interrupts are on, that should just happen
08:05 AM Kliment: it says in the datasheet that it's configurable, but I'm not sure where
08:05 AM Kliment: Okay, awesome
08:05 AM LeoNerd: Oh standby not just idle sleep?
08:05 AM Kliment: yes standby
08:05 AM very_sneaky: hey all, I'm pretty new to avr assembler, struggling a little bit with some conditional logic. What's the best way to write `if (reg < 5 && reg > -5)` in avr assembler?
08:06 AM very_sneaky: i seem to be missing most of the tools to write this without being overly verbose
08:08 AM LeoNerd: Kliment: it'll depend on your chip, but looking in my tiny814 datasheet, USART will wake from standby if you have the RUNSTBY bit set; though the section on the USART then doesn't talk about that bit :(
08:09 AM Kliment: very_sneaky: brlt, neg, brlt, rjmp
08:09 AM Kliment: LeoNerd: have that bit set where?
08:09 AM LeoNerd: Exactly my point :/
08:10 AM LeoNerd: Kliment: some peripherals, e.g. ADC, have a RUNSTBY bit - usually it's in CTRLA, so ADC0.CTRL |= ADC_RUNSTBY_bm; will enable that peripheral to run in standby mode
08:10 AM very_sneaky: Kliment, i'm not sure i understand
08:10 AM LeoNerd: The table of interrupts says the UART can do wake on start of frame, if that bit is set. But then later in the USART docs, it doesn't mention that bit
08:10 AM very_sneaky: no positive comparison?
08:11 AM Kliment: very_sneaky: you can swap operands around
08:12 AM Kliment: very_sneaky: or you can use brge instead of neg
08:13 AM Kliment: very_sneaky: Oh shit wait, what kind of avr
08:13 AM very_sneaky: Kliment, i think i sort of see what you're saying, but i think you're assuming i'm more familiar with assembly than i am
08:13 AM very_sneaky: it's an ATmega32a
08:13 AM Kliment: very_sneaky: I'm hacking on a 416 right now
08:14 AM Kliment: very_sneaky: let me pull up the 32a reference
08:14 AM very_sneaky: i can see NEG is there
08:15 AM very_sneaky: Kliment, this is what i'm rolling with atm: https://bpaste.net/show/xbPE
08:15 AM Kliment: Okay, so let's say your value is in R24
08:16 AM Kliment: oh even better
08:16 AM very_sneaky: which actually, looking at it again, looks like it might work
08:16 AM Kliment: yeah, looks fine to me except those are relative jumps
08:17 AM Kliment: But I think your assembler can handle that
08:17 AM very_sneaky: yeah it can, just gotta make sure the labels are close enough
08:17 AM Kliment: Just be aware you can't jump very far with relative jumps
08:17 AM Kliment: Yep
08:18 AM very_sneaky: but wait, could i change it to https://bpaste.net/show/q1xx?
08:18 AM very_sneaky: is that what you're saying?
08:18 AM Kliment: No, NEG works on a register
08:18 AM very_sneaky: ahh, ofc
08:18 AM LeoNerd: Kliment: actually, thinking about it the USART can't run in standby mode, because the peripheral clock isn't running. The only thing it can do is wake on start of frame (i.e. the start bit) which you can then use to switch the sleep mode to simply idle and then sleep again, shutting down the CPU clock but keeping peripheral clock running
08:19 AM Kliment: never mind, your original thing is fine
08:19 AM very_sneaky: but if i replaced 0x05, otherwise that would work? can nest statements?
08:19 AM very_sneaky: i didn't realise i could nest. that might save a lot of lines
08:19 AM Kliment: nest in what sense?
08:20 AM very_sneaky: `CP reg1, NEG reg1`
08:20 AM Kliment: no
08:20 AM Kliment: that won't work
08:20 AM very_sneaky: so, instructions as an argument of another isntruciton
08:20 AM very_sneaky: ah okay
08:20 AM Kliment: but four instructions for your double comparison is about right
08:20 AM very_sneaky: brlt, neg, brlt, rjm
08:21 AM LeoNerd: Kliment: The section "Start Frame Detection" in the USART chapter [24.3.2.7 in the tiny814 datasheet] has a good explanation. I have to head AFK now but can chat more late
08:21 AM very_sneaky: ahh, you were just listing the order of instructions
08:21 AM very_sneaky: gotcha
08:21 AM Kliment: LeoNerd: Thanks, that's all I wanted!
08:21 AM very_sneaky: cheers for the help
08:21 AM LeoNerd: #avr++ # helpful today :)
08:24 AM Kliment: LeoNerd: Okay this is great!
08:24 AM Kliment: LeoNerd: So it basically does what I need automagically in async mode
01:56 PM martinmake: Hey guys, I need to campture some local variables inside of lambda that I pass to other function. And that other function has to be inside of a namespace (not a macro).
01:57 PM LeoNerd: Is that an AVR question?
01:57 PM martinmake: yeah
01:58 PM martinmake: I'm looking for a workaround
04:21 PM cehteh: some people have strange understanding of AVR's
06:10 PM djph: cehteh: eh?
06:18 PM day__ is now known as day