sipeed / MaixPy-v1

MicroPython for K210 RISC-V, let's play with edge AI easier
https://wiki.sipeed.com/maixpy
Other
1.68k stars 438 forks source link

How to use the I2S master clock (MCLK) ? #405

Open rcmz opened 3 years ago

rcmz commented 3 years ago

Hello, I'm trying to use the I2S master clock (MCLK) signal on my Maix Bit (firmware v0.6.2) but I'm having issues

I used the same code as in the I2S tutorials, plus I registered the I2S MCLK pin, but no signal is outputted on the I2S MCLK pin

fm.register(19, fm.fpioa.I2S0_WS)
fm.register(18, fm.fpioa.I2S0_SCLK)
fm.register(17, fm.fpioa.I2S0_OUT_D1)
fm.register(16, fm.fpioa.I2S0_MCLK)
i2s = I2S(0)
i2s.channel_config(1, I2S.TRANSMITTER)
i2s.set_sample_rate(30000)

Then I found this issue https://github.com/sipeed/MaixPy/issues/159, in which they use undocumented parameters to the I2S constructor

i2s = I2S(0, pll2=262144000, mclk=31)

With this change the I2S MCLK pin now outputs a 5MHz signal (I'm not sure it is really 5Mhz my oscilloscope is pretty bad)

My question is what do these parameters do and how can I change the frequency of the I2S MCLK ? I tried playing with the pll2 and mclk parameters, and also looking at the source code, but I couldn't understand how it works

If you have any advise or documentation I could refer to Thanks

NameStream commented 1 year ago

su09-17-2023

ImportError: cannot import name MIC_ARRAY

MAix Amigo

(1.) Hi, there.

(2.) Using MAixPy IDE, receiving error code for MAix Amigo:

ImportError: cannot import name MIC_ARRAY

(3.) MAix AMIGO

(3a.) SP-MOD MicArray Module

(3b.) Connector: 10P 0.5mm FPC

(3c.) Sipeed MAix R6 + 1 Microphone Array Board

(3d.) Located inside the back of the developer board #2970, moved the switch to M1N instead of STM.

(3e.) MAixPy IDE: Tools > Select Board > Sipeed Maixduino

(3f.) Will only run the code for “helloworld.py”, although the LCD image orientation is misaligned, upside down; the picture is smaller than the LCD screen; but image has mostly clear resolution without any noticeable lag, latency, delay.

(3g.) Receiving “ImportError: cannot import name MIC_ARRAY” when attempting to run the code for:

ROUTINE Sound Source Localization

https://wiki.sipeed.com/soft/maixpy/en/develop_kit_board/module_microphone.html

andalsofor

AirPocket Soundman’s Sound Localizer https://github.com/airpocket-soundman/SoundVisualizer/blob/main/src/mic_array_en_ver204.py

(3h.) Pin assignments used for MAix AMIGO

LED_CLK_GPIOHS28…….23

LED_DAT_GPIOHS27…….20

DAT 0…………….......……12

DAT 1……………..…..…….…9

DAT 2………………..…...……31

DAT 3………….……..……...7

WS……………..…....…..……19

BCK_SCK……...…..…………17

(4.) Would you list the correct pin assignments for the:

(4a.) MAix Amigo #2970 in the M1n position

(4b.) MAix Amigo #2970 in the STM position

(5.) Thanks.

(6.) Toodles!