Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs/psoc6/quickref.rst: Fix clock details in PDM section. #197

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions docs/psoc6/quickref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ The :mod:`machine` module::

import machine

machine.freq() # get the current frequency of the Core M4
machine.freq(CM4, freq) # set the frequency of the Core M4 sourced by PLL to freq. Value of freq can be upto 150 MHz
machine.freq(CM4_FLL, freq) # set the frequency of the Core M4 sourced by FLL to freq. Value of freq can be upto 48 MHz
machine.freq(AUDIO_I2S_98_MHZ) # set the frequency of the I2S clock to 98 MHz
machine.freq(AUDIO_I2S_90_MHZ) # set the frequency of the I2S clock to 90 MHz
machine.freq(AUDIO_PDM_24_576_000_HZ) # set the frequency of the I2S clock to 24576000 HZ
machine.freq(AUDIO_PDM_22_579_200_HZ) # set the frequency of the I2S clock to 22579200 HZ
machine.freq() # get the current frequency of the Core M4
machine.freq(machine.CM4, freq) # set the frequency of the Core M4 sourced by PLL to freq. Value of freq can be upto 150 MHz
machine.freq(machine.CM4_FLL, freq) # set the frequency of the Core M4 sourced by FLL to freq. Value of freq can be upto 48 MHz
machine.freq(machine.AUDIO_I2S_98_MHZ) # set the frequency of the I2S clock to 98 MHz
machine.freq(machine.AUDIO_I2S_90_MHZ) # set the frequency of the I2S clock to 90 MHz
machine.freq(machine.AUDIO_PDM_24_576_000_HZ) # set the frequency of the I2S clock to 24576000 HZ
machine.freq(machine.AUDIO_PDM_22_579_200_HZ) # set the frequency of the I2S clock to 22579200 HZ

Delay and timing
----------------
Expand Down Expand Up @@ -558,8 +558,8 @@ Before using the I2S bus, the I2S clock frequency needs to be set. The I2S clock

::

machine.freq(AUDIO_I2S_98_MHZ) # set the frequency of the I2S clock to 98 MHz. For sample rates: 8KHz / 16 KHz / 32 KHz / 48 KHz
machine.freq(AUDIO_I2S_90_MHZ) # set the frequency of the I2S clock to 90 MHz. For sample rates: 22.05 KHz / 44.1 KHz
machine.freq(machine.AUDIO_I2S_98_MHZ) # set the frequency of the I2S clock to 98 MHz. For sample rates: 8KHz / 16 KHz / 32 KHz / 48 KHz
machine.freq(machine.AUDIO_I2S_90_MHZ) # set the frequency of the I2S clock to 90 MHz. For sample rates: 22.05 KHz / 44.1 KHz

Constructor
^^^^^^^^^^^^
Expand All @@ -581,15 +581,15 @@ Constructor

::

from machine import I2S, Pin
from machine import I2S, Pin, AUDIO_I2S_90_MHZ
import array

buf=bytearray(10) #Initialise buffer with required values for transmission & as empty buffer for reception
machine.freq(AUDIO_I2S_90_MHZ) #set the frequency of the I2S clock to 90 MHz.

audio_out = I2S(0, sck="P13_1", ws="P13_2", sd="P13_3", mode=I2S.TX, bits=16, format=I2S.STEREO, rate=22050, ibuf=20000) #create I2S object
num_written = audio_out.write(buf) # write buffer of audio samples to I2S device


audio_in = I2S(0, sck="P5_4", ws="P5_5", sd="P5_6", mode=I2S.RX, bits=16, format=I2S.STEREO, rate=22050, ibuf=20000) # create I2S object
num_read = audio_in.readinto(buf)# fill buffer with audio samples from I2S device

Expand All @@ -599,14 +599,29 @@ PDM - PCM bus
PDM/PCM is a asynchronous operation used to connect digital audio devices.
At the physical level, a bus consists of 2 lines: CLK, DATA.

PDM objects can be created and initialized using::
.. warning::
This is not part of the core MicroPython libraries. Therefore, not mapping any existing machine class API and neither supported by other ports.

from machine import PDM_PCM
from machine import Pin

The following specialization applies for configuring PDM-PCM bus in this port:

Before using the PDM-PCM bus, the clock frequency needs to be set. The PDM-PCM clock frequency can be set to 24.576 MHz or 22.579 MHz depending upon the sample rate. In order to set the frequency, use the following function:

::

machine.freq(machine.AUDIO_PDM_24_576_000_HZ) # set the frequency of the clock to 24.576 MHz. For sample rates: 8 / 16 / 48 kHz
machine.freq(machine.AUDIO_PDM_22_579_000_HZ) # set the frequency of the clock to 22.579 MHz. For sample rates: 22.05 / 44.1 KHz


PDM-PCM objects can be created and initialized using::

from machine import PDM_PCM, Pin, AUDIO_PDM_24_576_000_HZ

clk_pin = "P10_4"
data_pin = "P10_5"

machine.freq(AUDIO_PDM_24_576_000_HZ)

pdm_pcm = PDM_PCM(
0,
sck=clk_pin,
Expand Down Expand Up @@ -637,7 +652,7 @@ Constructor

- ``clk`` is a pin object for the clock line
- ``data`` is a pin object for the data line
- ``sample_rate`` specifies audio sampling rate
- ``sample_rate`` specifies audio sampling rate. It can be set to 8 / 16 / 48 KHz for which the clock frequency should be set to 24.576 MHz or to 22.05 / 44.1 KHz while clock should be set to 22.579 MHz.
- ``decimation_rate`` specifies PDM decimation rate
- ``bits`` specifies word length - 16, 18, 20, 24 being accepted values
- ``format`` specifies channel format - STEREO, MONO_LEFT or MONO_RIGHT
Expand Down
Loading