#avr Logs

Nov 20 2020

#avr Calendar

12:40 AM rue_bed2: ok, so tommorow I want to wind my lvdt, check the reset voltages on a t13, and...
12:46 AM rue_bed2: I suppose I should work on some error amp configs for my power supply
04:42 AM aborazmeh_ is now known as aborazmeh
08:51 AM rue_mohr: --
08:54 AM nohit: --
09:04 AM TyrMactire: --?
09:06 AM twnqx: --.
04:50 PM TyrMactire: ok cool. rue_mohr i basically took your idea and made a 595 with a pwm output. i think i did sleep correctly. not really sure how to tell..
04:50 PM TyrMactire: https://github.com/tyrm/stack-k3s/blob/develop/fan-control-avr-shift/main.c
04:56 PM nohit: <avr/sleep.h>
04:56 PM nohit: i didnt know that exists
04:57 PM nohit: but seems simple
05:04 PM rue_mohr: yea there ya go
05:05 PM rue_mohr: but why are you turning the interrrupts on and off all the time?
05:05 PM rue_mohr: just turn then on before the loop and just let them run
05:41 PM TyrMactire: rue_mohr, the documentation says that if an interrupt happens during the operations of sleep_enable it can end up in a bad state
05:41 PM TyrMactire: https://www.nongnu.org/avr-libc/user-manual/group__avr__sleep.html
05:41 PM cehteh: nohit: lol rtfm helps sometimes :D .. and sleeping is (not always) that simple
05:42 PM cehteh: yeah its racy
05:43 PM cehteh: also you may want to look at the PUD register and other powersaving control, not on tiny13 but on newer AVR's
05:43 PM nohit: cehteh: i dont usually read manuals of obsolete parts
05:43 PM cehteh: nohit: thats avr-libc even for actual parts
09:09 PM fstd: i'm going to be mixing some hand-written assembly with machine code produced by avr-gcc, and I'd like to have a few registers all to myself so that the compiler never touches/uses them. can this be done?
09:19 PM cehteh: yep
09:19 PM nohit: here's some info about the ABI and registers https://gcc.gnu.org/wiki/avr-gcc
09:21 PM cehteh: register uint8_t step asm("r2"); ...
09:21 PM cehteh: i have in some old code
09:21 PM cehteh: reserve registers from the C side
09:21 PM cehteh: global
09:21 PM nohit: that's not what he asked
09:22 PM cehteh: it is
09:22 PM fstd: thanks, let me try this
09:22 PM cehteh: you reserve / define them that way after that you can use them and the compiler wont use them for anything else
09:23 PM nohit: he's using asm, not C
09:23 PM cehteh: generally its a bad idea
09:23 PM cehteh: machine code produced by avr-gcc,
09:23 PM cehteh: guess it was C once
09:26 PM fstd: it does what i need it to do, i.e. having such a definition in the file stops avr-gcc from using that register
09:26 PM fstd: so that's awesome, thanks :)
09:26 PM fstd: OTOH i hadn't thought of it still being used by the standard library
09:26 PM fstd: but maybe i can find one that isn't used there
09:27 PM nohit: avr-gcc wont stop using that register
09:27 PM nohit: it will use register for that variable, if that is possible
09:28 PM nohit: but mixing asm & C is ok, just follow the ABI
09:29 PM fstd: yes, i'm aware of that. the goal is to stop avr-gcc from clobbering the register sooner or later; so if i just not use that variable i should be good
10:08 PM nohit: i assume that this is some time-critical thing youre doing ?
10:30 PM fstd: yes, i'm doing PWM in software and need to keep a few tasks below a certain number of cycles or else i'll lose resolution
10:42 PM nohit: so your main function/loop is in C and you call asm functions from C ? and you need to store something between function calls and its so time critical that you need to store it in a register ?
10:53 PM fstd: i use a (hardware) timer to establish a time base, whenever i get a compare match, i advance my clock. the ISR is literally just "ticks++"; but results in a ton of assembly still
10:53 PM fstd: so dedicating a register to 'ticks' and reducint the ISR to literally 'inc r13; reti' seemed like a good idea
10:54 PM nohit: okay
10:54 PM fstd: anyway then i realized i can do away with the ISR altogether and just use the timer's i/o register directly
10:54 PM fstd: the main loop is the next candidate to be rewritten in assembly, if necessary
10:54 PM fstd: overall i'd basically have that main loop, and link to a few C routines (e.g. for my UART)
10:55 PM nohit: ok
11:59 PM day_ is now known as day