ワイヤレス接続に関するナレッジベース

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Wireless Connectivity Knowledge Base

ディスカッション

ソート順:
This post provides guidance on how to port the example projects from the NXP NCI 2.0 NFC library to the MCXW71 Wireless MCU using SPI interface to communicate with PN7160 SPI EVK. To follow this guide, please use the following environment: MCUXpresso IDE 25.06.136. FRDM-MCXW71 SDK v25.12.00 (last available for MCUXpresso IDE). FRDM-MCXW71. OM27160B1 (PN7160 SPI EVK). Hardware Setup. The MCXW71 complies with the Arduino header standard as the OM27160B1 board, therefore you can connect directly the shield over the FRDM-MCXW71 as the pin connection match among both, allowing an easy connection between the devices. Take into consideration that this setup forces us to use the LPSPI1 instance of the MCXW71, it is possible to use another instance, but we would not be able to connect the boards directly, rather we would need to do the connections with jumpers.   Downloading base projects and adapting for MCXW71 port. To start with the porting work, download the NXP-NCI example project from this page. This compressed file contains the base project for different boards that will allow us to do the required modifications to add support for the MCXW71. Once downloaded, extract the SW6705 file into a known path (e.g. the Downloads folder) to later import the project to the IDE. The extracted folder should contain a .zip file with the examples that we will later import to the IDE. Download the FRDM-MCXW71's SDK from the SDK Builder page, make sure to select the 25.12.00 version, as it is the latest SDK available to use along the MCUXpresso IDE. Now we have to import the NXP-NCI2.0_MCUXpresso_examples.zip file we previously extracted to the IDE's workspace, to do so, click on the Import project(s) from file system and in the Project archive (zip) tab, browse for the extracted file of step 1 (NXP-NCI2.0_MCUXpresso_examples.zip) and click on Next >. NOTE: Don’t worry if the IDE shows an error message for not having the SDKs of the default boards (iMXRT1170, LPC55S6x, LPC82x) or having a different version, close the warning message, we only need these examples to copy the NCI library and example files. Your workspace should now look like the following image: Import the hello_world example from the FRDM-MCXW71 SDK: Add the SPI drivers to the imported project by right clicking over the project, hover the cursor over the SDK Management option and select the option Manage SDK Components: Select the driver, click Ok and if you are asked to refresh files accept it, after this you should be able to see the driver in the "drivers" folder of the project. Copy the contents of the source folder of the iMXRT1170 project, as well as the NfcLibrary folder and paste them into the imported hello_world project:   Make sure to delete the hello_world.c and hello_word.mex files as we won't need it again. After this process your project should look like the following image: To avoid compiling issues, exclude from the build the files nfc_example_P2P.c and nfc_example_RW.c, to do so right click on the file, go to Resource Configurations and select Exclude from Build… and select for all configurations. Do this for each file. Add the preprocessor macro: BOARD_NXPNCI_INTERFACE_SPI, as this is used by the example to select the interface with the board. To do this, right-click on the project and select Properties, then drop-down the C/C++ Build option and go to the Settings tab. Here, add the macro in the Preprocessor option, click on Apply and accept the index rebuild. Add the root folder in C/C++ General > Paths and Symbols > Source Location tab, click on Ok and then Apply: Still in Paths and Symbols, go to the Includes tab and add the source, TML and tool folders from workspace, click Ok and Apply. Make sure to add them one by one. Now, go to C/C++ Build > Settings > Includes and add the following folders from Workspace. You can select all of them and add them at the same time or also do it one by one. Once done, click on Apply and Apply and Close. If you are asked to rebuild the index, do it. "${workspace_loc:/${ProjName}/source/TML}" "${workspace_loc:/${ProjName}/source/tool}" "${workspace_loc:/${ProjName}/NfcLibrary}" "${workspace_loc:/${ProjName}/NfcLibrary/inc}" "${workspace_loc:/${ProjName}/NfcLibrary/NdefLibrary}" "${workspace_loc:/${ProjName}/NfcLibrary/NdefLibrary/inc}" "${workspace_loc:/${ProjName}/NfcLibrary/NdefLibrary/src}" "${workspace_loc:/${ProjName}/NfcLibrary/NxpNci20}" "${workspace_loc:/${ProjName}/NfcLibrary/NxpNci20/inc}" "${workspace_loc:/${ProjName}/NfcLibrary/NxpNci20/src}" Source Code Changes. In the board folder, open the board.h file and add the following definitions to refer to the peripherals and clocks to be used. Please notice that you may change the LPSPI instance, however you would need to connect jumpers instead of connecting directly the shield over the FRDM. #ifdef BOARD_NXPNCI_INTERFACE_SPI #define BOARD_NXPNCI_SPI_CLOCK (CLOCK_GetIpFreq(kCLOCK_Lpspi1)) #define BOARD_NXPNCI_SPI_INSTANCE (LPSPI1) #define BOARD_NXPNCI_SPI_BAUDRATE (400000) #endif #define BOARD_NXPNCI_IRQ_PORT (GPIOC) // J2.10 - GPIO0 [PN7160] - IRQ -> J2.10 GPIOC0 [MCXW71] #define BOARD_NXPNCI_VEN_PORT (GPIOA) // J4.1 - GPIO1 [PN7160] - VEN -> J1.8 GPIOA21 [MCXW71] #define BOARD_NXPNCI_DWL_PORT (GPIOA) // J4.2 - GPIO2 [PN7160] - REQ -> J1.7 GPIOA20 [MCXW71] #define BOARD_NXPNCI_IRQ_PIN (0U) #define BOARD_NXPNCI_VEN_PIN (21U) #define BOARD_NXPNCI_DWL_PIN (20U) Now we need to add the required clock, peripheral and pin initialization for our board. To do this, go to the hardware_init.c file inside the board folder, and overwrite the BOARD_InitHardware function with the following: void BOARD_InitHardware(void) { BOARD_InitPins(); BOARD_BootClockRUN(); BOARD_InitDebugConsole(); CLOCK_SetIpSrc(kCLOCK_Lpspi1, kCLOCK_IpSrcFro192M); CLOCK_SetIpSrcDiv(kCLOCK_Lpspi1, kSCG_SysClkDivBy16); }   To add the correct pin multiplexing and configuration for our SPI and GPIO pins, go to the pin_mux.c file (also in the board folder) and overwrite the BOARD_InitPins function with the following: void BOARD_InitPins(void) { /* Clock Configuration: Peripheral clocks are enabled; module does not stall low power mode entry */ CLOCK_EnableClock(kCLOCK_GpioA); CLOCK_EnableClock(kCLOCK_GpioC); CLOCK_EnableClock(kCLOCK_PortA); CLOCK_EnableClock(kCLOCK_PortB); CLOCK_EnableClock(kCLOCK_PortC); /*IF SHORTING SH11, SH12, SH13, SH14 needed for LPSPI1*/ const port_pin_config_t portb0_pin46_config = {/* Internal pull-up resistor is enabled */ (uint16_t)kPORT_PullUp, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPSPI0_PCS0 */ (uint16_t)kPORT_MuxAlt2, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTB0 (pin 46) is configured as LPSPI1_PCS0 */ PORT_SetPinConfig(PORTB, 0U, &portb0_pin46_config); const port_pin_config_t portb1_pin47_config = {/* Internal pull-up resistor is enabled */ (uint16_t)kPORT_PullUp, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPSPI0_SIN */ (uint16_t)kPORT_MuxAlt2, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTB1 (pin 47) is configured as LPSPI1_SIN */ PORT_SetPinConfig(PORTB, 1U, &portb1_pin47_config); const port_pin_config_t portb3_pin1_config = {/* Internal pull-up resistor is enabled */ (uint16_t)kPORT_PullUp, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPSPI0_SOUT */ (uint16_t)kPORT_MuxAlt2, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTB3 (pin 1) is configured as LPSPI1_SOUT */ PORT_SetPinConfig(PORTB, 3U, &portb3_pin1_config); const port_pin_config_t portb2_pin48_config = {/* Internal pull-up resistor is enabled */ (uint16_t)kPORT_PullUp, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPSPI0_SCK */ (uint16_t)kPORT_MuxAlt2, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTA19 (pin 14) is configured as LPSPI1_SCK */ PORT_SetPinConfig(PORTB, 2U, &portb2_pin48_config); /*IF SHORTING SH11, SH12, SH13, SH14 needed for LPSPI1*/ const port_pin_config_t irq_pin = {/* Internal pull-up/down resistor is disabled */ (uint16_t)kPORT_PullUp, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as PTC0 */ (uint16_t)kPORT_MuxAsGpio, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTC0 (pin 37) is configured as PTC0 */ PORT_SetPinConfig(PORTC, 0U, &irq_pin); const port_pin_config_t ven_pin = {/* Internal pull-up/down resistor is disabled */ (uint16_t)kPORT_PullDisable, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as PTA20 */ (uint16_t)kPORT_MuxAsGpio, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTA20 (pin 17) is configured as PTA20 */ PORT_SetPinConfig(PORTA, 20U, &ven_pin); const port_pin_config_t req_pin = {/* Internal pull-up/down resistor is disabled */ (uint16_t)kPORT_PullDisable, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as PTA21 */ (uint16_t)kPORT_MuxAsGpio, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTA21 (pin 18) is configured as PTA21 */ PORT_SetPinConfig(PORTA, 21U, &req_pin); const port_pin_config_t portc2_pin39_config = {/* Internal pull-up/down resistor is disabled */ (uint16_t)kPORT_PullDisable, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPUART1_RX */ (uint16_t)kPORT_MuxAlt3, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTC2 (pin 39) is configured as LPUART1_RX */ PORT_SetPinConfig(PORTC, 2U, &portc2_pin39_config); const port_pin_config_t portc3_pin40_config = {/* Internal pull-up/down resistor is disabled */ (uint16_t)kPORT_PullDisable, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPUART1_TX */ (uint16_t)kPORT_MuxAlt3, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTC3 (pin 40) is configured as LPUART1_TX */ PORT_SetPinConfig(PORTC, 3U, &portc3_pin40_config); }   To add the required interfacing APIs specific of our chip, we need to modify the tml.c file from the TML folder, in this file overwrite the functions: INTF_INIT, INTF_WRITE and INTF_READ with the following: static void INTF_INIT(void) { lpspi_master_config_t userConfig; uint32_t srcFreq = 0; /*SPI configuration*/ LPSPI_MasterGetDefaultConfig(&userConfig); userConfig.baudRate = BOARD_NXPNCI_SPI_BAUDRATE; srcFreq = BOARD_NXPNCI_SPI_CLOCK; userConfig.whichPcs = (lpspi_which_pcs_t)kLPSPI_Pcs0; userConfig.pcsActiveHighOrLow = (lpspi_pcs_polarity_config_t)kLPSPI_PcsActiveLow; /*Initialize SPI*/ LPSPI_MasterInit(BOARD_NXPNCI_SPI_INSTANCE, &userConfig, srcFreq); } static status_t INTF_WRITE(uint8_t *pBuff, uint16_t buffLen) { uint8_t temp[1000]; temp[0] = 0x7F; memcpy(temp+1, pBuff, buffLen); masterXfer.txData = temp; masterXfer.rxData = NULL; masterXfer.dataSize = buffLen+1; masterXfer.configFlags = kLPSPI_MasterPcs0 | kLPSPI_MasterPcsContinuous | kLPSPI_MasterByteSwap;; return LPSPI_MasterTransferBlocking(BOARD_NXPNCI_SPI_INSTANCE, &masterXfer); } static status_t INTF_READ(uint8_t *pBuff, uint16_t buffLen) { status_t status; uint8_t temp[257]; temp[0] = 0xFF; masterXfer.txData = temp; masterXfer.rxData = temp; masterXfer.dataSize = buffLen+1; masterXfer.configFlags = kLPSPI_MasterPcs0 | kLPSPI_MasterPcsContinuous | kLPSPI_MasterByteSwap;; status = LPSPI_MasterTransferBlocking(BOARD_NXPNCI_SPI_INSTANCE, &masterXfer); if(status == kStatus_Success) memcpy(pBuff, temp+1, buffLen); SDK_DelayAtLeastUs(10, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY); return status; } #endif   We also need to overwrite the functions: tml_Init, tml_DeInit and tml_Reset to adapt them to use the specific APIs for the GPIOs of our board. static Status tml_Init(void) { gpio_pin_config_t in_config = {kGPIO_DigitalInput, 0}; gpio_pin_config_t out_config = {kGPIO_DigitalOutput, 0}; GPIO_PinInit(BOARD_NXPNCI_IRQ_PORT, BOARD_NXPNCI_IRQ_PIN, &in_config); GPIO_PinInit(BOARD_NXPNCI_VEN_PORT, BOARD_NXPNCI_VEN_PIN, &out_config); GPIO_PinInit(BOARD_NXPNCI_DWL_PORT, BOARD_NXPNCI_DWL_PIN, &out_config); INTF_INIT(); return SUCCESS; } static Status tml_DeInit(void) { GPIO_PortClear(BOARD_NXPNCI_VEN_PORT, 1U << BOARD_NXPNCI_VEN_PIN); return SUCCESS; } static Status tml_Reset(void) { /* Set DWL_REQ low for NCI protocol */ GPIO_PortClear(BOARD_NXPNCI_DWL_PORT, 1U << BOARD_NXPNCI_DWL_PIN); GPIO_PortClear(BOARD_NXPNCI_VEN_PORT, 1U << BOARD_NXPNCI_VEN_PIN); Sleep(10); GPIO_PortSet(BOARD_NXPNCI_VEN_PORT, 1U << BOARD_NXPNCI_VEN_PIN); Sleep(10); return SUCCESS; }   Finally, modify the main file so it uses the APIs to initialize our board clocks and pins: #include <stdio.h> #include <string.h> #include "app.h" #include "board.h" #include "pin_mux.h" #include "fsl_debug_console.h" extern void nfc_example (void); int main(void) { BOARD_InitHardware(); #ifdef BOARD_NXPNCI_INTERFACE_I2C PRINTF("\nRunning the NXP-NCI2.0 example (I2C interface)\n"); #else PRINTF("\nRunning the NXP-NCI2.0 example (SPI interface)\n"); #endif nfc_example(); } Testing the example. At this point we have everything set to build and flash our example with SPI interface, you may proceed to build and debug/flash the example by pressing the blue beetle button: Once the example is flashed, open a serial terminal such as Teraterm with the following settings: Baudrate: 115200. Data: 8 bits. Parity: None. Stop bits: 1 bit. No flow control. While running, the example should output the following logs to the terminal: When a tag is placed near the antenna, the example should print the tag information in the terminal as shown:
記事全体を表示
This pages is used to log key items related with KW4X products evaluation, development with SDK, power and RF performance evaluation, etc.
記事全体を表示
This article discusses the different use cases and configuration of the errata "ERR053404: FlexCAN: Message Buffer (MB) and Enhanced RX FIFO Filter Element (ERFFEL) Memory Corruption". The errata is impacting Messabe Buffers (MB) and Enhanced RX FIFO Filter Elements (ERFFEL), the impact of each MB or ERFFEL depends on the configuration of the payload buffer, MB and/or ERFFEL. In this post, we plan to provide some examples of such configuration and impact on the FlexCAN IP.  Taking a 64-byte payload as an example, the following configurations illustrate the trade-off between the number of Message Buffers (MBs) and acceptance filters: /* ERR053404: This errata explains affected words depends on MB payload size, this example applies for MB configured for 64-byte payload */ #define BYTES_IN_MB kFLEXCAN_64BperMB FLEXCAN_FDInit(EXAMPLE_CAN, &flexcanConfig, EXAMPLE_CAN_CLK_FREQ, BYTES_IN_MB, true); 1. MB0 is not used, MB1 is used. In this configuration, ERFFEL[0–29] can be fully utilized as acceptance filters, while MB1–MB6 are available as Message Buffers, maximum ERFCR[NFE] is 14. The following code can be used as reference for the driver configuration for this case.  /* Config fifo filters to make it accept STD frame with ID 0x123 ~ 0x140. Used ERFFEL[0–29], ERFCR[NFE]=14 */ uint32_t rxEnFifoFilter[] = {FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x123, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x124, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x125, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x126, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x127, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x128, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x129, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12A, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12B, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12C, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12D, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12E, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12F, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x130, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x131, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x132, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x133, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x134, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x135, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x136, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x137, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x138, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x139, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13A, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13B, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13C, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13D, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13E, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13F, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x140, 0, 0x3F, 0)}; flexcan_enhanced_rx_fifo_config_t rxEhFifoConfig; flexcan_rx_mb_config_t mbConfig; /* Setup Enhanced Rx FIFO. */ rxEhFifoConfig.idFilterTable = rxEnFifoFilter; rxEhFifoConfig.idFilterPairNum = sizeof(rxEnFifoFilter) / sizeof(rxEnFifoFilter[0]) / 2U; rxEhFifoConfig.extendIdFilterNum = 0; rxEhFifoConfig.fifoWatermark = RX_MESSAGE_COUNT - 1U; /* Reduce the frequency to enter IRQ. */ rxEhFifoConfig.dmaPerReadLength = kFLEXCAN_19WordPerRead; rxEhFifoConfig.priority = kFLEXCAN_RxFifoPrioHigh; FLEXCAN_SetEnhancedRxFifoConfig(EXAMPLE_CAN, &rxEhFifoConfig, true); rxFifoXfer.framefd = &rxFrame[0]; rxFifoXfer.frameNum = RX_MESSAGE_COUNT; /* Set Rx Masking mechanism for MB. Only accept data frame with desired ID. */ FLEXCAN_SetRxMbGlobalMask(EXAMPLE_CAN, FLEXCAN_RX_MB_STD_MASK(0x7FFU, 0, 0)); #define RX_MESSAGE_BUFFER_1 (1U) /* Setup Rx Message Buffer 1. */ mbConfig.format = kFLEXCAN_FrameFormatStandard; mbConfig.type = kFLEXCAN_FrameTypeData; mbConfig.id = FLEXCAN_ID_STD(0x121U); FLEXCAN_SetFDRxMbConfig(EXAMPLE_CAN, RX_MESSAGE_BUFFER_1, &mbConfig, true); 2. MB0 and MB1 are not used. In this case, ERFFEL[0–31] are available for acceptance filtering, and MB2–MB6 are reserved as Message Buffers, maximum ERFCR[NFE] is 15. The following code can be used as reference for the driver configuration for this case.  /* Config fifo filters to make it accept STD frame with ID 0x123 ~ 0x142. Used ERFFEL[0–31], ERFCR[NFE]=15 */ uint32_t rxEnFifoFilter[] = {FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x123, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x124, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x125, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x126, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x127, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x128, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x129, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12A, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12B, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12C, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12D, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12E, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12F, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x130, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x131, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x132, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x133, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x134, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x135, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x136, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x137, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x138, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x139, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13A, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13B, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13C, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13D, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13E, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x13F, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x140, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x141, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x142, 0, 0x3F, 0)}; flexcan_enhanced_rx_fifo_config_t rxEhFifoConfig; /* Setup Enhanced Rx FIFO. */ rxEhFifoConfig.idFilterTable = rxEnFifoFilter; rxEhFifoConfig.idFilterPairNum = sizeof(rxEnFifoFilter) / sizeof(rxEnFifoFilter[0]) / 2U; rxEhFifoConfig.extendIdFilterNum = 0; rxEhFifoConfig.fifoWatermark = RX_MESSAGE_COUNT - 1U; /* Reduce the frequency to enter IRQ. */ rxEhFifoConfig.dmaPerReadLength = kFLEXCAN_19WordPerRead; rxEhFifoConfig.priority = kFLEXCAN_RxFifoPrioHigh; FLEXCAN_SetEnhancedRxFifoConfig(EXAMPLE_CAN, &rxEhFifoConfig, true); rxFifoXfer.framefd = &rxFrame[0]; rxFifoXfer.frameNum = RX_MESSAGE_COUNT; 3. MB0 and MB1 are both used. Under this configuration, only ERFFEL[0–11] can be used as acceptance filters. ERFFEL[12–31] are not available, while MB0–MB6 can be used as Message Buffers, maximum ERFCR[NFE] is 5. The following code can be used as reference for the driver configuration for this case.  /* Config fifo filters to make it accept STD frame with ID 0x123 ~ 0x12E. Used ERFFEL[0–11], ERFCR[NFE]=5 */ uint32_t rxEnFifoFilter[] = {FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x123, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x124, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x125, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x126, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x127, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x128, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x129, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12A, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12B, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12C, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12D, 0, 0x3F, 0), FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(0x12E, 0, 0x3F, 0)}; flexcan_enhanced_rx_fifo_config_t rxEhFifoConfig; flexcan_rx_mb_config_t mbConfig; /* Setup Enhanced Rx FIFO. */ rxEhFifoConfig.idFilterTable = rxEnFifoFilter; rxEhFifoConfig.idFilterPairNum = sizeof(rxEnFifoFilter) / sizeof(rxEnFifoFilter[0]) / 2U; rxEhFifoConfig.extendIdFilterNum = 0; rxEhFifoConfig.fifoWatermark = RX_MESSAGE_COUNT - 1U; /* Reduce the frequency to enter IRQ. */ rxEhFifoConfig.dmaPerReadLength = kFLEXCAN_19WordPerRead; rxEhFifoConfig.priority = kFLEXCAN_RxFifoPrioHigh; FLEXCAN_SetEnhancedRxFifoConfig(EXAMPLE_CAN, &rxEhFifoConfig, true); rxFifoXfer.framefd = &rxFrame[0]; rxFifoXfer.frameNum = RX_MESSAGE_COUNT; /* Set Rx Masking mechanism for MB. Only accept data frame with desired ID. */ FLEXCAN_SetRxMbGlobalMask(EXAMPLE_CAN, FLEXCAN_RX_MB_STD_MASK(0x7FFU, 0, 0)); #define RX_MESSAGE_BUFFER_0 (0U) /* Setup Rx Message Buffer 0. */ mbConfig.format = kFLEXCAN_FrameFormatStandard; mbConfig.type = kFLEXCAN_FrameTypeData; mbConfig.id = FLEXCAN_ID_STD(0x120U); FLEXCAN_SetFDRxMbConfig(EXAMPLE_CAN, RX_MESSAGE_BUFFER_0, &mbConfig, true); #define RX_MESSAGE_BUFFER_1 (1U) /* Setup Rx Message Buffer 1. */ mbConfig.format = kFLEXCAN_FrameFormatStandard; mbConfig.type = kFLEXCAN_FrameTypeData; mbConfig.id = FLEXCAN_ID_STD(0x121U); FLEXCAN_SetFDRxMbConfig(EXAMPLE_CAN, RX_MESSAGE_BUFFER_1, &mbConfig, true); Recommendation: To achieve a balanced trade-off between the number of Message Buffers and acceptance filters, Option 1 is recommended.
記事全体を表示
This doc is a brief step by step introduction for how to play music through A2DP on IW612 + I.MX8MPlus-EVK based on L6.6.52. Step 1: Load WiFi/Bluetooth Driver • NXP i.MX Release Distro 6.6-scarthgap imx8mpevk ttymxc1 imx8mpevk login: root root@imx8mpevk:~# modprobe moal mod_para=nxp/wifi_mod_para.conf root@imx8mpevk:~# root@imx8mpevk:~# dmesg | grep wlan [ 562.728200] wlan: Loading MWLAN driver [ 562.728788] wlan: Register to Bus Driver... [ 562.730460] wlan: Enable TX SG mode [ 562.730464] wlan: Enable RX SG mode [ 563.554778] wlan: uap%d set max_mtu 2000 [ 563.622367] wlan: version = SDIW612---18.99.3.p21.10-MM6X18505.p4-GPL-(FP92) [ 563.625611] wlan: Register to Bus Driver Done [ 563.625622] wlan: Driver loaded successfully root@imx8mpevk:~#modprobe btnxpuart root@imx8mpevk:~# hciconfig -a hci0: Type: Primary Bus: UART BD Address: D0:17:69:EE:71:4F ACL MTU: 1021:7 SCO MTU: 120:6 DOWN RX bytes:774 acl:0 sco:0 events:48 errors:0 TX bytes:496 acl:0 sco:0 commands:47 errors:0 Features: 0xbf 0xfe 0x8f 0xfe 0xdb 0xff 0x7b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH SNIFF Link mode: PERIPHERAL ACCEPT • Step 2: Up BT interface and enable the power save feature root@imx8mpevk:~# hciconfig hci0 up root@imx8mpevk:~# hciconfig hci0 piscan root@imx8mpevk:~#hciconfig hci0 noencrypt root@imx8mpevk:~# hciconfig -a hci0: Type: Primary Bus: UART BD Address: D0:17:69:EE:71:4F ACL MTU: 1021:7 SCO MTU: 120:6 UP RUNNINGPSCAN ISCAN RX bytes:1900 acl:0 sco:0 events:109 errors:0 TX bytes:1365 acl:0 sco:0 commands:108 errors:0 Features: 0xbf 0xfe 0x8f 0xfe 0xdb 0xff 0x7b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH SNIFF Link mode: PERIPHERAL ACCEPT Name: 'imx8mpevk' Class: 0x200000 Service Classes: Audio Device Class: Miscellaneous, CI Version: 5.4 (0xd) Revision: 0x8300 LMP Version: 5.4 (0xd) Subversion: 0x1015 Manufacturer: NXP Semiconductors (formerly Philips Semiconductors) (37) • Step 3: Scan, Pair and Connect to Headset root@imx8mpevk:~# bluetoothctl hci0 new_settings: powered connectable discoverable bondable ssp br/edr le secure-conn cis-central cis-peripheral Agent registered [CHG] Controller D0:17:69:EE:71:4F Pairable: yes [bluetooth]# power on Changing power on succeeded [bluetooth]# default-agent Default agent request successful [bluetooth]# agent on Agent is already registered [bluetooth]# scan on [NEW] Device B1:96:11:68:9C:09 联想thinkplus-HE05X II代 [bluetooth]# scan off [bluetooth]# pair B1:96:11:68:9C:09 Attempting to pair with B1:96:11:68:9C:09 hci0 device_flags_changed: B1:96:11:68:9C:09 (BR/EDR) supp: 0x00000000 curr: 0x00000000 [DEL] Device 67:02:B9:7C:ED:B5 67-02-B9-7C-ED-B5 [DEL] Device 80:F4:16:4C:48:F2 HI-Apiyoo-12MIQ001981 hci0 B1:96:11:68:9C:09 type BR/EDR connected eir_len 34 [CHG] Device B1:96:11:68:9C:09 Connected: yes hci0 new_link_key B1:96:11:68:9C:09 type 0x04 pin_len 0 store_hint 1 [CHG] Device B1:96:11:68:9C:09 Bonded: yes [DEL] Device 6A:98:7A:08:0F:B8 6A-98-7A-08-0F-B8 [CHG] Device B1:96:11:68:9C:09 ServicesResolved: yes [CHG] Device B1:96:11:68:9C:09 Paired: yes Pairing successful5X II代]# [DEL] Device 6C:59:25:E5:66:77 6C-59-25-E5-66-77 [DEL] Device 61:CC:7D:CE:20:4E 61-CC-7D-CE-20-4E [DEL] Device 64:C1:4B:76:C1:80 64-C1-4B-76-C1-80 [DEL] Device 72:50:16:14:52:A6 72-50-16-14-52-A6 hci0 B1:96:11:68:9C:09 type BR/EDR disconnected with reason 2 [CHG] Device B1:96:11:68:9C:09 ServicesResolved: no [CHG] Device B1:96:11:68:9C:09 Connected: no [bluetooth]#trust B1:96:11:68:9C:09 [CHG] Device B1:96:11:68:9C:09 Trusted: yes Changing B1:96:11:68:9C:09 trust succeeded [bluetooth]#connect B1:96:11:68:9C:09 Attempting to connect to B1:96:11:68:9C:09 hci0 B1:96:11:68:9C:09 type BR/EDR connected eir_len 34 [CHG] Device B1:96:11:68:9C:09 Connected: yes [NEW] Endpoint /org/bluez/hci0/dev_B1_96_11_68_9C_09/sep1 [NEW] Endpoint /org/bluez/hci0/dev_B1_96_11_68_9C_09/sep2 [NEW] Transport /org/bluez/hci0/dev_B1_96_11_68_9C_09/sep1/fd0 [CHG] Transport /org/bluez/hci0/dev_B1_96_11_68_9C_09/sep1/fd0 Delay: 0x05dc (1500) Connection successfulII代]# [CHG] Device B1:96:11:68:9C:09 ServicesResolved: yes [联想thinkplus-HE05X II代]#quit • Step 4: Start pipewire and wireplumber Service then list and choose default Audio Source/Sink Card root@imx8mpevk:~#systemctl --user start pipewire wireplumber root@imx8mpevk:~#wpctl status PipeWire 'pipewire-0' [1.0.5, root@imx8mpevk, cookie:831282980] Clients: 32. WirePlumber [1.0.5, root@imx8mpevk, pid:1528] 40. WirePlumber [export] [1.0.5, root@imx8mpevk, pid:1528] 87. wpctl [1.0.5, root@imx8mpevk, pid:1552] Audio -Devices: 41. Built-in Audio [alsa] 42. Built-in Audio [alsa] 43. Built-in Audio [alsa] 44. Built-in Audio [alsa] 45. Built-in Audio [alsa] 81. 联想thinkplus-HE05X II代 [bluez5] -Sinks: 47. Built-in Audio Mono [vol: 0.40] 48. Built-in Audio Stereo [vol: 0.40] 50. Built-in Audio Stereo [vol: 0.40] 58. Built-in Audio Digital Stereo (IEC958) [vol: 0.40] * 82. 联想thinkplus-HE05X II代 [vol: 0.40] -Sources: 46. Built-in Audio Mono [vol: 1.00] 49. Built-in Audio Stereo [vol: 1.00] 51. Built-in Audio Stereo [vol: 1.00] * 59. Built-in Audio Digital Stereo (IEC958) [vol: 1.00] -Filters: -Streams: Video -Devices: 52. mxc-isi-m2m_v1 [v4l2] 53. vsi_v4l2enc [v4l2] 54. vsi_v4l2dec [v4l2] Streams: Settings Default Configured Devices: root@imx8mpevk:~#wpctl set-default 82 root@imx8mpevk:~#wpctl set-default 59 root@imx8mpevk:~# wpctl status PipeWire 'pipewire-0' [1.0.5, root@imx8mpevk, cookie:831282980] Clients: 32. WirePlumber [1.0.5, root@imx8mpevk, pid:1528] 40. WirePlumber [export] [1.0.5, root@imx8mpevk, pid:1528] 87. wpctl [1.0.5, root@imx8mpevk, pid:1572] Audio 41. Built-in Audio [alsa] 42. Built-in Audio [alsa] 43. Built-in Audio [alsa] 44. Built-in Audio [alsa] 45. Built-in Audio [alsa] 81. 联想thinkplus-HE05X II代 [bluez5] 47. Built-in Audio Mono [vol: 0.40] 48. Built-in Audio Stereo [vol: 0.40] 50. Built-in Audio Stereo [vol: 0.40] 58. Built-in Audio Digital Stereo (IEC958) [vol: 0.40] * 82. 联想thinkplus-HE05X II代 [vol: 0.40] 46. Built-in Audio Mono [vol: 1.00] 49. Built-in Audio Stereo [vol: 1.00] 51. Built-in Audio Stereo [vol: 1.00] * 59. Built-in Audio Digital Stereo (IEC958) [vol: 1.00] 分区Bluetooth 的第4 页 * 59. Built-in Audio Digital Stereo (IEC958) [vol: 1.00] Streams: Video 52. mxc-isi-m2m_v1 [v4l2] 53. vsi_v4l2enc [v4l2] 54. vsi_v4l2dec [v4l2] Streams: Settings Default Configured Devices: 0. Audio/Sink bluez_output.B1_96_11_68_9C_09.1 1. Audio/Source alsa_input.platform-sound-xcvr.iec958-stereo Step 5: Copy、Play and Enjoy Music Drag the music file yesterday-once-more.wavto I.MX8MP-EVK board by connecting Windows PC and I.MX8MP-EVK board into one local area network. root@imx8mpevk:~# pw-play -v ./yesterday-once-more.wav sndfile: opened file "yesterday-once-more.wav" format 00010002 channels:2 rate:44100 sndfile: using default channel map: FL,FR PCM: fmt:s16 rate:44100 channels:2 width:2 rate:44100 latency:4410 (0.100s) connecting playback stream; target=(null) stream state changed unconnected -> connecting stream param change: Spa:Enum:ParamId:Latency stream param change: Spa:Enum:ParamId:Tag stream param change: Spa:Enum:ParamId:Props stream properties: application.name = "pw-play" node.name = "pw-play" media.software = "Lavf58.29.100" media.format = "WAV (Microsoft)" node.rate = "1/44100" node.latency = "4410/44100" media.type = "Audio" media.category = "Playback" media.role media.filename = "yesterday-once-more.wav" media.name = "yesterday-once-more.wav" stream.is-live = "true" node.want-driver = "true" node.autoconnect = "true" media.class = "Stream/Output/Audio" remote 0 is named "pipewire-0" stream state changed connecting -> paused stream param change: Spa:Enum:ParamId:Props stream param change: Spa:Enum:ParamId:Latency stream param change: Spa:Enum:ParamId:Latency stream param change: Spa:Enum:ParamId:Format stream state changed paused -> streaming stream set volume to 1.000 -success stream node 88 stream time: now:0 rate:1/48000 ticks:0 delay:9248 queued:0 buffered:0 buffers:0 avail:2 size:0 stream time: now:4821374572568 rate:1/48000 ticks:49152 delay:9248 queued:1882 buffered:32 buffers:1 avail:1 size:1882 stream time: now:4822355905886 rate:1/48000 ticks:96256 delay:9248 queued:1882 buffered:32 buffers:1 avail:1 size:1882 stream time: now:4823379905870 rate:1/48000 ticks:145408 delay:9248 queued:1881 buffered:32 buffers:1 avail:1 size:1881 Finished By Christine.Li Jul 22th,2026.
記事全体を表示
The clock tolerance for CAN FD at high baud rates is generally considered to be tight compared to lower baud rates, meaning that the clock frequency needs to be very precise to ensure reliable communication; this is due to the high data rate requiring precise bit timing. CAN generally requires crystal or PLL clock source due to accuracy requirements, on KW45/7 that is limited to 32 MHz crystal (SOSC) since there is no PLL available. However, the FRO192 (FIRC) can be fine trimmed to the SOSC crystal as reference, in a closed loop configuration. When operating in closed loop the FRO192 accuracy is +/-0.25%. The FRO192 when operating in open loop (default) will not be accurate enough for CAN-FD (+/-3%). Closed loop operation is enabled while SCG0→FIRCCSR[FIRCTRUP] = 1 and SCG0→FIRCCSR[FIRCTREN] =1. The auto trim continues as long as those bits are set (for example if change in temperature causes the FRO192clock frequency to drift). Once locked, only the fine trim bits would be updated on subsequent corrections. Refer to code snippet below for correct clock configuration: #include "clock_config.h" #include "fsl_clock.h" const scg_sosc_config_t g_scgSysOscConfig_BOARD_BootClockRUN = { .freq = 32000000U, /* System Oscillator frequency: 32000000Hz */ .monitorMode = kSCG_SysOscMonitorDisable, /* System OSC Clock Monitor is disabled */ .enableMode = kSCG_SoscEnable, /* System OSC Enable */ }; const scg_sys_clk_config_t g_sysClkConfig_BOARD_BootClockRUN = { .divSlow = (uint32_t)kSCG_SysClkDivBy4, /* Slow Clock Divider: divided by 4 */ .divBus = (uint32_t)kSCG_SysClkDivBy1, /* Bus Clock Divider: divided by 1 */ .divCore = (uint32_t)kSCG_SysClkDivBy1, /* Core Clock Divider: divided by 1 */ .src=(uint32_t)kSCG_SysClkSrcFirc, /* Fast IRC is selected as System Clock Source */ }; static const scg_firc_trim_config_t FircTrimConfig_BOARD_BootClockRUN = { .trimMode = kSCG_FircTrimUpdate, /* FIRC trim is enabled and trim value update is enabled */ .trimsrc=kSCG_FircTrimSrcSysOsc, /* Trim source is System OSC */ .trimDiv = 31U, /* Divided by 32 */ .trimCoar = 0U, /* Trim value, see Reference Manual for more information */ .trimFine = 0U, /* Trim value, see Reference Manual for more information */ }; const scg_firc_config_t g_scgFircConfig_BOARD_BootClockRUN = { .enableMode = kSCG_FircEnable, /* Fast IRC is enabled */ .range = kSCG_FircRange96M, /* 96 Mhz FIRC clock selected */ .trimConfig = &FircTrimConfig_BOARD_BootClockRUN, }; /* Unlock FIRC and SOSC control status registers */ CLOCK_UnlockFircControlStatusReg(); CLOCK_UnlockSysOscControlStatusReg(); /* Init FIRC */ CLOCK_CONFIG_FircSafeConfig(&g_scgFircConfig_BOARD_BootClockRUN); /* Set SCG to FIRC mode */ CLOCK_SetRunModeSysClkConfig(&g_sysClkConfig_BOARD_BootClockRUN); /* Wait for clock source switch finished */ do { CLOCK_GetCurSysClkConfig(&curConfig); } while (curConfig.src != g_sysClkConfig_BOARD_BootClockRUN.src); /* Initializes SOSC according to board configuration */ (void)CLOCK_InitSysOsc(&g_scgSysOscConfig_BOARD_BootClockRUN); /* Set the XTAL0 frequency based on board settings */ CLOCK_SetXtal0Freq(g_scgSysOscConfig_BOARD_BootClockRUN.freq); /* For 6 mbps baud rate requires FRO192M as FlexCAN source clock */ CLOCK_SetIpSrc(kCLOCK_Can0, kCLOCK_IpSrcFro192M); CLOCK_SetIpSrcDiv(kCLOCK_Can0, kSCG_SysClkDivBy1); The maximum supported baud rate for KW47 and MCXW72 devices is 6 Mbps. Although higher rates may be achievable on some SoCs, 6 Mbps is the highest baud rate supported by the device clock specifications.  For simplicity, the FlexCAN driver APIs can be used to configure the CAN FD baud rate, as shown in the following code snippet: #include "fsl_flexcan.h" #define EXAMPLE_CAN CAN0 #define USE_CANFD (1) #define RX_MESSAGE_BUFFER_NUM (0) #define TX_MESSAGE_BUFFER_NUM (1) #define BYTES_IN_MB kFLEXCAN_64BperMB /* For 6 Mbps use case. FRO192 must be selected as clock source */ #define EXAMPLE_CAN_CLK_FREQ CLOCK_GetFreq(kCLOCK_ScgFircClk) #define USE_IMPROVED_TIMING_CONFIG (1) flexcan_config_t flexcanConfig; /* Get FlexCAN module default Configuration. */ /* * flexcanConfig.clksrc=kFLEXCAN_ClkSrc0; * flexcanConfig.bitRate = 1000000U; * flexcanConfig.bitRateFD = 2000000U; * flexcanConfig.maxMbNum = 16; * flexcanConfig.enableLoopBack = false; * flexcanConfig.enableSelfWakeup = false; * flexcanConfig.enableIndividMask = false; * flexcanConfig.disableSelfReception = false; * flexcanConfig.enableListenOnlyMode = false; * flexcanConfig.enableDoze = false; */ FLEXCAN_GetDefaultConfig(&flexcanConfig); /* Manually override default CAN FD config to 1 Mbps for nominal rate and 6 Mbps for data rate */ flexcanConfig.bitRate = 1000000U; flexcanConfig.bitRateFD = 6000000U; #if (defined(USE_IMPROVED_TIMING_CONFIG) && USE_IMPROVED_TIMING_CONFIG) flexcan_timing_config_t timing_config; memset(&timing_config, 0, sizeof(flexcan_timing_config_t)); if (FLEXCAN_FDCalculateImprovedTimingValues(EXAMPLE_CAN, flexcanConfig.bitRate, flexcanConfig.bitRateFD, EXAMPLE_CAN_CLK_FREQ, &timing_config)) { /* Update the improved timing configuration*/ memcpy(&(flexcanConfig.timingConfig), &timing_config, sizeof(flexcan_timing_config_t)); } #endif FLEXCAN_FDInit(EXAMPLE_CAN, &flexcanConfig, EXAMPLE_CAN_CLK_FREQ, BYTES_IN_MB, true); Note: The maximum supported CAN baud rate for KW47 and MCXW72 devices is 2 Mbps. While higher rates may be achievable under certain conditions, operation above 2 Mbps is outside the supported specification and is not recommended for applications in the field. 
記事全体を表示
The LCD_PAR_S035 can be interfaced with the U-blox IRIS-W1 EVK using the 8080 8-bit parallel interface. Enabling this configuration requires a combination of GPIO routing, jumper wiring, and two resistor population changes on the EVK. The reason for this additional wiring is that the signals required by the LCD's 8080 interface are distributed across multiple expansion connectors on the EVK. Additionally, the CS (Chip Select) and DC (Data/Command) signals are not routed by default to the required GPIOs and must be reassigned through resistor rework. Without these modifications, the LCD controller cannot be properly controlled by the IRIS-W1 device when operating in 8080 parallel mode.   Signal Mapping The following GPIO assignments have been verified for operation with the LCD_PAR_S035:   GPIO56 -> CS Available on J48 after removing R263 and populating R264 GPIO57 -> DC Available on J48 after removing R265 and populating R266 GPIO54 -> WR Available on J43 by default GPIO48 -> RD Available on J44 by default GPIO44 -> RST Available on J3 by default GPIO45 -> TE Available on J4 by default GPIO53 -> D7 Available on J43 by default GPIO52 -> D6 Available on J44 by default GPIO51 -> D5 Available on J43 by default GPIO49 -> D4 Available on J43 by default GPIO47 -> D3 Available on J43 by default GPIO46 -> D2 Available on J48 by default GPIO43 -> D1 Available on J4 by default GPIO42 -> D0 Available on J3 by default GPIO17 -> I2C_SCL Available on J47 by default GPIO16 -> I2C_SDA Available on J10 by default   Required Hardware Rework Two routing modifications are required to expose the LCD control signals through the desired GPIOs: CS Signal Routing:   Remove : R263 Populate : R264  DC Signal Routing: Remove : R265 Populate : R266   Populate:     Remove:   LCD Configuration The LCD module must be configured for 8080 8-bit parallel mode before power-up. The interface selection switch located on the back of the LCD_PAR_S035 should be set to: 110     Incorrect switch settings will prevent communication between the display controller and the IRIS-W1. Software Configuration After completing the hardware setup, any compatible LVGL example from the SDK can be used as a starting point. The selected project must use a flash configuration that matches the flash device populated on the target hardware. Reference flash configurations are available in the following repository: https://github.com/u-blox/u-blox-sho-OpenCPU/tree/master/MCUXpresso/IRIS-W1/sw_config/flash_config Reference Design Files Additional information regarding connector locations, GPIO routing, resistor options, and board-level implementation can be found in the EVK design package: https://github.com/u-blox/evk_designs_sho_altium/tree/main/EVK-IRIS-W10/Deliverables Summary Enabling the LCD_PAR_S035 on the U-blox IRIS-W1 EVK through the 8080 8-bit interface requires: Configuring the display for 8080 8-bit mode (switch setting 110 ). Reworking resistor populations for CS and DC routing. Connecting the LCD control and data signals according to the GPIO mapping listed above. Selecting the appropriate flash configuration for the target hardware. Using an LVGL-based application to validate display operation. This configuration provides direct access to the LCD through the parallel interface and serves as a useful reference for graphics evaluations and GUI development on the IRIS-W1 platform. Results:  
記事全体を表示
In this lab, we'll learn how to access Application Code Hub directly from Visual Studio Code, download a RTP USB Camera Stream over WiFi (FRDM‑MCXN947 + IW610), and run it on the FRDM-MCXN947 using IW610G-M2 + FRDM-ADPT-MCX-M2 to add Wi-Fi capabilities and USB camera to video stream. Hardware Requirements: FRDM-MCXN947 FRDM-ADPT-MCX-M2 IW610G-M2 Logitech C920 HD Pro WebCam Type C USB Cable Software Requirements: IDE: Visual Studio Code 1.130 or later SDK: V26.06.00 LTS VLC  RTP USB Camera Stream over Wi-Fi lab guide Community Support If you have questions regarding this training, please leave your comments in our MCU Community! here 
記事全体を表示
This document takes i.MXRT 1060 evkc and iw610 M.2 module as example to share how to setup manufactory mode in i.MXRT platform for NXP wifi product.  Hardware Host platform: i.MXRT 1060 evkc Wi-Fi chip: iw610 M.2 evk Software RT1060EVKC SDK 25.12.00 MFG TOOL: MFG-SD-IW610-MF-LABTOOL-Native-BRG-WIN-X86-2.0.0.39.0-18.80.5.p77
記事全体を表示
To generate a hello world (suppose) example for KW47-EVK for IAR toolchain. We asume that IAR toolchain is already installed. Set IAR_DIR environment variable. In Windows, this can be done via Edit environment variables system option. Example: IAR_DIR=C:\iar\ewarm-9.60.1.    Note: IAR toolchain version may change. Type the following commands on your MCUXSDK workspace: cd mcuxsdk west build -b kw47evk ./examples/demos_apps/hello_world --toolchain=iar -t standalone_project -Dcore_id=cm33_core0 --pristine -d ./build/kw47evk/kw47evk_standalone_hello_world_iar​ IAR project should have been generated on  MCUXSDK_WS/mcuxsdk/build/kw47evk/kw47evk_standalone_hello_world_iar/iar directory. IAR project has .eww file extension.     Relevant links IDE Project Generation: https://mcuxpresso.nxp.com/mcuxsdk/latest/html/develop/build_system/IDE_Project.html# Note: Ruby is required for this feature. Typically, this tool is installed via MCUXpresso Installer. However, if having issues with this tool refer to the next link: Ruby Environment Setup: https://mcuxpresso.nxp.com/mcuxsdk/latest/html/develop/build_system/IDE_Project.html#ruby-environment-setup Suppose you want to generate a hello world example for KW47-EVK for IAR toolchain as the previous example, but this time LPTMR driver is required for low-power timer operating purposes. We asume that IAR toolchain is already installed and IAR_DIR variable is already set. The easiest way to accomplish this is to add the lptmr Kconfig symbols with ‘yes’ value at Board-Application level (Refer to Kconfig User Guide). In this case, the target prj.conf file is located on  MCUXSDK_WS/mcuxsdk/examples/_boards/kw47evk/demo_apps/hello_world.​ Edit this file and add the LPTMR required symbols:  CONFIG_MCUX_COMPONENT_driver.lptmr=y CONFIG_MCUX_COMPONENT_component.lptmr_adapter=y​       Type the following command on your MCUXSDK workspace:  west build -b kw47evk ./examples/demo_apps/hello_world --toolchain=iar -t standalone_project -Dcore_id=cm33_core0 --pristine -d ./build/kw47evk/kw47evk_standalone_hello_world_iar IAR project should have been generated on MCUXSDK_WS/mcuxsdk/build/kw47evk/kw47evk_standalone_hello_world_iar/iar directory. IAR project has .eww file extension. This time LPTMR drivers should be included in iar/drivers/lptmr          
記事全体を表示
When performing Bluetooth LE RF testing on KW47 and MCXW72 devices, it may be necessary to configure the transmitter output power through a vendor-specific HCI command. NXP's Test Tool provides a convenient way to send HCI commands during Direct Test Mode (DTM) validation and characterization. Although the Test Tool is still commonly referenced in documentation and application workflows, it is no longer actively maintained. As a result, the default HCI command XML definitions included with the tool do not correctly support the vendor-specific Tx power command required by KW47 and MCXW72 devices. The default Test Tool XML does not correctly define the vendor-specific HCI_VENDOR_CONFIG_TX_POWER command for KW47 and MCXW72 devices. As a result, the command is not available in the GUI. Edit BLE HCI 5.0 1.6.1.xml (typically located in C:\nxp\Test Tool 12.9.2.2\Xml) and replace the command definition with the XML snippet provided in this article. Alternatively, replace the original XML file with the updated file attached to this article. <Vendor_Commands> <GroupDesc>Vendor_Commands</GroupDesc> <Cmd> <CmdName>HCI_VENDOR_CONFIG_TX_POWER</CmdName> <CmdDesc>HCI_VENDOR_CONFIG_TX_POWER Desc. OgB: FD OcB: 2D </CmdDesc> <CmdSync>01</CmdSync> <CmdHeader>3F 012D</CmdHeader> <CmdParms> <Parm> <ParmName>tx_power</ParmName> <ParmDesc>tx_power Desc</ParmDesc> <ParmSize>1</ParmSize> <ParmType>tInt</ParmType> <ParmLastValue>00</ParmLastValue> <ParmDefaultValue>00</ParmDefaultValue> </Parm> <Parm> <ParmName>Channel</ParmName> <ParmDesc>type Desc</ParmDesc> <ParmSize>1</ParmSize> <ParmType>tInt</ParmType> <ParmLastValue>00</ParmLastValue> <ParmDefaultValue>00</ParmDefaultValue> </Parm> <Parm> <ParmName>NotUsed</ParmName> <ParmDesc>Not Used</ParmDesc> <ParmSize>2</ParmSize> <ParmType>tInt</ParmType> <ParmLastValue>00</ParmLastValue> <ParmDefaultValue>00</ParmDefaultValue> </Parm> </CmdParms> </Cmd> </Vendor_Commands>​ After updating the XML file and restarting Test Tool, HCI_VENDOR_CONFIG_TX_POWER should appear in the GUI. HCI_VENDOR_CONFIG_TX_POWER command parameters: tx_power[1]: Supported values are 0x00 (0 dBm), 0x07 (7 dBm), and 0x0A (10 dBm). Channel[1]: Supported values are 0x00 (applies to advertising channels) and 0x01 (applies to non-advertising channels). NotUsed[2]: Reserved parameter. Always set this field to 0x0000.
記事全体を表示
  Background PN7160 / PN7220 are external NFC front-end controllers provided by NXP, designed for deep integration with the Android OS. They are widely used in Android-based non-mobile devices such as digital signage, self-service terminals, access control and attendance systems, in-vehicle systems, and industrial control equipment. Unlike smartphone-class SoCs with integrated NFC, this solution o􀆯ers flexible antenna layout, high system customizability, and long-term stable operation, making it particularly suitable for fixed Android terminals in non-mobile scenarios. The PN7160 / PN7220 NFC solution consists not only of hardware but also NXP-provided Firmware (FW) and Android Middleware (MW), covering NFC protocol handling, RF management, and Android system integration. This complete hardware–software solution helps ensure consistency, stability, and maintainability of NFC functionality across di􀆯erent Android versions, especially for non-handheld Android devices such as advertising displays, access control systems, and kiosks. During Android OS upgrades, changes in system framework design and power management strategies may a􀆯ect NFC behavior and performance. At the same time, PN7160 / PN7220 firmware and middleware versions must remain compatible with the target Android version. Recent customer reports of NFC performance degradation and abnormal behavior in NFC Cockpit debugging are compatibility issues caused by changes in the Android OS, FW, and MW combinations, which can be improved through version alignment, configuration adjustment, and parameter optimization. This document summarizes the observed issues, root cause analysis, and solution approaches based on issue reproduction and test results, providing reference material for future technical support, troubleshooting, and system version evaluation. Test Environment - Android OS:Android 15 - NFC Reader IC:PN7220 / PN7160 - MW Version: NFC_AR_INFRA_001E_15.03.00 - FW Version:3.2.5(PN7220)/12.50.11(PN7160) - NFC Cockpit Version:NxpNfcCockpit_v8.3.0.0 Issue Description – Reduced NFC Communication Distance After Android OS Upgrade from 15 to 16 Recently, some customers reported a significant change in NFC read performance on Android devices using the PN7160 NFC controller when upgrading the Android OS from version 15 to version 16. Under Android 15, when operating in Reader Mode, the stable NFC card reading distance was approximately 4 cm. After upgrading to Android 16, with the hardware platform remaining completely identical (including NFC controller, antenna design, RF matching, and mechanical structure), the e􀆯ective reading distance was reduced to approximately 1.5 cm. The customer confirmed the following conditions:  NFC controller model: PN7160  Hardware revision unchanged  Antenna specifications and mounting position unchanged  Power supply, system structure, and peripheral components unchanged  The only difference is the Android OS version before and after the upgrade The issue manifests as a significant reduction in NFC read range, while basic NFC functionality remains operational. This is a performance-level regression, which impacts application scenarios requiring relatively long reading distances, such as digital signage and self-service kiosks. Issue Location and Root Cause Analysis The issue is related to the NFC front-end reader configuration on the Android platform and is not caused by hardware design. Based on the observed behavior, the issue points to an RF configuration change. By extracting and comparing the RF configuration files from Android 15 and Android 16 platforms, it was found that polling protocol parameters in the Android 16 RF configuration file were modified—specifically, certain receiver-related parameters were changed. These parameters changes resulted in reduced read sensitivity, leading to a shorter NFC communication distance. Solution Using the following ADB command to pull the NFC configuration file C:\Users\nxf920XX>adb pull vendor/etc/libnfc-nxp.conf Restore the parameters related to the polling protocol to their default RF values. The default RF values can be referenced from AN13218 – Annex 3. For the issue of reduced communication distance reported by customers, the specific parameters that need modification are shown in the original configuration screenshots:   After modification, push the updated configuration file back to the original path by using command C:\Users\nxf920XX>adb push libnfc-nxp.conf vendor/etc/ libnfc-nxp.conf . And then Reboot the device for the new configuration to take effect by using command C:\Users\nxf920xx>adb reboot. Issue Description – Cockpit Failure After Upgrading FW to Latest Version The latest NFC Cockpit version currently available is NxpNfcCockpit_v8.3.0.0. However, the firmware versions supported by this Cockpit release are not the latest Reader FW versions. When the NFC Reader firmware is upgraded to the latest version and then connected to NFC Cockpit, a version mismatch error occurs, as shown in the original error screenshot. Once this error appears, all NFC Cockpit functions become unavailable or severely limited, greatly reducing debugging efficiency. Solution  Navigate to the NFC Cockpit installation directory, for example: C:\nxp\NxpNfcCockpit_v8.3.0.0\cfg  Open the file NxpNfcCockpit_Configuration.  Modify the default Reader firmware version in the configuration file to match the latest firmware version used on the Reader.  Save the file.    Reboot the device to apply the new configuration. For PN7220, use: C:\Users\nxf920xx>adb reboot . Verification Result After modifying the configuration file and restarting NFC Cockpit, all NFC Cockpit functions were verified to be fully operational again, as shown in the verification screenshot.   Recommendations  NFC performance degradation after Android OS upgrade primarily a􀆯ects PN7160-based platforms.  NFC Cockpit malfunction after firmware upgrade a􀆯ects all Reader products that support NFC Cockpit. When customers encounter the issues described above, it is recommended to follow the configuration adjustments outlined in this document.  
