Replies: 16 comments 2 replies
-
|
Hi @greenpau , The K64 is an old MCU and is not getting much attention today. A more modern equivalent from NXP is the MCXN family, and the FRDM-MCXN947 already has I2S support in Zephyr. The K64 uses the same SAI hardware peripheral as the MCXN947, and uses the same driver. You could enable the SAI on the K64, referencing other boards that already support it. Enabling includes steps like adding the SAI device to the K64 SOC and board devicetree, configuring pinctrl, enabling the SAI clock, and ensuring the low-level SAI driver from HAL_NXP is included in the build. Or if it is easier, switch to the FRDM-MCXN947 :) Best regards |
Beta Was this translation helpful? Give feedback.
-
|
@DerekSnell , thank you for the reply!
That's not the way 😄 It was interesting to research how to make this happen. As far as I understand right now, I need to override the default choices made. I spent time understanding At the end, by way of learning, created small library to generate DTS for my project. My work in progress is here https://github.com/greenpau/nxp-utils If you have a moment and get on a phone with me, I would love to pick your brain on the approach. This DIY stuff helps me learning about NXP and Zephyr. |
Beta Was this translation helpful? Give feedback.
-
|
@DerekSnell , I came up with the following / {
aliases {
rec-sw-btn = &rec_sw_btn;
i2s-rx = &i2s0;
};
buttons {
compatible = "gpio-keys";
rec_sw_btn: button_rec {
gpios = <&gpioc 12 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "External Recording Button";
};
};
soc {
i2s0: sai@4002f000 {
compatible = "nxp,kinetis-sai";
reg = <0x4002f000 0x1000>;
interrupts = <80 0>;
status = "okay";
pinctrl-0 = <&i2s0_default>;
pinctrl-names = "default";
/* I2S Parameters */
/* Audio Format Configuration */
protocol = "i2s";
bit-format = "s16le"; /* Signed 16-bit Little Endian */
sample-rate = <16000>; /* 16 kHz */
/* INMP441 Specifics */
receiver {
/* Sync RX to the TX clocks we defined on PTB18/19 */
sync-mode = <1>;
data-lane = <0>;
};
};
};
};
&pinctrl {
i2s0_default: i2s0_default {
group1 {
pinmux = <
0x2054 /* PTC5: MIC_DATA_OUT (Port 2, Pin 5, Alt 4) */
>;
bias-pull-up;
nxp,passive-filter; /* Standard NXP vendor prefix */
drive-strength = "low";
};
group2 {
pinmux = <
0x1134 /* PTB19: MIC_WORD_SELECT (Port 1, Pin 19, Alt 4) */
0x1124 /* PTB18: MIC_BIT_CLOCK (Port 1, Pin 18, Alt 4) */
>;
drive-strength = "low";
slew-rate = "fast";
};
};
};The only thing I am not sure is about the override here. Now, I ran into issue with compiling. As soon as I add #include <zephyr/drivers/i2s.h>
static const struct device *i2s_dev = DEVICE_DT_GET(I2S_RX_NODE);
if (!device_is_ready(i2s_dev)) {
LOG_ERR("I2S device not ready");
atomic_set(&recording_active, 0);
return;
}Researching What I got so far is that I probably would need to create a driver. Found the below paper. Looks relevant. Reviewed /* I2S - Peripheral instance base addresses */
/** Peripheral I2S0 base address */
#define I2S0_BASE (0x4002F000u)So my reg = <0x4002f000 0x1000>;Any ideas what might be causing it? |
Beta Was this translation helpful? Give feedback.
-
|
Hi @greenpau , Let us know how it goes. |
Beta Was this translation helpful? Give feedback.
-
@DerekSnell , thank you for the reference! 👍 At this point, I understand the DTS business a little bit more. What I've learned so far is that I need to write /** @file
* @brief I2S bus (SAI) driver for NXP Kinetis series.
*/
#define DT_DRV_COMPAT nxp_kinetis_i2s
#include <errno.h>
#include <string.h>
#include <zephyr/sys/__assert.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/init.h>
#include <zephyr/drivers/dma.h>
#include <zephyr/drivers/i2s.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/sys/barrier.h>
#include <soc.h>
#include <fsl_sai.h>
#include <fsl_edma.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(dev_i2s_kinetis, CONFIG_I2S_LOG_LEVEL);Do you know if someone already written something like that? |
Beta Was this translation helpful? Give feedback.
-
|
The const struct device *dev = DEVICE_DT_GET(NODE_ID);To fix it, you need to make sure that:
Review /*
* 47 /pinctrl/i2s0_default
* 48 /pinctrl/i2s0_default/group1
* 49 /pinctrl/i2s0_default/group2
* 116 /soc/sai@4002f000
* 117 /soc/sai@4002f000/receiver
*/ |
Beta Was this translation helpful? Give feedback.
-
@ldomaigne , @DerekSnell , thank you for the pointers! I switched to Do the following values what they should be? I also, added the following to Then, I ran into the problem with the clock source: I cannot set it directly |
Beta Was this translation helpful? Give feedback.
-
|
Attempted to set As soon as I did it, I got to the following issue Added |
Beta Was this translation helpful? Give feedback.
-
|
Added and the following error is gone: |
Beta Was this translation helpful? Give feedback.
-
|
Added and the following error is gone: |
Beta Was this translation helpful? Give feedback.
-
|
@DerekSnell , @ldomaigne , that leaves me with the following 2 errors. Both of which has to do with the How would you configure / {
aliases {
rec-sw-btn = &rec_sw_btn;
// i2s-rx = &i2s0;
};
buttons {
compatible = "gpio-keys";
rec_sw_btn: button_rec {
gpios = <&gpioc 12 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "External Recording Button";
};
};
// dma0: dma@40008000 {
// compatible = "nxp,kinetis-dma";
// reg = <0x40008000 0x4000>;
// interrupts = <24 0>;
// status = "okay";
// };
soc {
i2s0: sai@4002f000 {
compatible = "nxp,mcux-i2s";
reg = <0x4002f000 0x1000>;
// interrupts = <80 0>;
status = "okay";
pinctrl-0 = <&i2s0_default>;
pinctrl-names = "default";
/* I2S Parameters */
// dmas = <&dma0 0 0>, <&dma0 1 0>;
dma-names = "tx", "rx";
// // interrupts = <I2S0_Rx_IRQn 0>, <I2S0_Tx_IRQn 0>;
interrupts = <92 0>, <93 0>;
nxp,tx-dma-channel = <0>;
nxp,rx-dma-channel = <1>;
nxp,tx-channel = <0>;
dmas = <&edma0 0 15>, <&edma0 1 14>;
#address-cells = <1>;
#size-cells = <0>;
/* Audio Format Configuration */
// protocol = "i2s";
// bit-format = "s16le"; /* Signed 16-bit Little Endian */
// sample-rate = <16000>; /* 16 kHz */
/* INMP441 Specifics */
receiver {
/* Sync RX to the TX clocks we defined on PTB18/19 */
sync-mode = <1>;
data-lane = <0>;
};
};
};
};
&pinctrl {
i2s0_default: i2s0_default {
group1 {
pinmux = <
0x2054 /* PTC5: MIC_DATA_OUT (Port 2, Pin 5, Alt 4) */
>;
bias-pull-up;
nxp,passive-filter; /* Standard NXP vendor prefix */
drive-strength = "low";
slew-rate = "fast";
};
group2 {
pinmux = <
0x1134 /* PTB19: MIC_WORD_SELECT (Port 1, Pin 19, Alt 4) */
0x1124 /* PTB18: MIC_BIT_CLOCK (Port 1, Pin 18, Alt 4) */
>;
drive-strength = "low";
slew-rate = "fast";
};
};
}; |
Beta Was this translation helpful? Give feedback.
-
|
The In the which corresponds to |
Beta Was this translation helpful? Give feedback.
-
|
Now, I am getting this error. 🫨 💣 Changed |
Beta Was this translation helpful? Give feedback.
-
|
It compiled ... I deployed ... It is running ... BUT now it seems something went wrong and I no longer can flash to the device. however, I can connect to the board via serial just fine. |
Beta Was this translation helpful? Give feedback.
-
|
The Flash GUI did not quite work. |
Beta Was this translation helpful? Give feedback.
-
|
Recovered the device following this tutorial. https://mcuoneclipse.com/2014/04/19/recovering-frdm-k64f-mbed-board/ Something in this |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In
zephyr/boards/nxp/frdm_k64f/doc/index.rst, I see there no mention of I2S at all.The official documentation speaks about odd pins which are marked appropriately. Specifically,
J1odd pins.I am trying to figure out how to make I2S work.
The
zephyr/boards/nxp/frdm_k64f/frdm_k64f-pinctrl.dtsireferencesmodules/hal/nxp/dts/nxp/kinetis/MK64FN1M0VLL12-pinctrl.hvia
nxp/kinetis/MK64FN1M0VLL12-pinctrl.h.The
MK64FN1M0VLL12-pinctrl.hreferences the I2S pins.However, when I open
zephyr/boards/nxp/frdm_k64f/frdm_k64f-pinctrl.dtsi, I see not reference toI2S.Why are these pins not included? For example,
PTC5andPTC7.Beta Was this translation helpful? Give feedback.
All reactions