#avr Logs

Aug 19 2022

#avr Calendar

06:03 AM crackwitz is now known as Cracki
02:53 PM nuxil: Q: when writing and reading to pins, the datasheet (1284p) says a nop should be used between the write and read instructions. but does this only apply to the same port?, small example given is on same port tho.
03:00 PM nuxil: example is it safe to do: out PORTC r20; out PORTD, r21; in r20 PINA; in r21 PINB; or do i need a NOP here?
03:00 PM nuxil: out PORTC r20; out PORTD, r21; nop; in r20 PINA; in r21 PINB;
03:05 PM nuxil: i guess its only relevant on same port to avoid some metastability
05:42 PM exp: nuxil: haha how many cycles are you down to now?
05:44 PM exp: nuxil: page 82 indicates you should be ok i think, max is 1½ clocks
09:32 PM nuxil: exp, 9300 ish cycles
09:33 PM nuxil: let me grab a coffee and explain
09:38 PM nuxil: so. i had to rewrite the code. old code was a giobridge for 4x motors, in other words sampling 10 inputs. with this code i could get a cycle penalty of 36 cycles.
09:39 PM nuxil: thats like 1 uS. so i changed it to a 2x motor "5 input sampler", instead as it is what i need.
09:39 PM nuxil: now my loop is 9 cycles
09:39 PM nuxil: but.
09:40 PM nuxil: Program: 274 bytes (0.2% Full)
09:40 PM nuxil: so im like.. i wounder if i can use the space to improve my speed.
09:40 PM nuxil: i wrote a a few lines of python.. https://bpa.st/C6UQ
09:40 PM nuxil: https://bpa.st/RB6Q#1L260
09:41 PM nuxil: volla.
09:41 PM nuxil: Program: 130994 bytes (99.9% Full)
09:41 PM nuxil: lol
09:42 PM nuxil: do you see what i did there ?
09:44 PM nuxil: instead of useing a small loop LOOP: in foo; .... out bar; rjmp LOOP; .. is now instead a huge loop: LOOP in foo .. out bar .. in foo; .. out bar; in foo .. out bar .......... jmp LOOP
10:47 PM * nuxil sips some coffee
10:50 PM nuxil: exp, so each pass on the loop takes 9 cycles. @20mhz - 450nSec but if i use that rolf.S file. you can say 9337 passes of the loop is 350nSec while 1 pass is 500nSec
10:50 PM nuxil: thats alot of 100ns improvement and only 1 x 50ns penalty
10:54 PM nuxil: besides. the mcu is not doing anything else than in2out .. so why not do some rolf like this :p
11:03 PM * Phantom adds some tabasco into nuxil's coffee
11:03 PM nuxil: exp, you see the asm code in the py file. i started off by hand copy&paste into my gpiobridge.S file. after like 50 copy&paste,'s im like hell no, number of lines are growing to fast..
11:03 PM nuxil: so i wrote that py file and just include it in gpiobride file instead.
11:03 PM nuxil: and im glad i did so.
11:03 PM nuxil: cos its 84K lines :D
11:05 PM nuxil: Phantom, youre so kind. thank you
11:09 PM * nuxil gets a new cup of coffee
11:10 PM * Phantom adds a spoon of salt in that new coffee