M6 - bit of SMART NCO Frequency
Hi,
I am trying to using some code from @FredBlais to output I2S at a MAX98357A.
https://github.com/speccy88/TAQOZ/blob/master/src/forth/audio/WAV-I2S.FTH
It sets a pin to NCO-Frequency mode and -as far as I understand- tries to output the inverted signal by setting bit14 = M6.
(Sorry for the FORTH syntax.)
%1_00110_0 := #NCO_FREQ 1 14 << NCO_FREQ OR := #NegNCO_FREQ ... *BCLK PIN #NegNCO_FREQ WRPIN
Unfortunately, if bit14 is set, then there is no output at the pin. If the bit is not set, then I can measure the output at the pin.
(Also I do not see anything to be shifted out, but that's the next step...
Edit: There must be some change in the Taqoz version for this, the active PIN get's lost. now I get at least some ugly noise...)
What's wrong here? The code is from 2019, so before the last revision. Has anything changed here?
Thanks for any hints!
Christof
Comments
P_INVERT_OUTPUT (bit14) is not going to be a problem in itself, so you've probably got other problems.
Pin assignment is flawed. Any relative change between DIN and BCLK also requires editing the smartB relative assignment in #SYNC_TX. If BCLK is not DIN+2 then this would explain why the TX pin is doing nothing serially.
Thanks for looking into it! And thank you for the warning.
By chance I was able to use exactly the pins 10,12,14 in my setup and there is a warning in the source code too, so this is not my problem.
@cgracey
The question is here, if M6 bit can be used to invert the output signal at the physical pin in NCO_Frequency mode.
At the moment I do not set M6 and have changed the disabling to float the DIR. Also I have changed over to use local variables in the main loop which is more easy to read for me.
If I output $f I get the following picture, which seems to be OK. Yellow is data, blue is LRCLK. The signals change at high-low of the clock and the last 2 bits of LBS are still transferred after LRCLK changes. The timing of these phases is stable.
(It's the first time, that I play with I2S, so I am not completely sure.)
If I transfer real data, I can faintly hear some good signal burried in lots of noise.
Ah, it must be only one last bit send after LRCLK changes!!!!
Mario is playing now without noise.
Still wondering, if there was a change in the behaviour of M6 which might perhaps explain, that this old code does no more work.
Looking at those scope traces, inverting BCLK will phase shift it with respect to the LRCLK. That might screw with which data bit gets clocked first into each I2S channel.
EDIT: Doing a little reading, I'm surprised to find the data is meant to lag behind the LRCLK by one BCLK. It's different to what I remember from a couple a decades ago. I was reading AC97 specs that had it as LSbit first, but the modern chips seem to be MSbit first now. Same as SPI.
So that means the data trace above is one BCLK late. Inverting BCLK could shift the data later still.
Ah, it's simple a typo! #NCO_FREQ and NCO_FREQ !