記事全体を表示
In this lab, we'll learn how to access Application Code Hub directly from Visual Studio Code, download a https-wifi-server-temperature-monitor-demo, and run it on the FRDM-MCXN947 using IW610G-M2 + FRDM-ADPT-MCX-M2 to add WiFi capabilities. Hardware Requirements: FRDM-MCXN947 FRDM-ADPT-MCX-M2 IW610G-M2 Type C USB Cable Software Requirements: IDE: Visual Studio Code 1.130 or later SDK: V26.06.00 LTS Wi-Fi Server Temperature Monitor Lab Guide Community Support If you have questions regarding this training, please leave your comments in our MCU Community! here 
記事全体を表示
  Welcome to IW610 M.2 and FRDM Adapter Product Training! This page provides access to training materials, presentations, demos, recordings, and supporting resources related to the IW610 M.2 development card and the FRDM adapter. While live Q&A support will be available during the training period, all content will remain accessible for future reference and self-paced learning.  Instructions  To get started with the IW610 M.2 and FRDM Adapter training, you will need to have your FRDM-MCXN947, IW610G-M2 and FRDM Adapter board in hand and perform the set-up operations according to the IW610G-M2 and FRDM-ADPT-MCX-M2 Getting Started Page which is a pre-requisite.   Step 1. Mandatory pre-work before starting with the labs:  Getting Started with IW610G-M2 Getting Started with FRDM-ADPT-MCX-M2 Step 2. After completing the pre-work, download the lab guides. Each lab has its own guide document and a video guide you can use as support material in case you have any question at any step:  Lab1: Wi-Fi Server Temperature Monitor Description This demo connects the IW610G-M2 to an FRDM-MCXN947 using an FRDM-M2-ADAPTER board and sends temperature measurements to an HTTPS server over Wi-Fi. Also creates an access point to enable connections. The online dashboard can also be used to wirelessly control the onboard LEDs. (End applications: home automation, industrial monitoring) Lab2: RTP USB Camera Stream over Wi-Fi Description This demo connects the IW610G-M2 to an FRDM-MCXN947 using an FRDM-M2-ADAPTER board and uses a camera module to stream real-time video over Wi-Fi to a laptop or another FRDM-MCXN947 with an IW610G-M2. The captured video is displayed on an LCD-PAR screen (In case to use a FRDM-MCXN947). (End application: Interphone, security camera) Step 3. Review the support material and useful links to get you up to speed with some product information, M.2 development card and FRDM adapter information and getting started. Below also includes additional reading material.   IW610 M2 Module | NXP Semiconductors Getting Started with IW610G-M2 | NXP Semiconductors https://nww.preview-cloud.nxp.com/pages/:FRDM-ADPT-MCX-M2 Getting Started with FRDM-ADPT-MCX-M2 | NXP Semiconductors Community Support If you have questions regarding this training, please leave your comments in our Wireless Community! here 
