#
✕ nick:marcan
#asahi-dev · 2021-10-29 16:08
marcan00000000 585929.9563842667 -0000001 6.00007725 0.000000
#asahi-dev · 2021-10-29 16:08
marcan00000000 540858.4014394722 -0000001 6.50008392 0.000000
#asahi-dev · 2021-10-29 16:08
marcanso I think that must just be a weird artifact of the lowest div
#asahi-dev · 2021-10-29 16:08
marcanalso I get better numbers with a div6
#asahi-dev · 2021-10-29 16:07
marcanI'm probably doing the math wrong
#asahi-dev · 2021-10-29 16:06
marcandoes it?
#asahi-dev · 2021-10-29 16:04
marcan(for the highest freq)
#asahi-dev · 2021-10-29 16:04
marcanthat doesn't look right
#asahi-dev · 2021-10-29 16:04
marcanI get a divider of 4.50005766 with the flop one way, and 4.05639163 the other
#asahi-dev · 2021-10-29 16:03
marcanNCO1: #156: 900000000 0 0xa8/0x23b048000: nco: 0x80300000 0x45e 0x5ad200 0xff9f5200 0x7f9f5200 0x0
#asahi-dev · 2021-10-29 16:03
marcanok, something's off
#asahi-dev · 2021-10-29 15:57
marcanand then this accumulator toggles between two adjacent dividers
#asahi-dev · 2021-10-29 15:57
marcanthe lfsr divider works in 0.5 units (half clocks I guess?)
#asahi-dev · 2021-10-29 15:57
marcanyes
#asahi-dev · 2021-10-29 15:54
marcanprobably why they used an LFSR divider ;)
#asahi-dev · 2021-10-29 15:53
marcan900000000, supposedly
#asahi-dev · 2021-10-29 15:53
marcaninput freq
#asahi-dev · 2021-10-29 15:52
marcan(high_inc needs to be negated in the register)
#asahi-dev · 2021-10-29 15:52
marcanhttps://mrcn.st/p/w1wM9Yvh is my attempt at calculating the values
#asahi-dev · 2021-10-29 15:50
marcanunless the input clock is a bit of a lie and not exact
#asahi-dev · 2021-10-29 15:50
marcanI'd *think* my timer and this thing would be frequency-locked to some extent, which is a bit weird
#asahi-dev · 2021-10-29 15:49
marcanso I measure 47999.3839 but I calculate that macos should be setting 48000.5586 and I don't know if that's measurement error or what
#asahi-dev · 2021-10-29 15:44
marcanjix: yeah I don't know why they use fout as the sum of the params
#asahi-dev · 2021-10-29 15:32
marcanstill has some error though
#asahi-dev · 2021-10-29 15:32
marcanah, had it backwards
#asahi-dev · 2021-10-29 15:32
marcanhm, wait, no, that's too much
#asahi-dev · 2021-10-29 15:32
marcanI actually suspect macos has some rounding error here...
#asahi-dev · 2021-10-29 15:17
marcanzigzag
#asahi-dev · 2021-10-29 15:12
marcanthat's gotta make sense mathematically
#asahi-dev · 2021-10-29 15:10
marcan(r1 - r2) == desired_freq
#asahi-dev · 2021-10-29 15:10
marcannah, see what xnu did there
#asahi-dev · 2021-10-29 15:10
marcanha.
#asahi-dev · 2021-10-29 15:10
marcan12288000
#asahi-dev · 2021-10-29 15:10
marcan>>> 48000 * 256
#asahi-dev · 2021-10-29 15:10
marcan12288000
#asahi-dev · 2021-10-29 15:10
marcan>>> 5952000+6336000
#asahi-dev · 2021-10-29 15:08
marcan(or 0x7fffffff)
#asahi-dev · 2021-10-29 15:08
marcanso really that register can just always be set to 0x80000000 I guess, I have no idea why you'd bother with anything else?
#asahi-dev · 2021-10-29 15:07
marcanand top bit 1 means high div and use high-inc
#asahi-dev · 2021-10-29 15:07
marcanthe midpoint is indeed 0x80000000
#asahi-dev · 2021-10-29 15:06
marcanthat way you can use small incs without having to wait for the accumulator to wrap back across the midpoint
#asahi-dev · 2021-10-29 15:06
marcanthen you set bit 31 of the ctl reg and it goes off
#asahi-dev · 2021-10-29 15:06
marcan00: ctl 04: div/lfsr 08: low-inc 0c: high-inc 10: init accumulator
#asahi-dev · 2021-10-29 15:06
marcanthen you write the config
#asahi-dev · 2021-10-29 15:06
marcanso you have to stop the NCO first, clearing bit 31 of the control register
#asahi-dev · 2021-10-29 15:05
marcanyes, that's what it is
#asahi-dev · 2021-10-29 15:04
marcanhmmm
#asahi-dev · 2021-10-29 15:00
marcanmaybe the third one is just some initializer, perhaps it needs a control reg kick to set?
#asahi-dev · 2021-10-29 15:00
marcanmacos sets these to 0x5ad200 0xff9f5200 0x7f9f5200
#asahi-dev · 2021-10-29 14:58
marcannot sure what that one's about

plus ›