Goertzel from ADC+Streamer

I'm done proving out all the pads on the latest test chip. Everything was spot-on, except the PLL, which I believe is in good shape now.
The last thing to try out was the Goertzel circuit. This brings all kinds of capability together. It uses an ADC on a pin, in conjunction with the streamer and CORDIC solver to perform frequency-power measurements. It can even output a sine and cosine on separate DAC pins, while some echoed version of either comes back in through an ADC pin. It resolves phase difference and power.
In my test, since I know the output already works, I tried out the input, never minding the output potential. I let it accumulate sine and cosine samples multiplied by the ADC bit stream, treating 0's as -1 and 1's as 1 coefficients. In my test, after 16 complete target-frequency cycles, I grab the sine and cosine accumulations and perform a cartesian-to-polar conversion on them to render power level of the target frequency in the ADC bitstream. Then, I get the power into a byte and output it onto a DAC pin which the scope shows. It's looking for 3.33MHz:
(pictures in next post, due to modern computer problems)
The last thing to try out was the Goertzel circuit. This brings all kinds of capability together. It uses an ADC on a pin, in conjunction with the streamer and CORDIC solver to perform frequency-power measurements. It can even output a sine and cosine on separate DAC pins, while some echoed version of either comes back in through an ADC pin. It resolves phase difference and power.
In my test, since I know the output already works, I tried out the input, never minding the output potential. I let it accumulate sine and cosine samples multiplied by the ADC bit stream, treating 0's as -1 and 1's as 1 coefficients. In my test, after 16 complete target-frequency cycles, I grab the sine and cosine accumulations and perform a cartesian-to-polar conversion on them to render power level of the target frequency in the ADC bitstream. Then, I get the power into a byte and output it onto a DAC pin which the scope shows. It's looking for 3.33MHz:
(pictures in next post, due to modern computer problems)
Comments
Here's the code that does it:
dat org hubset #$FF ' make a sin/cos table in LUT and then output it to dacs 1/0 ' switches between 1x and 2x frequency doit wrpin adcmode,#4 'enable adc mode on pin 4 bith dira,#5 'enable output on pin 5 mov z,#$1FF 'make 512-sample sin/cos table in lut sincos mov x,z 'get angle into top 9 bits of x shl x,#32-9 qrotate #$7F,x 'get sin/cos of (ro,theta) getqx x 'get cos getqy y 'get sin setbyte x,y,#1 'get sin into byte1, cos in byte0 setword x,x,#1 'copy bytes 1,0 to 3,2 xor x,##$8080 'make bytes 1,0 positive (not used, but could be) wrlut x,z 'write sin:cos:psin:pcos into lut bottom bytes djnf z,#sincos 'make 512 samples loop setq f1 'ready frequency xcont m1,#0 'issue Goertzel command getxacc x 'get last Goertzel accumulations, x first mov y,0 'y comes through s qvector x,y 'convert (x,y) to (rho,theta) getqx x 'get rho (power measurement) shr x,#5 'scale into byte sca x,##$7700 setbyte dacmode,0,#1 'update dac pin (scaled byte comes through s) wrpin dacmode,#5 jmp #loop 'loop adcmode long %0000_0000_000_1000110000000_01_00000_0 'adc dacmode long %0000_0000_000_1010000000000_00_00000_0 'dac f1 long round(3_333_333.3/80_000_000.0 * float($80000000)) '3.33MHz m1 long 4<<17 + 16 'Goertzel mode, pin 4 input, 16-cycle measurement x res 1 y res 1 z res 1
getqx x 'get rho (power measurement) qlog x 'get log of rho getqx x shr x,#17 'shift it into range shr x,#5 'scale into byte
The CORDIC makes some otherwise-extremely-tedious things super easy and fun in assembly language.
Now to dissect the code... think there's a lot of help going on with streamer and smart pin
Voice projects I see on Youtube tend to demonstrate mere connectors back to Google's voice system. Bringing in the cloud is so anticlimactic. They only tell you what they want you to know, and they harvest every bit of information they gather. Then, they interpret what you say through their lens, which does things like apply capitalization on incidental words and phrases that happen to be trademarks. And someday, when they determine that they really don't like you for some secret reason, your system won't work. Not cool.
Having analog functionality on P2 will be a game changer IMO.