記事全体を表示
Background MIFARE Ultralight AES can implement AES authentication and Secure Messaging through a software encryption library or NXP SAM AV3. The software solution is less expensive, but the AES key needs to be stored in the MCU, posing a risk of key leakage. When using SAM AV3, the DataProtKey and Session Key are always stored internally in SAM, preventing the host from directly reading the keys. Furthermore, SAM's secure storage and attack resistance capabilities effectively enhance overall system security. Therefore, for applications requiring anti-cloning, anti-key leakage, or high-security standards, the SAM AV3 solution is recommended. Build Debugging Environment •NFC reader ICs: CLRD730 (2023) •FW versions: Pegoda 3: v07.06.01 •RFID Discover: V5.8.0.0 Preparation Device Pegoda 3, SAM AV3 and MIFARE Ultralight AES Pre-setting MIFAE Ultralight AES By default, MIFARE Ultralight AES does not require authentication. Therefore, some initial configuration is required before the authentication flow can be demonstrated. For example, the default value of AUTH0 is 0x3C, which means authentication protection is disabled for all user memory pages. To enable AES-based access protection, the AUTH0 value needs to be updated. In this example, AUTH0 is configured to 0x10, meaning: Pages 00h to 0Fh can be accessed without authentication. Pages 10h to 3Bh require successful AES authentication before access is granted. This configuration can be performed using Pegoda 3 and RFIDDiscover, as shown below: Next, we will use Pegoda 3 and RFIDDiscover to walk through a complete MIFARE SAM AV3 + MIFARE Ultralight AES workflow step by step, including personalization, key management, authentication, and accessing memory operations. Step 1 – Activate SAM AV3 Step 2 – Register key entry To support the CMAC-based secure messaging from MIFARE Ultralight AES, the secretkey to be used needs to be injected into the SAM AV3 symmetric keystore. This key canbe used either diversified or non-diversified. The session key that is generated during the 3-pass mutual authentication is stored then in one of the 4 available RAM key entries.MIFARE Ultralight AES needs an AES-128 key of key class "OfflineCrypto". Note: A key of key class "PICC" will not work, as the secure messaging used in MIFARE UltralightAES is not natively implemented in MIFARE SAM AV3. Therefore, we need to register two keys in SAM AV3. Register OfflineCrypto keyEntry:   Step 3 – Activate OfflineCrypto keys can be used directly to compute cryptographic functions, such as encrypting, decrypting, generating, and verifying MAC/CMAC—just like using general cryptographic tools. However, the key must be activated before use.   Step 4 – Switching MIFARE Ultralight AES Table Using the AES key securely stored in the SAM AV3 to perform MIFARE Ultralight AES authentication. Once the authentication is completed successfully, access to the protected memory area is granted. In this example, since AUTH0 is configured to 0x10, all pages from 0x10 to 0x3B can subsequently be read from and written to. Step 5 – Change Key Update the DataProKey under an authenticated session, like below: Verify the new key, back to step 3. References 1. Data sheet – Data sheet of MIFARE SAM AV3, doc nr. 3235xx. 2. Application note – AN5212 – MIFARE SAM AV3 – Key Management and Personalization, document nr. 5212xx. 3. AN12694_MIFARE SAM AV3 – For MIFARE Ultralight AES, MIFARE Ultralight C and MIFARE Ultralight EV1
記事全体を表示
Background The EX10 example provided in the NFC Reader Library is designed specifically for read and write operations on MIFARE DESFire EVx series cards. It supports application and file creation (AID/FID), authentication, and data read/write operations. After upgrading the NFC Reader Library to a newer version, it was observed that the EX10 example works correctly only with DESFire EV2 and EV3 cards. When using DESFire EV1 cards, read/write operations fail, regardless of whether DES or AES-128 encryption is selected. According to official documentation, DESFire EV1 cards support both DES and AES-128 encryption algorithms, so card capability limitations can be ruled out. Based on functional verification and issue reproduction using the updated NFC Reader Library, abnormal behavior of the EX10 example was confirmed when accessing MIFARE DESFire EV1 cards. This document summarizes the observed issue, root cause analysis, and final solutions based on test results, and serves as a reference for future technical support, troubleshooting, and version evaluation. Test Environment  Software reference design: NFC Reader Library → EX10  NFC reader ICs: PN5180 / PN5190 / RC663 / PN7462  NFC Reader Library versions: v7.10 / v7.13  Card types: MIFARE DESFire EV1 / EV2 / EV3  Authentication algorithms: DES / AES Issue Description – MIFARE DESFireEV1 DES Key When running the EX10 example and selecting option 1, the EV1 card can be successfully detected and authenticated. Application and file creation are also successful. However, the operation fails during the Read Data phase. Issue Description – MIFARE DESFireEV1 DES Key When running the EX10 example and selecting option 1, the EV1 card can be successfully detected and authenticated. Application and file creation are also successful. However, the operation fails during the Read Data phase. During online step by step debugging, the failure was traced to the ReadData() and WriteData() functions. Issue Analysis and Root Cause The issue occurs only with DESFire EV1 cards; EV2 and EV3 behave normally. The behavior is independent of reader IC type and library version. In the updated DESFire examples, the read/write data commands were changed. Specifically, command parameter byte 0x01 controls the chaining mode.   When this parameter is set, the command used is: PHAL_MFDFEVX_CMD_READ_DATA_ISO(0xAD) However, DESFire EV1 does not support ISO chaining. Instead, it requires the following command: PHAL_MFDFEVX_CMD_READ_DATA (0xBD) Solution and Verification Solution:Modify the command parameter in the read/write functions by changing the command byte from 0x01 to 0x00. After this modification, the EX10 example runs correctly on MIFARE DESFire EV1 cards, and the read/write issue is fully resolved. Like the below:     Verification Result: Issue Description – MIFARE DESFireEV1 AES Key Although the above modification resolves the read/write issue when using DES keys, failures still occur when using AES keys. Detail errors as below: Through step-by-step debugging, the failure was traced to calls to CreateTMACFile() and CommitTransaction(). According to NXP Application Note AN12889, MIFARE DESFire EV1 does not support the CreateTMACFile command. Additionally, the EX10 example creates a standard application, not a TMAC-enabled one. Solution and Verification Solution:Comment out the calls to CreateTMACFile () and CommitTransaction() in the EX10 example. After this change, AES-128 key authentication and read/write operations on MIFARE DESFire EV1 cards work correctly.。 Modification as the below: Verification Result Test results confirm that AES authentication and data operations succeed after applying the above modification. Recommendation These issues were introduced when the NFC Reader Library was updated from v07.09.00 to v07.10.00. Currently available versions start from v07.10.00, so customers using any released version may encounter this problem. It is recommended that customers apply the modifications described above when working with MIFARE DESFire EV1 cards.
記事全体を表示
  Background OfflineChangeKey is a secure key management mechanism in SAM AV3 that allows a KeyEntry to be updated without exposing the new key value to the host MCU. It is typically used for personalization, key rotation, remote field updates, and other high-security applications where keys must remain protected inside the SAM. OfflineChange Key can only be of type AES-128, AES-192 or AES-256. Some usage scenarios of OfflineChange Key are as follows: Using in “SAM_ChangeKeyEntry” command and “SAM_ChangeKUCEntry” command to: ➢Update the key entries offline. The update of a key entry in offline is only possible if the KeyNoCEK of that key entry is OfflineChange key. ➢Update key usage counter offline. The update of a key usage counter is offline only possible if the KeyNoCKUC of that RefNoKUC is OfflineChange key. The offline update of a key entry is only possible if the KeyNoCEK of that key entry is an OfflineChange key. Build Debugging Environment •Software reference design: NfcrdlibEx7_MIFAREPlus and SAM AV3 X-mode Project •NFC reader ICs: RC663 / PN7642 •NFC Reader Library versions: NxpNfcRdLib_v7.16 •NXP Reader Library versions: NxpRdLib_v17.1.0.2535 Issue Description – A Key entry will be changed using an OfflineChangeKey key entry NXP's MIFARE SAM AV3 comes with a default key and configuration. Before applying it to actual projects, users typically need to complete two configuration phases: pre-personalization and personalization. Pre-personalization Define and Register two KeyEntries, one is KeyEntry 0x11 with keyclass PICC and the other is KeyEntry 0x10 with OfflineChangeKey. And the KeyNoCEK of KeyEntry 0x11 is KeyEntry 0x10. Define KeyEntry 0x10 = Define KeyEntry 0x11= If you are developing on an MCU platform, the NXP Reader Library provides the necessary APIs to perform the SAM AV3 personalization process, including creating and updating KeyEntry 0x10 and KeyEntry 0x11. Alternatively, the same operation can be performed using Pegoda 3 together with RFIDDiscover, which provides a convenient way to explore and validate the personalization flow without writing application code. As an example, the following screenshots demonstrate how to provision KeyEntry 0x10 using RFIDDiscover: Personalization Use the OfflineChangeKey procedure to perform a secure key update. Specifically, KeyEntry 0x10 is configured as the OfflineChangeKey (KeyNoCEK), and KeyEntry 0x11 is defined to reference this key. As a result, KeyEntry 0x11 can only be updated using a cryptogram generated with the OfflineChangeKey stored in KeyEntry 0x10. ➢ Set the New KeyEntry values to be written into KeyEntry 0x11= ➢ Concatenation the new value of Key Entry 0x11, which is called PlainKeyEntry[80] = AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 000000000000FF20000000000100FEFE 80000000000000000000000000000000 (padding 16bytes) ➢ Generate Kce and Kcm, both encrypted using Ks in AES-CBC mode. Here should be noted that, Inputs parameters: Ks is saved in key entry 0x10 in my example. And the value = 00000000000000000000000000000000 SV1: ChangeCtr || 14 bytes of 0x71 SV2: ChangeCtr || 14 bytes of 0x72 ChangeCtr: 0x0001 Outputs are: SV1: 00017171717171717171717171717171 SV2: 00017272727272727272727272727272 Kce: 91E868E9890A05B692E49ECBAE916289 (Ek (Ks, SV1)) Kcm: 4CCB0BC24405CC5CFA2E05F81812A181 (Ek (Ks, SV2)) Kce is to encrypt keyentry, and Kcm is to calculate the CMAC.     ➢ Encrypt PlainKeyEntry [80] with Kce under AES-CBC mode and output EncKeyEntry[80] = E78E4571BD8FBDBFD9A16E74F92E0921 2A4286925E6AF74CD650C12F0751A486 ECFAFABFA88FDD17C124250BCED89AE3 A479B21E7FD66D683696D2461D452EE2 F0D4FE0568F29226FC6C9CDA93AD44BD ➢ Calculate CMAC Input data: 80C111FF5A0001 (CLA, INS, P1, P2, Lc+10, change ctr) E78E4571BD8FBDBFD9A16E74F92E0921 (Encrypted KeyEntry) 2A4286925E6AF74CD650C12F0751A486 ECFAFABFA88FDD17C124250BCED89AE3 A479B21E7FD66D683696D2461D452EE2 F0D4FE0568F29226FC6C9CDA93AD44BD and calculated CMAC with Kcm, output is: 81C7931698390354968FED95B8A2FC14 And make MFP Truncate, finally output is CMAC_Truc[8] = C71639548F95A214 ➢ Activate offlinechankekey Enable the Offline Change mechanism and specify the corresponding OfflineChangeKey. This step is required so that the SAM can identify which key shall be used to authorize and process future offline key update operations. If you are developing on an MCU platform, the same configuration can be performed programmatically using the APIs provided by the NXP Reader Library. Alternatively, you can use Pegoda 3 and RFIDDiscover to perform the same configuration without developing MCU application code, as shown below: ➢ Update KeyEntry 0x11 using OfflineChangeKey If you are developing on an MCU platform, which can be implemented using the APIs provided by the NXP Reader Library. And need to note that the key parameter: uint8_t * pOfflineCrypto = EncKeyEntry[80] + OfflineMAC[8] EncKeyEntry[80] = EncKeyEntry [80] OfflineMAC[8] = CMAC_Truc [8] At the same time, instead of implementing the configuration through MCU software, you can use Pegoda 3 and RFIDDiscover to perform and verify the same configuration interactively, as the below: References 1. Data sheet – Data sheet of MIFARE SAM AV3, doc nr. 3235xx. 2. Application note – AN5212 – MIFARE SAM AV3 – Key Management and Personalization, document nr. 5212xx.
記事全体を表示
1. Introduction  In this article I'm going to explain how the FRDM-RW612 SDK (v26.06) configures the external NOR flash of the FRDM-RW612. And give a brief explanation on how the memory parameters from the flash datasheet are mapped into the SDK structures (FCB, LUT). It focuses on software-level configuration, including: FCB LUT Relevant SDK files   2. Overview of the RW612 External Flash System This section explains how the RW612 interacts with the external NOR flash (W25Q512JV) at boot and runtime. The RW61x supports a FlexSPI memory size up to 1 Gbit. The RW61x supports all JESD216-compliant flash memories. Refer to Table 15 of the RW61x Design Guide to see the recommended memories.  2.1 Flash Configuration Block (FCB) When the RW612 is powered on, the Boot ROM is the first piece of code that is executed. To access the external flash, the Boot ROM reads a data structure stored at a fixed offset in flash called the Flash Configuration Block. The FCB tells the Boot ROM:   what flash protocol to use (i.e. single, dual, quad) what read opcode to send how many dummy cycles are needed which LUT sequence defines the read operation In the SDK, this is defined though specific FCB fields like lookupTable, lutCustomSeq, deviceModeCfgEnable, etc. The meaning of the fields of the FCB can be found in section 11.4.1.1 of the RW61x User Manual. The RW61x ROM can initialize the FlexSPI in two ways: 1. FCB from external flash: If FLEXSPI_AUTO_PROBE_EN is 0, the Boot ROM looks for an FCB in the external flash. It reads the 512 byte FCB into on-chip SRAM and configures the FlexSPI controller according to that structure. 2. Flash auto-probe: If FLEXSPI_AUTO_PROBE_EN is 1 , the Boot ROM performs a flash auto probe sequence using OTP fuse parameters such as FLEXSPI_PROBE_TYPE  FLEXSPI_FLASH_TYPE, FLEXSPI_DUMMY_CYCLES , and FLEXSPI_FREQUENCY. Refer to section 11.4 of the RW61x User Manual for more information. Each FlexSPI NOR flash driver API depends on a common fc_flexspi_nor_config_t parameter to perform the proper operation. The structure can be found in flash_config.c . This is the FCB in the code.     2.2 Lookup Table (LUT)   The FlexSPI LUT contains the encoded command sequences the FlexSPI uses to communicate with the external flash. The RW61x LUT contains 16 command sequences, and each sequence consists up to 8 instructions. These define: the command opcode the number of pads the address phase dummy cycles mode bits read/write operations the stop instruction   In other words, the FCB is the configuration used by the Boot ROM. And the LUT are the sequences used by the FlexSPI controller during both boot and runtime. The FCB contains the LUT. The SDK defines these sequences using the macro FC_FLEXSPI_LUT_SEQ() inside flash_config.c . For example, the default “Fast Read Quad I/O” sequence on the FRDM‑RW612 for the W25Q512JV flash memory includes: a command opcode (0xEC) an address phase using 4 pads a mode byte (0xF0) dummy cycles (0x04) the read operation using 4 pads Each flash vendor uses its own set of opcodes, timing requirements, and dummy cycles. Therefore, when adapting the RW612 SDK to work with a different flash, customers will need to update the LUT entries in flash_config.c . However, the changes are not limited to the LUT, since other parameters such as pad configuration, clock settings, and device mode may also need to be adjusted. The LUT is essential not only for IP commands but also for XIP, where FlexSPI uses a single LUT sequence (selected by ARDSeqIndex and ARDSeqNumber ) to perform every AHB read. The following is recommended to check when using a custom flash: sflashPadType serialClkFreq sflashA1Size page size /sector size read opcode address width: 24 bit vs 32 bit dummy cycles Quad Enable status register BUSY bit write enable command page program opcode sector/block erase opcode sample clock / DQS configuration For more detailed information refer to section 34.2.6 of the RW61x User Manual. 2.3 From the Memory Datasheet to the SDK Configuring the external flash on the RW612 is essentially a translation process: you extract details from the flash datasheet, and encode them into the SDK’s FCB and LUT. This section explains exactly which datasheet parameters matter, where each one appears in the SDK, and how the SDK structures correspond to the flash device’s command set. Example: Datasheet SDK Flash size sflashA1Size Supported I/O mode: 1-1-1, 1-1-4, 4-4-4 sflashPadType Fast read opcode LUT read sequence Dummy cycles LUT DUMMY_SDR operand Mode bits required by the read command LUT MODE8_SDR operand inside the read sequence Quad Enable bit / flash configuration register write deviceModeCfgEnable , deviceModeSeq , deviceModeArg , plus matching LUT sequence   Datasheet Parameter → FCB Fields The flash datasheet defines the electrical and protocol characteristics that the Boot ROM must use to perform the very first read command (XIP). These values map directly into the FCB ( fc_flexspi_nor_config_t ) found in flash_config.c .  a) Pad configuration (Single / Dual / Quad) Datasheet: specifies which bus modes (1‑1‑1, 1‑1‑4, 4‑4‑4…) the device supports. SDK mapping:  .sflashPadType = kSerialFlash_4Pads; This configures how FlexSPI drives the CMD/ADDR/DATA pads.   b) Read frequency Datasheet: supports up to 133MHz SDK mapping: .serialClkFreq = 5;  (Refer to Table 65 of the RW61x User Manual) The value must be chosen so that the final FlexSPI clock does not exceed the flash’s read timing limits. c) Dummy cycles for fast‑read Datasheet: fast‑read commands require N dummy cycles depending on frequency. SDK mapping: encoded directly in LUT using:  [1] = FC_FLEXSPI_LUT_SEQ(MODE8_SDR, 4PAD, 0xF0, DUMMY_SDR, 4PAD, 0x04),​ Here the last operand ( 0x04 ) is the dummy-cycle count. In this example, 0xF0 is the mode byte transmitted during the read command. It is not the same as the Quad Enable configuration. QE is handled separately through the device mode sequence. d) Quad-enable (QE)  Datasheet: describes how to enable Quad I/O (usually by writing SR1/SR2), or how to enter 4‑byte mode. SDK mapping: The FCB “device mode sequence,”: .deviceModeCfgEnable = 1, .deviceModeSeq = {.seqNum = 1, .seqId = 2}, .deviceModeArg = 0x02,​ This instructs the Boot ROM to execute an LUT sequence at boot to configure QE. e) Flash size Datasheet: total memory capacity. SDK mapping:  .sflashA1Size = 0x4000000U; // 64 MB     Datasheet Parameter → LUT Commands The flash datasheet defines opcodes and sequences for: Fast-read Read-status Write-enable Page program Sector erase These map to FlexSPI LUT entries inside lookupTable  in flash_config.c . Example of a Quad I/O fast read: [0] = FC_FLEXSPI_LUT_SEQ(FC_CMD_SDR, FC_FLEXSPI_1PAD, 0xEC, FC_RADDR_SDR, FC_FLEXSPI_4PAD, 0x20), [1] = FC_FLEXSPI_LUT_SEQ(FC_MODE8_SDR, FC_FLEXSPI_4PAD, 0xF0, FC_DUMMY_SDR, FC_FLEXSPI_4PAD, 0x04), [2] = FC_FLEXSPI_LUT_SEQ(FC_READ_SDR, FC_FLEXSPI_4PAD, 0x04, FC_STOP_EXE, FC_FLEXSPI_1PAD, 0x00), Every element (opcode, pads, address phase, dummy, mode byte) comes directly from the datasheet’s command table.   Decoding the LUT: [0] = FC_FLEXSPI_LUT_SEQ(FC_CMD_SDR, FC_FLEXSPI_1PAD, 0xEC, FC_RADDR_SDR, FC_FLEXSPI_4PAD, 0x20) FC_FLEXSPI_LUT_SEQ(...) packs two LUT instructions into one 32 bit word: (cmd0, pad0, op0) and (cmd1, pad1, op1).  FC_CMD_SDR: Transmit command code to flash in SDR mode Why LUT entries in flash_config.c Use “[4 * index + Offset]” Why does flash_config.c write LUT entries using expressions like [4 * index + 0] , [4 * index + 1] , etc? Each LUT sequence ID occupies 4 × 32-bit LUT words , and each 32-bit LUT word packs two 16-bit FlexSPI instructions , so one sequence can contain up to 8 instructions .   [4 * index + 0] [4 * index + 1] [4 * index + 2] [4 * index + 3] Inside FlexSPI: A sequence ID represents one full command operation (e.g., fast-read). Each sequence index reserves four 32-bit LUT words, which together encode up to eight 16 bit LUT instructions. Each instruction takes one LUT entry. Therefore, each sequence uses a block of 4 LUT slots: seqId 0 → entries 0,1,2,3 seqId 1 → entries 4,5,6,7 seqId 2 → entries 8,9,10,11 This indexing scheme is required by the hardware.       2.4 FlexSPI Access Types The RW612 uses two distinct access paths to the external flash: AHB Path (XIP / Read‑Only) Once the Boot ROM configures FlexSPI using the FCB, the controller maps the external flash into the AHB address space. Instruction fetches, constant data reads, and general code execution occur directly from flash (Execute‑In‑Place). Uses only the read LUT sequence (usually the fast‑read command). Cannot perform program/erase. Depends entirely on the correctness of the FCB + LUT. IP Command Path (Program / Erase / Status Read) This path is used for explicit command‑based transactions. The SDK’s mflash_drv.c uses this mode to implement: Write Enable Page Program Sector Erase Read Status (BUSY polling) Program/erase operations require: correct LUT sequences correct WREN opcode correct erase opcode correct busy‑bit polarity and offset Customers replacing the flash must update these sequences in the LUT and, if needed, adjust the busy‑bit handling in mflash_drv.c .   2.5 External Flash on the FRDM‑RW612 The FRDM‑RW612 comes with a QuadSPI NOR flash connected to FlexSPI Port A1. The default configuration in the SDK sets: Quad‑pad mode ( sflashPadType = 4 ) Fast‑read Quad I/O opcode ( 0xEC ) Mode byte and dummy cycles for this device Sector size and page size  LUT entries for read, status, write‑enable, page‑program, and erase This configuration is a reference template showing how the flash’s datasheet values are encoded into the FCB and LUT.   HW setup for the W25Q512JV memory  The W25Q512JV NOR flash is connected to Port A (GPIO28 to GPIO34) of the FlexSPI module of the RW612. See the below snapshot from the FRDM-RW612 Schematics Rev1. The table below shows the RW612 FlexSPI pinout. On the FRDM-RW612 board, the external NOR flash is connected to the FlexSPI Port A signals used by the board design RW612 pin QSPI function GPIO_28 FLASH_SSEL0 GPIO_29 FLASH_DQS GPIO_30 FLASH_DATA0 GPIO_31 FLASH_DATA1 GPIO_32 FLASH_DATA2 GPIO_33 FLASH_DATA3 GPIO_34 FLASH_CLK0   2.6 Key SDK Files for the External Flash Configuration The RW612 SDK includes several software components that together define how the external flash is initialized, accessed, and programmed. Customers adapting the SDK to a different flash device will primarily interact with the following files: flash_config.c Contains the FCB used by the Boot ROM, including: FlexSPI timing configuration pad mode (single/dual/quad) serial clock settings device‑mode configuration (e.g., QE or 4‑byte mode) the boot‑time LUT used for fast‑read and basic flash commands flash_config.h Defines: FCB data structures ( fc_flexspi_nor_config_t ) macros used to encode FlexSPI LUT instructions command type definitions and constants mflash_drv.c / mflash_drv.h Implements the runtime flash driver using the IP command path, including: Write Enable Page Program Sector Erase Status register polling (BUSY bit) cache/buffer invalidation after programming These functions rely on LUT entries and must be updated if the flash device uses different opcodes or timing.   4. References RW61x User Manual RW612 datasheet RW61x Registers MCUXpresso SDK RW61x Design Guide
記事全体を表示