LPC Microcontrollers Knowledge Base

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC Microcontrollers Knowledge Base

Discussions

Sort by:
Hello Community! This document is provided as a hands-on lab guide.  The intent of the lab is to demonstrate how to program and use the LPC8N04 development board by using the LPC8N04 board support package demo application and make use of the read, write and energy harvesting capabilities of the NFC tag. Setup The following items are needed to complete the lab: Software: •    LPC8N04 Board Support Package MCUXpresso, can be downloaded at this link: https://www.nxp.com/downloads/en/lab-test-software/LPC8N04-MCUXpresso-BSP.zip •    MCUXpresso IDE version 10.2.1, can be installed from here: https://www.nxp.com/mcuxpresso/ide •    LPC8N04 NFC Demo Android application, can be installed at the link below: https://play.google.com/store/apps/details?id=com.nxp.lpc8nxxnfcdemo   Hardware: •    LPC8N04 Development Board for LPC8N04 MCU (OM40002): https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/lpc-cortex-m-mcus/lpc800-series-cortex-m0-plus-mcus/lpc8n04-development-board-for-lpc8n04-mcu:OM40002 •    Android Phone with NFC •    1 Micro USB cable   Hope this guide is helpful! Any comments are welcome.   Best Regards, Carlos Mendoza Technical Support Engineer
View full article
    Writing this post just want to remind the customer of RAM allocation when use the on-chip CAN drivers in LPC11C24. Otherwise, when meet the abnormal issues, it is difficult to locate the root reason and it also causes a waste of time.      Now, take a real customer question as an example, to highlight the RAM allocation importance when using the on-chip CAN API in LPC11C24. Problem description     Customer used the LPC11C24 on-chip CAN API to realize the CAN frames sending and receiving, the CAN code was from the official lpcopen, and it worked OK when he just used the CAN code. But when customer added the UART code, they found the code always enter hardfault after a short time running. They test the UART code which without the CAN code directly, the UART code worked perfectly. It means, independent UART code and independent CAN code are all working normally, but when combine the UART and on-chip CAN code together, the code will enter hardfault. Problem analysis From the Cortex M0 devices generic user guide, we can get the information about the hard fault:     Faults are a subset of exceptions, see Exception model. All faults result in the HardFault exception being taken or cause lockup if they occur in the NMI or HardFault handler. The faults are:      execution of an SVC instruction at a priority equal or higher than SVCall      execution of a BKPT instruction without a debugger attached      a system-generated bus error on a load or store      execution of an instruction from an XN memory address      execution of an instruction from a location for which the system generates a bus fault      a system-generated bus error on a vector fetch      execution of an Undefined instruction      execution of an instruction when not in Thumb-State as a result of the T-bit being previously cleared to 0      an attempted load or store to an unaligned address Now we debug the problem project to check, which detail code line caused this hardfault problem. When the code enters the hardfault handler, check the MSP address in the flash, then find the LR register, which will link to the code before entering in the hardfault handler, the following are the according debug result:   The LR register is 0X1FFF2C1F, it means before enter in hardfault handler, the code runs to this address code. Now, check the 0X1FFF2C1F in the memory map.    We can find the address is in the ROM area, because we just use the ROM CAN driver, UART is just the pure register control code, then we can get the problem still relate to the on-chip CAN driver, not the UART code. But we can’t see or debug the detail ROM CAN driver directly, we still can’t find the root problem.    Even we know the problem is not caused by the UART, but another important clue which relates to the UART function also influence the test result after I do a lot of testing. In the customer code, he defines the UART user transmit and receive buffer like this: #define UART_SRB_SIZE 128    // Send #define UART_RRB_SIZE 32    // Receive /* Transmit and receive buffers */ static uint8_t rxbuff[UART_RRB_SIZE], txbuff[UART_SRB_SIZE];   On one occasion, I tried changing #define UART_SRB_SIZE 128 To  #define UART_SRB_SIZE 32 Just minimize the txbuff size, I found the code won’t enter in the hardfault handler any more. It seems very strange and contradiction with the hardfault handler enter point which is test before.    I also check the generated code size, the used RAM and flash size is:   text       data        bss        dec        hex    filename    7672          0        244       7916       1eec    pscan.axf LPC11C24 RAM is 8K, here just 244 Bytes, the stack also use the whole RAM, so the 8K RAM size should be enough to use.   In this situation, I check the project’s .map file about the txbuff with 128 and 32 respectively.    1)txbuff with 128Bytes Rxbuff and txbuff occupy the RAM address from 0X10000048 to 0X100000E8.     2)txbuff with 32Bytes Rxbuff and txbuff occupy the RAM address from 0X10000048 to 0X10000088. We can find the txbuff start address is the same, just the end address has difference.    With these information, we checked the LPC11C24 user manual chapter C_CAN on-chip drivers again, we found a significant description:      0X10000050 to 0X100000B8 is used by the on-chip CAN API RAM, and from the issue project, memory map file, we can find rxbuff and txbuff RAM address is 0X10000048 to 0X100000E8, it already occupies the whole CAN API RAM, this is the key point. Minimize the txbuff, then rxbuff and txbuff occupy the RAM address from 0X10000048 to 0X10000088, this address doesn’t occupy the whole on chip CAN API RAM, in this situation, the problem doesn’t happen, I think the used CAN API may in the RAM address 0X10000089-0X100000B8.    Anyway, just minimize the buffer size can’t solve the problem from the root side. We must follow the user manual to keep the RAM address from 0x10000050 to 0x100000b8 won’t be used by any other application code.   Problem solutions      From the above chapter, we can find the root problem is the application code occupies the on-chip CAN RAM, to solve the problem, we need to modify the linker file, to prevent the usage of on-chip CAN RAM range.      Because the customer is using the LPCXPresso IDE, then we take this IDE as an example, to protect the RAM address 0x10000050 to 0x100000b8. From the above, we can get that the LPCX11C24 have 8Kbytes RAM, normally, customer will define it just in one, now we divide the RAM to two pieces. 1) RAM2: Location 0X10000000, size 0X100 2) RAM: Location 0X10000100, size 0X1F00 In the LPCXpresso, Project Properties -> C/C++ Build -> MCU settings, then modify it like this:     Then generate the code, and check the map file again.   RAM address from 0x10000000 to 0X10000FF is not used by any other application code. All the application code RAM is using from address 0x10000100. After long time testing, we find the hardfault problem never happens, on customer side, it also works OK. In conclusion, when customer want to use the on-chip CAN API, they need to protect the RAM address from 0x10000050 to 0x100000b8 in the linker file.    
View full article
#lpc‌ #dualcore‌ #feature‌ Attached doc is the LPC MCU Serial dual core feature introduction and application
View full article
This document explains how to start with LPCXpresso845-MAX Evaluation Board building, running and debugging example codes. Introduction   Based on the ARM Cortex-M0+ core, LPC84x is a low-cost, 32-bit MCU family operating at frequencies of up to 30 MHz. The LPC84x MCU family supports up to 64 KB of flash memory and 16 KB of SRAM. There is no LPCOpen nor SDK for LPC84x, however there is an example code bundles (register level) available for this family. The example code bundles offer a fastest, and simplest way for user to learn how to program each peripheral before progressing to more advance features of the peripheral. New users of LPC84x can step through the Example Code like a tutorial. Each project contains concise and accurate explanations in Readme files and comments in source files help the user to start/debug quickly. LPC845 Example Code Bundle is available for KEIL, MCUXpresso and IAR IDEs and you can download it from next link:   http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/lpc-cortex-m-mcus/lpc800-series-cortex-m0-plus-mcus/low-cost-microcontrollers-mcus-based-on-arm-cortex-m0-plus-cores:LPC84X?tab=Design_Tools_Tab Build, run and debug an example   This section describes the steps required to build, run, and debug an example application. 1. Download the LPC845 Example Code Bundle MCUXpresso from the next link:  http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/lpc-cortex-m-mcus/lpc800-series-cortex-m0-plus-mcus/low-cost-microcontrollers-mcus-based-on-arm-cortex-m0-plus-cores:LPC84X?tab=Design_Tools_Tab 2. Open MCUXpresso IDE. 3. Select "Import project(s) …" from the Quickstart Panel. 4. Click the "Browse" button and point to the LPC845-Example-Code-Bundle-MCUXpresso.zip, which should be downloaded previously, and then click “Next” button. 5. By default all the projects are selected, however you can select only the desired example project. In order to build the example project, it is necessary to add in the workspace the following projects: common peripherals_lib utilities_lib For this document, we are using the Multi_Timer_Blinky example project. 6. Build the project using the hammer icon on Quickstar Panel.  7. Connect the development platform to your PC via USB cable. If connecting for the first time, allow some seconds for the devices to enumerate.   8. This example runs from Flash. To run this code you have two options: a) Download and Debug.    b) Load to flash using the “run” IDE icon and press the reset button on the board. Note: It may be necessary to power-cycle the board in order to regain control of the reset button after programming. At this moment, you can be able to run or debug the example project. I hope this helps!!!
View full article
Note: This document provides a simple description, the details about flashloader can be found at Getting Started with LPC540xx Flashloader User's Guide.pdf which is located in SDK_2.5.0_LPCXpresso54S018\middleware\mcu-boot\doc   Download LPC54S0xx SDK.   Compile the flashloader project to generate flashloader.bin  The project is located in sdk\boards \lpcxpresso54s018\bootloader_examples\flashloader   Use dfu-util.exe or IDE to load flashloader.bin into RAM. dfu-util can be downloaded from http://dfu-util.sourceforge.net/releases/ Configure the ISP pins and then reset the chip to make the chip to enter USB1 DFU boot mode. Boot mode ISP2 PIO0_6 pin ISP1 PIO0_5 pin ISP0 PIO0_4 pin Description USB1 DFU boot LOW LOW HIGH USB DFU class is used to download image over the USB1 high-speed port into SRAM. Connect the LPC54S0xx device USB1 high-speed port and PC with USB. The following is the command line to load the flashloader.bin: $ dfu-util.exe –D flashloader.bin   Use blhost to program/erase LPC540xxM/LPC54S0xxM flash Once the flashloader binary is downloaded and starts its execution on the LPC54S0xx platform and there remains a physical USB connection between the LPC54S0xx platform USB1(High-Speed) and host, the flashloader will be ready to receive the commands. blhost -u 0x1fc9,0x01a2 -- get-property 12 blhost -u 0x1fc9,0x01a2 -- fill-memory 0x2000d000 4 0xc0000004 blhost -u 0x1fc9,0x01a2 -- configure-memory 0xa 0x2000d000 blhost -u 0x1fc9,0x01a2 -- get-property 25 0xa blhost -u 0x1fc9,0x01a2 -t 100000 -- flash-erase-region 0x10000000 0x100000 blhost -u 0x1fc9,0x01a2 -t 100000 -- write-memory 0x10000000 xxx.bin Note: xxx.bin is the target file which needs to be downloaded to the flash.   Author: Hao Liu  Thanks for Hao Liu.
View full article
SCTimer implement traffic signal Overview      The State Configurable Timer (SCTimer/PWM) is a peripheral that is unique to NXP Semiconductors. It can operate like most traditional timers, but also adds a state machine to give it a higher degree of configurability and control, in another word, the SCTimer/PWM can be considered as consist of Stand Timer and State/Event Logic (Fig 1). This allows the SCT to be configured as multiple PWMs, a PWM with dead-time control, and a PWM with reset capability, in addition to many other configurations that can’t be duplicated with traditional timers. Once the SCTimer/PWM has been configured, it can run autonomously from the microcontroller core, unless the SCTimer/PWM interrupt has been enabled which requires the core to service the interrupt. Fig 1       The first time you look at the SCTimer/PWM, it may appear to be a very complex peripheral, but you will see that it is actually not that difficult to use. Understanding the Event and State is critical to understanding the SCTimer/PWM.        Event:        The following conditions define possible events: a counter match condition, an input (or output) condition, a combination of a match and/or an input/output condition in a specified state, and the count direction. Events can control outputs, interrupts, DMA requests and the SCTimer/PWM states. They can also cause timer limit, halt, start, or stop conditions to occur.        State:         The state variable is the main feature that distinguishes the SCTimer/PWM from other counter/timer/PWM blocks. Events can be made to occur only in certain states. Events, in turn, can perform the following actions: a)    Set and clear outputs; b)   Limit, stop, and start the counter; c)    Cause interrupts; d)   Modify the state variable;         Regarding the event and state mechanism (Fig 2 show a basic example), The SCT allows the user to group and filter events, thereby selecting some events to be enabled together while others are disabled. A group of enabled and disabled events can be described as a state, and several states with different sets of enabled and disabled events are allowed. Changing from one state to another is event driven as well and can happen without software intervention. Formally, the SCTimer/PWM can be programmed as state machine generator. The ability to perform switching between groups of events provides the SCT the unique capability to be utilized as a highly complex State Machine engine. Events identify the occurrence of conditions that warrant state changes and determine the next state to move to. This provides an extremely powerful control tool - particularly when the SCT inputs and outputs are connected to other on-chip resources (comparators, ADC triggers, other timers etc.) in addition to general-purpose I/O. Fig 2 Traffic signal implementation             Fig 3 illustrates the application of the SCT to simulate the traffic signal. Fig 3 v Demo create         LPCOpen is an extensive collection of free software libraries (drivers and middleware) and example programs that enable developers to create multifunctional products based on LPC microcontrollers. In this article, I will illustrate the steps of creating a new demo in the LPCOpen, for instance, create a demo by using the IAR IDE. Since the selected hardware board is the LPCXpresso824, the creating work is based on the corresponding LPCOpen.              Creates a new project Fig 4   2.    Create the example and lib groups, then add the startup and board initialization files under the example group and add the library files: board_nxp_lpcxpresso_824.a and chip_82x_lib.a under the lib group. Next, create a main.c file: traffic_signal_demo.c. Fig 5 3.     Add the corresponding paths $PROJ_DIR$\..\..\..\..\..\..\software\lpc_core\lpc_chip\chip_8xx\config_82x $PROJ_DIR$\..\..\..\..\..\..\software\lpc_core\lpc_chip\chip_common $PROJ_DIR$\..\..\..\..\..\..\software\lpc_core\lpc_chip\chip_8xx $PROJ_DIR$\..\..\..\..\..\..\software\lpc_core\lpc_board\board_common $PROJ_DIR$\..\..\..\..\..\..\software\lpc_core\lpc_board\boards_8xx\nxp_lpcxpresso_824                $PROJ_DIR$\..\..\..\..\..\..\software\CMSIS\CMSIS\Include 4.     Miscellaneous settings For instance, target selecting, adds the linker file, add other c files (Fig 6),etc. Fig 6   v Crucial code                                                          Table 1 main.c /**  * @brief             Application main program  * @return          Nothing (This function will not return)  */ int main(void) {                 /* Generic Initialization */                 SystemCoreClockUpdate();                   /*Set system clock div as 30*/                 Chip_Clock_SetSysClockDiv(30);                                 /*Assign SCT_out to board LED pin*/                 Chip_SWM_MovablePinAssign(SWM_SCT_OUT1_O, 13); // assign SCTOUT_0 to P0_13 YELLOW_LED                 Chip_SWM_MovablePinAssign(SWM_SCT_OUT2_O, 27); // assign SCTOUT_0 to P0_27 GREEN_LED                 Chip_SWM_MovablePinAssign(SWM_SCT_OUT0_O, 17); // assign SCTOUT_0 to P0_17 RED_LED                                 /* Initialize the SCT clock and reset the SCT */                 Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SCT);                 Chip_SYSCTL_PeriphReset(RESET_SCT);                   /*Initialize SCT*/                 sct_fsm_init();                   /* Start the SCT counter by clearing Halt_L in the SCT control register */                 Chip_SCT_ClearControl(LPC_SCT, SCT_CTRL_HALT_L);                /* Enter sleep mode */                 while (1) {                                 __WFI();                 } }                                                     Table 2 sct_fsm_init(void) void sct_fsm_init (void) { /*The SCT operates as a unified 32-bit counter*/ LPC_SCT->CONFIG = (LPC_SCT->CONFIG & ~0x00060001) | 0x00000001; /* UNIFIED */   /* MATCH/CAPTURE registers */ LPC_SCT->REGMODE_L = 0x00000000;           LPC_SCT->MATCH[0].U = entry_mat;             /* entry_match */ LPC_SCT->MATCHREL[0].U = entry_mat; LPC_SCT->MATCH[1].U = flash;                       /* flash_mat0 */ LPC_SCT->MATCHREL[1].U = flash; LPC_SCT->MATCH[2].U = flash1;                    /* flash_mat1 */ LPC_SCT->MATCHREL[2].U = flash1; LPC_SCT->MATCH[3].U = delay;                     /* match0 */ LPC_SCT->MATCHREL[3].U = delay; LPC_SCT->MATCH[4].U = yel_delay;              /* yel_delay_mat */ LPC_SCT->MATCHREL[4].U = yel_delay; LPC_SCT->MATCH[5].U = yel_flash;               /* yel_flash_mat */ LPC_SCT->MATCHREL[5].U = yel_flash;   /* OUTPUT registers */ /*Event 1 set the output*/ LPC_SCT->OUT[5].SET = 0x00000002;        /* out_track */ /*Event 3 clear the output*/ LPC_SCT->OUT[5].CLR = 0x00000008; /*Event 0 and 3 set the output*/ LPC_SCT->OUT[2].SET = 0x00000009;        /* turn_green */ /*Event 7 clear the output*/ LPC_SCT->OUT[2].CLR = 0x00000080; /*Event 1 set the output*/ LPC_SCT->OUT[0].SET = 0x00000002;        /* turn_red */ /*Event 0 and 6 clear the output*/ LPC_SCT->OUT[0].CLR = 0x00000041; /*Event 0, 2, 4, 5, 6 and 7 set the output*/ LPC_SCT->OUT[1].SET = 0x000000F5;        /* turn_yellow */ /*Event 1, 3, 4, 5 set the output*/ LPC_SCT->OUT[1].CLR = 0x0000003A;   /* Unused outputs must not be affected by any event */ LPC_SCT->OUT[3].SET = 0; LPC_SCT->OUT[3].CLR = 0; LPC_SCT->OUT[4].SET = 0; LPC_SCT->OUT[4].CLR = 0;   /* Conflict resolution register */ LPC_SCT->RES = (LPC_SCT->RES & ~0x0000000C) | 0x0000000C;   /*  Set COMBMODE = 0x1. Event 0 uses match condition only.  Set MATCHSEL = 0x0. Select match value of match register 0. The match value of MAT0 is associated with event 0 Set STATEV bits to 1 and the STATED bit to 1. Event 0 changes the state to state 1 */ LPC_SCT->EV[0].CTRL = 0x0000D000;     /* U: --> state RED */ LPC_SCT->EV[0].STATE = 0x00000001; /*  Set COMBMODE = 0x1. Event 1 uses match condition only.  Set MATCHSEL = 0x3. Select match value of match register 3. The match value of MAT3 is associated with event 1 Set STATEV bits to 2 and the STATED bit to 1. Event 1 changes the state to state 2 */ LPC_SCT->EV[1].CTRL = 0x00015003;     /* U: --> state YELLOW */ LPC_SCT->EV[1].STATE = 0x00000002; /*  Set COMBMODE = 0x1. Event 1 uses match condition only.  Set MATCHSEL = 0x4. Select match value of match register 4. The match value of MAT4 is associated with event 2 Set STATEV bits to 4 and the STATED bit to 1. Event 1 changes the state to state 4 */ LPC_SCT->EV[2].CTRL = 0x00025004;     /* U: --> state YELLOW_FLASH */ LPC_SCT->EV[2].STATE = 0x00000004; /*  Set COMBMODE = 0x1. Event 1 uses match condition only.  Set MATCHSEL = 0x3. Select match value of match register 3. The match value of MAT3 is associated with event3 Set STATEV bits to 2 and the STATED bit to 1. Event 1 changes the state to state 2 */   LPC_SCT->EV[3].CTRL = 0x00015003;     /* U: --> state YELLOW */ LPC_SCT->EV[3].STATE = 0x00000008; /*  Set COMBMODE = 0x3. Event 6 uses when match and I/O condition occur.  Set MATCHSEL = 0x5. Select match value of match register 5. Set OUTSEL = 1. Select output. Set IOSEL = 5. Select output 5. Set IOCOND = 0x0. Output 0 is Low The match value of MAT5 is associated with event 6 Set STATEV bits to 1 and the STATED bit to 1. Event 1 changes the state to state 1 */ LPC_SCT->EV[6].CTRL = 0x0000F165;     /* U: --> state RED */ LPC_SCT->EV[6].STATE = 0x00000010; /*  Set COMBMODE = 0x3. Event 6 uses when match and I/O condition occur.  Set MATCHSEL = 0x5. Select match value of match register 5. Set OUTSEL = 1. Select output. Set IOSEL = 5. Select output 5. Set IOCOND = 0x3. Output 0 is High The match value of MAT5 is associated with event 7 Set STATEV bits to 3 and the STATED bit to 1. Event 7 changes the state to state 3 */ LPC_SCT->EV[7].CTRL = 0x0001FD65;     /* U: --> state GREEN */ LPC_SCT->EV[7].STATE = 0x00000010; /*  Set COMBMODE = 0x1. Event 1 uses match condition only.  Set MATCHSEL = 0x1. Select match value of match register 1. The match value of MAT1 is associated with event4 Set STATEV bits to 4 and the STATED bit to 1. Event 1 changes the state to state 4 */ LPC_SCT->EV[4].CTRL = 0x00025001;     /* U: --> state YELLOW_FLASH */ LPC_SCT->EV[4].STATE = 0x00000010; /*  Set COMBMODE = 0x1. Event 1 uses match condition only.  Set MATCHSEL = 0x2. Select match value of match register 2. The match value of MAT2 is associated with event5 Set STATEV bits to 4 and the STATED bit to 1. Event 1 changes the state to state 4 */ LPC_SCT->EV[5].CTRL = 0x00025002;     /* U: --> state YELLOW_FLASH */ LPC_SCT->EV[5].STATE = 0x00000010;   /* STATE registers */ LPC_SCT->STATE_L = 0;   /* state names assignment: */   /* State U 0: U_ENTRY */   /* State U 1: RED */   /* State U 2: YELLOW */   /* State U 3: GREEN */   /* State U 4: YELLOW_FLASH */   /* CORE registers */ LPC_SCT->START_L = 0x00000000; LPC_SCT->STOP_L =  0x00000000; LPC_SCT->HALT_L =  0x00000000; /* Event0, 1, 2, 3, 6 and 7 reset the counter register */ LPC_SCT->LIMIT_L = 0x000000CF; LPC_SCT->EVEN =    0x00000000; LPC_SCT->DMAREQ0 = 0x00000000; LPC_SCT->DMAREQ1 = 0x00000000;   } v Result demonstrate          The demo runs on the LPCXpresso824-MAX board, and using the Blue led replaces the Yellow led, and the video shows the demo working. Fig 7 LPCXpresso824-MAX board Video's link: SCTimer implement traffic signal - YouTube 
View full article
This document was made to explain how to regain control of any LPC EVK on brick mode without using an external debugger. Explore the simple way. In some cases, this method forms well and is the easy way, open your IDE and select your project.   At this point you may have a debugger configuration of your last debug session, so, you have similar icons to the image. Open the tab below and select erase. Depending on your debugger configuration you need to select the same icons below. Note: In some cases will be necessary to put your MCU in ISP. And that’s all, could try if the MCU is out the brick mode.   Introduction First, you need to install these tools on your PC. LPCScrypt [LPCScrypt v2.1.2 | NXP Semiconductors]. J-Link Commander. [J-Link Commander (segger.com)]. To understand this document, we need to know that every EVK [Evaluation Kit] can be divided into 2 parts. The debugger on the board Link2 and the target LPC55sXX. Figure 1. Link2 Green square, LPC55sXX Red square This document will describe two methods that must be done in the order mentioned because we will see how to update the firmware of the debugger to use the same board for a self-recovery, this step is necessary for the tool J-Link Commander to recognize the debugger as a Segger probe, then when the update is done the second step should be to enter ISP mode to do a mass erase of the target to get out of the brick mode. Link2 The Link 2 (LPC4370) debugger on the board probe can be configured to support various development tools and IDEs using a variety of different downloadable firmware images. Available firmware images include: J-Link by Segger. LinkServer. By default, the EVK board has the firmware LinkServer on the LPC4322 (dependent on your board), for this proposal we will see how to change to J-Link On-Board. DFU The EVK needs to be prepared to receive this firmware on the debugger, to do that we need to put the board on DFU [Device Firmware Update]. On the schematic need to find the DFU jumper to put on the board, the image below is an example of different EVKs check Figure 2.   Figure 2. DFU from different boards. Then connect it to the PC. Note: The firmware update is completely reversible. LPCScrypt Once installed on the PC we need to locate these files of the installation. Root example: C:\nxp\LPCScrypt\scripts When you have the board on DFU, connecting the USB Llink2 to the PC and then RUN the Scrypt (program_JLINK) in CMD check Figure 3. Press any key to continue… Figure 3. Flash firmware of J-Link in DFU mode. Successfully done, at this moment the EVK has the firmware of J-Link Segger. Review the Figure 4. Figure 4. The firmware was flashed successfully. Remove the USB cable to remove the DFU jumper with the board unpowered. ISP Brief of ISP (In System Programming) this method is used to recover a part programmed with a corrupted image which is not detectable by ROM. So, to enter this mode the user needs to put a jumper in the ISP header pins, search for this in the schematic, then connect to the PC and check Figure 5.     Figure 5. ISP image examples from different boards. J-LINK Commander Open the software and if the communication is right the message will appear J-Link via USB… OK check Figure 6. Figure 6. The EVK is now communicating to the tool J-Link Commander. Commands To start the communication needs to send the command “connect”. Then the tool shows your last target (if you use it) and use the next command “?” to change the target review Figure 7. Figure 7. Review the target. In the new popup window in the green area, you need to put the name of the target, take care you do not put the debugger check Figure 8. Figure 8. In the green area, you need to put the matricula of the MCU target. Example [LPC55s16 or LPC55s69] depending of your target check Figure 9. Figure 9. If the tool supports the MCU will show below the red square. In the next selections the tool is asking for the interface of communication, the communication of the EVK is SWD, and for that write “S” as SWD. On speed, only click enter without entry. Then this will appear before the connection check Figure 10. Figure 10. The communication is Done. Then use the command “erase” like the Figure 11. Figure 11. The tool indicate the erase is done. Finally disconnect the USB and remove the ISP jumper, then open the IDE and test the blinky led example, or if you wanted you could use the BLHOST. Flashing the MCU using  BLHOST. At this step you could able to use the IDE or use BLHOST. You could install SPSDK if you wanted [Installation Guide — SPSDK documentation]. In ISP mode… blhost -p COMxx  get-property 1 Figure 12. The first command is to check the communication. blhost -p COMxx flash-erase-all Figure 13. Do a mass erase. blhost -p COMxx write-memory 0 C:\root_example\Debug\led_blinky.bin Figure 14. The flashing was done. Remove the ISP jumper and reset your device. Common error LPCScrypt If the message appears “Nothing to boot”, need to be sure the board is connected to the PC with the DFU mode in LINK 2 check Figure 16. Figure 16. The red square is an example of an error communication. J-Link Commander If a similar message appears, “Cannot connect to target”, need to put the target in ISP mode, and return to the first steps with J-Link commander check Figure 18. Figure 18. Show how the communication is not done.
View full article
Introduction GUI Guider is a user-friendly graphical user interface development tool from NXP that enables the rapid development of high quality displays with the open-source LVGL graphics library. GUI Guider's drag-and-drop editor makes it easy to utilize the many features of LVGL such as widgets, animations and styles to create a GUI with minimal or no coding at all. In recent years, Smart Home has emerged rapidly and has a strong momentum of development. Smart Homes connect various household appliances and provide services such as lighting control, telephone remote control, burglar alarm and environmental monitoring. Smart Home applications are more and more widely used, but it is difficult for many developers to start. Using NXP GUI Guider can improve the development speed, reduce development difficulty, shorten development cycle. This article mainly introduces the use of GUI Guider to realize some functions of Smart Home, and shares some common methods in the use of GUI Guider, including creating a new project, adding controls, adding events, interface design and layout, and controlling the lighting of hardware lights. Development environment 2.1 Hardware environment Evaluation of LPC54628 -LPCXpresso54628, also applies to LPCxpresso54618, LPCxpresso54608. 2.2 Software Environment This Smart Home demo uses GUI Guider version 1.5.1 to set up the software environment. GUI Guider version 1.5.1 supports LVGL versions 7.10.1 and 8.0.2. This introduction is based on version 8.0.2 LVGL. Download link: https://www.nxp.com/design/software/development-software/gui-guider:GUI-GUIDER Create a new project 3.1 Double-click the GUI Guider icon to start the GUI Guider.   3.2 Click Create a new project (" Create a New Project ") button to start the project creation process.   3.3 select LVGL version v8.3.2 and click Next button.   3.4 Select LPC54628 as the target board template and click Next button.   3.5 Select empty application template EmptyUI and click Next.   3.6 Perform the project Settings, and set the project name, project location, and screen type (select RK043FN66H or RK043FN02H according to your screen type). Click Create to create the project.   3.7 After the project is created, the interface is as follows.   Page Design and Layout This section describes how to adjust the background color, layout, add various controls (Such as images, image buttons, text, and containers , etc), and set properties. 4.1 Create the image folder, and put the image resources needed in the project under the established image folder.   4.2 Adjust the background color of the interface ① Click the Background color icon to open the background color Settings. ② You can set the background Gradient or monochrome by using Gradient. ③ Then select the background color.   4.3 Add images ① Open Widgets control options. ② Click to add the Image control. ③ Then click the image shape button in the Attribute box of the property Settings, and “Select Images” will pop up. In “Select Images”, select the image you want to add, click OK to add the image, and adjust the image size and position.   In the same way, you can add the "small house" image. In the Widgets box, you can view the added image and set the image name. In the Screen box, you can view the current interface and set the interface name.   4.4 Add text ① Open the control options, select and click the Label control. ② In Property Settings Text, set the text content to SMART HOME. ③ Then click the Background background setting area to set the Label control background. ④ Set the color depth of the Label control to 0, without background color. ⑤ Set the Font color, size and style in the font.   4.5 Add a container Containers are essentially basic objects with layout and automatic resizing capabilities. Open the control option, click Container to add the Container control, and drag the control size. Set the background color in the property Settings. ③ Then set the Border and rounded corner of container in "Border".   Name the added Container control cont_TodayInfo. Add other controls to the Container control. You can view other controls (including picture, text, and line controls) added to the cont_TodayInfo container in the Widgets.   4.6 Add an Image button Image button are very similar to simple "button" objects. The only difference is that it displays image in each state defined by the user. ① Open component options, select and click the Imgbtn control. ② Add the Released and Pressed images.   In the same way, add other Imgbtn controls and Label controls.   Switch the interface This section describes how to create sub-interfaces and switch between the main interface and sub-interface. 5.1 Add a second new interface Click “+” to add a new screen, rename the new screen src_Light, add Image, imgbtn controls, and change the background color.   5.2 Add interface switching trigger conditions ① Select the imgbtn_Light button on the first screen. ② Select the Events Settings. ③ Click “+” to add an event, and then set the event. ④  In event Settings, trigger conditions need to be selected, here Clicked trigger conditions are selected. Target Select the second new interface src_Llight that you want to load, and then select the Delete current interface option. When the program is running, when the imgbtn_Light button is clicked, it will switch to the second src_Light interface.   Updating Media   5.3 Add a trigger condition for returning to the interface ① Select the imgbtn_Home control. ② In the event Settings, select Clicked trigger conditions, Target select src_Welcome for the interface to be loaded, and select Delete the current interface option. When the program is running, when the imgbtn_Light button is clicked, it returns to the first main screen of src_Welcome.   5.4 Design the second interface Add controls in the second interface, including Switch control, Slider control, Dropdown control, Image control, Imgbtn control, Label control. Switch control: This switch can be used to turn the light on/off and it looks like a small slider. Slider control: The slider object looks like a bar supplemented with knobs. You can drag the knob to set the value. The slider can be vertical or horizontal. Dropdown control: A drop-down list allows the user to select a value from a list. By default, the drop-down list is turned off and displays a single value or predefined text. The Image control, Imgbtn control, and Label control are described in the previous section.   Control hardware light design Smart home usually has the control of the light, through the control interface to control the hardware light on and off, the steps are as follows: 6.1 GUI Guider generates code project ① Generate the code by clicking the Generate code button. ② Click the Folder icon to open the project folder   6.2 Starting the MDK Project After the generated code is completed, open the project folder and open the MDK project in the specified directory (support MCUXpressoIDE, MDK, IAR).   6.3 First, the drive to control the light switch is added to the project Add a GPIO initializer in lvgl_guider.c.   6.4 then, add a custom Led control function under Custom.c This routine adds Led1_Control, Led2_Control, and Led3_Control lamp control functions.   6.5 Add custom event program to GUI Guider ① Select the first Switch control and add the event. ② In the event, select Trigger to trigger the event condition that the Switch control is on and off, and the Target option is set to Null.  In Action, select C to add custom events and click to open Edit Code.  Add a custom event function to Edit Code (open Led3, close Led2, Led1), and add the header file of the file where the custom event function is located.   6.6 View custom events in the MDK project After setting the custom event, the set Led custom trigger event can be found on events_init.c after the GUI Guider regenerates the code again.   Program download and demo After the project is completed, there are two ways to download the program to the development board: Open the project with IDE (MCUXpresso IDE, KEIL or IAR), compile and download the program to the development board. Selecting MCUXpresso, Keil, or IAR from Target in the GUI Guider automatically compiles the program to download to the board. The following diagram shows how Guider automatically compiles the download program to the development board in GUI.   Attached video shows the effect.   8.In SUMMARY This artical mainly shares the Smart Home interface design based on GUI Guider. GUI Guider, as a tool for GUI design, is powerful and easy to use. This article only uses a few functions of GUI Guider, we can further learn to explore GUI Guider, the related project has been placed in the attachment. The GUI Guider application guide can be found on the NXP official website, and the following are some ways to find information when learning to use GUI Guider. View the User Guide and click Help->User Guide   control Settings and usage instructions, you can click the following small icon to view    
View full article
  Background LPC55(S)XX and MCX series products support updating firmware (ELF, HEX, BIN or SREC/S19) in ISP mode, including USB, UART, SPI, and I2C  connection interfaces.  There was no official host software tool supporting SPI-ISP and I2C-ISP before, so it was difficult for customers to update firmware files through I2C and SPI in ISP mode. Now NXP has launched MCUXpresso Secure Provisioning Tool(SEC or SPT), a graphical interface tool that makes it easy to connect through the four ISP interfaces. Based on the SEC, this article takes LPCXpresso55S69 as an example to introduce the methods of updating firmware in four modes: USB-ISP, UART-ISP, SPI-ISP and I2C-ISP.   Preparation (1)Software MCUXpresso Secure Provisioning Tool is a graphical user interface tool, which is mainly used for security configuration. When  MCU is in the ISP mode, you can use this tool to connect and communicate, it support all interfaces of  ISP. LPC55(s)xx series include four ISP download interfaces: USB, UART, SPI, and I2C. This article is based on this to introduce. (2)Hardware LPCXpresso55S69-evk development board (chip version is 1B)   Steps Make chip into ISP mode before  using SEC tool connect. When power-on, BOOT ROM determines whether enter the ISP mode, based on the CMPA configuration in bit DEFAULT_ISP_MODE and ISP pin status. As shown in  following tables:     Keep the default value of EFAULT_ISP_MODE to “000”, and enter the ISP mode by pulling down the ISP pin PIO0_5. The first valid probe message on USART, I2C, SPI or USB locks in that interface. On LPCXpresso55S69 development board, connect the ISP interface cable (USB\UART\SPI\I2C), press and hold the ISP button, power on,  it will  enter ISP mode.   3.1 USB HID ISP mode (1)In LPC55(s)xx, HS-USB is default USB-ISP port, LPCxpresso55s69-evk uses P9 port, use USB cable to connect P9 and PC. (2)Press and hold  ISP button, reset board, entered ISP-USB mode. (3)Configure MCUXpresso Secure Provisioning Tool: select USB connection mode, test connection. First, click "File->New Workspace", open the option to create a new workspace, and select the processor model you are using.     Then, click "Target->Connection" to open the connection configuration.   In configuration, select USB interface, click “Test Connection” button, if the result shows " ok", connected successfully.   (4)Select the source file in "Source executable image". This tool can build plaint image, signed image, and encrypted image. You can configure it according to your own requirements. For example, use a plain image file "lpcxpresso55s69_gpio_led_output.hex", this file is a binary file generated from MCUXpresso IDE under the SDK example. Click the "Build image" button, ensure that the compilation was successful.     (5)Download the image file Choose “Write Image” view, in “Image path” select the image generated by the previous step, then click  “Write Image” button.   If download  successfully, the following picture will be displayed:     3.2 UART ISP mode (1)LPC55(s)xx  use UART0 as UART-ISP interface, you can use USB cable to connect P6 of LPCxpresso55s69-evk and PC, or use USB-UART convertor to connect UART0 TX/RX and PC. (2)Enter ISP mode, refer to 3.1. (3)Configure MCUXpresso Secure Provisioning Tool, refer to 3.1, select UART connection mode, and perform connection test.   Step 4 and step 5 are the same as 3.1.   3.3 SPI ISP mode (1) LPC55(s) 2x/6x currently includes two versions, 0A and 1B, which can be checked from the chip mask. The 0A version supports SPI3 and HS_SPI ISP interface, and the 1B version only supports HS_SPI ISP interface. This article uses version 1B for the experiment. Both SPI and I2C use LIBUSB interface, LPC-LINK2 and MCU-LINK pro support this function interface, so as long as there is LPC-LINK2 or MCU-LINK pro, SPI-ISP and SEC tool connection can be realized. Special reminder: LPC-link2 and MCU-LINK pro must be updated to CMSIS-DAP debugging interface, J-link does not support this function. In the LPCxpresso55s69-evk development board, SPI3 is connected to LPC-LINK2 by default, and HS_SPI is not connected, so  an external connection is required, connect SCK, MOSI, MISO, and SSEL1 of HS_SPI to the corresponding positions of LPC-link2. For details, please refer to the lpc55xx manual and the development board schematic. It can also be connected according to the figure below. The connection of the development board is shown in the below picture   (2) Connect the USB cable to the P6 port. (3) Enter ISP mode, refer to 3.1. (4) Configure MCUXpresso Secure Provisioning Tool, refer to 3.1, select the SPI connection mode, and perform a connection test.   Step 5 and step 6 are the same as 3.1.   3.4 I2C ISP mode The I2C-ISP mode is the same as SPI, with the help of the LIBUSB interface, that is, the LPC-link2 on the development board. Special reminder: LPC-link2 and MCU-LINK pro must be updated to CMSIS-DAP debugging interface, J-link does not support this function. (1)  Connect the USB cable to the P6 port. (2)  LPC55(s)6x/2x uses I2C1, and LPCxpresso55s69-evk development board has already connected I2C1 and LPC-LINK2, no need additional connection. (3)  Enter ISP mode, refer to 3.1. (4) Configure the MCUXpresso Secure Provisioning Tool, refer to 3.1, select the I2C connection mode, and perform a connection test.   Step 5 and step 6 are the same as 3.1.   Summary (1) All ISP interfaces (USB/UART/SPI/I2C) are supported by MCUXpresso Secure Provisioning Tool. (2) LPC-link2/MCU-LINK pro must be configured as CMSIS-DAP debug probe. (3) Check the chip version and make sure use the correct SPI port. (4) Make sure that the usb  cable interface is connected correctly and must enter the ISP mode before testing the connection.      
View full article
The ADC of LPC55xx supports scan mode, in scan mode, once ADC triggering (either hardware or software) can convert multiple analog channels. The document gives an example that the CTImer2 module triggers ADC and ADC converts two analog channels for each triggering. The doc introduces the CTimer configuration, ADC triggering control register configuration, and ADC Command buffer chain and ADC result reading , in this way, the CTimer can trigger ADC, the ADC can convert multiple channels. The example and the doc are attached. The Example is developed based on SDK example lpcxpresso55s69_lpcadc_interrupt example, the tools is MCUXprsso IDE ver11.7, the SDK package is SDK_2.x_LPCXpresso55S69 ver2.11.1  
View full article
The minimum saturation current spec of Inductor is 300mA in the LPC55xx internal DC/DC converter, why is it 300mA, what is the actual current flowing through the inductor? 1)This is internal DC/DC converter block diagram for LPC55xx, on the LX pin, the 4.7uH inductor and 22uF capacitor are required, the FB pin is the detected pin to sense the output voltage, the DC/DC converter provide about 1.1V power for the VDD_PMU power supply pin. Let's discuss the current flowing through the inductor L1 via LX pin   2)compute the actual current flowing the inductor The above circuit is the illustrating block diagram, the control regulation uses PWM signal to control the MOSFET, but the high time of the PWM signal is constant for each PWM cycle, in other words, the on-time of the MOSFET is constant, for the LPC55S69 internal DC/DC converter, the on-time Δt is 0.52us, which means that the interval of MOSFET turning-on time is 0.52us. Assume that the VDC_IN is 3.3V, the output voltage of the DC/DC converter is 1.1V, the constant high time of the PWM signal is 0.52uS. when the MOSFET is on, the capacitor will be charged.   The above figure is the waveform tested on the LX pin of LPC55S68 on the LPC55S69-EVK board, you can measure via scope that the high time of the yellow PWM signal is 0.52uS, during which the MOSFET turns on, the capacitor is charged. The inductor works in DCM mode(discontinuous current mode)   The incremental current flowing the inductor during the MOSFET turns on: ΔI= (VDC_IN-VDC_OUT)* Δt/L=(3.3V-1.1V)*0.52*10**(-6)/4.7*10**(-6)=243mA.   3)The actual flowing current through the inductor is about 250mA for each PWM cycle, so when you select the inductor, the saturation current spec must be greater than actual current, the minimum required saturation current spec for the 4.7uH inductor is 300mA, when you select inductor for the DC/DC converter, you should select the inductor with 300mA or above saturation current .
View full article
The example demos how to use ARM TX Event to trigger ADC based on LPC55S69-EVK board and MCUXPresso IDE and SDK. As the Table 753, the “ARM tx event” is the one of the ADC triggering source, although it is a hardware triggering, but the mechanism is the same as software triggering, after ADC configuration, you execute the instruction asm(“SEV”); the ARM tx event will be generated and trigger ADC to sample. The ADC of LPC55xx support hardware trigger mode, each hardware trigger source corresponds to a trigger register, as the Table 753, the ARM tx event ASC triggering source index is 11, so you have to initialize the ADC trigger control register TCTRL11. In the TCTRL11 register, you can assign the command ID, select the FIFO0 or FIFO1 to save the ADC result, enable hardware triggering.    
View full article
Contents     Introduction to OPAMP. ........................................1     Usage of LPC5536-OPAMP. ................................2 2.1 Follower OPAMP. .................................................2 2.2 Non-inverting OPAMP. .........................................3 2.3 Differential OPAMP. ..............................................3     Test Preparation of LPC5536-EVK. ......................4     Test Result ............................................................5 4.1      Follower Test ....................................................6 4.2      Non-inverting Test ............................................7 4.2.1 Error Analysis. ...................................................7 4.2.2 Gain Error and Output Offset Error ...................8 4.2.3 OPAMP Output Error .........................................9 4.4 Differential Test ...................................................10     Conclusion. .........................................................11   The Article shows the OPAMP performance test that the precision of LPC5536-OPAMP matches the description in the product data sheet. The gain error is less than 5%, and the input offset voltage is less than 5mV, which can meet the presicion need to a certain extent. It is worth mentioning that the output error of LPC5536-OPAMP is very small at low magnification. For example, the full-range error is just single-digit mV at the magnifications of 2X and 5X in non-inverting mode. For scenarios requiring higher precision, users can connect the external high-precision resistors to achieve higher output precision.  The article includes detailed test steps and EVK board settings. For detail, see attached article.  
View full article
Because the LPC55S69 has PowerQuad, in SDK example code, the FFT/FIR/IIR and the other DSP function are implemented by the Powerquad module instead of the Cortex-CM33 core.  This is the Powerquad example to implement the DSP function:'   But if customers want to use CMSIS-DSP to implement the DSP function based on Cortex-CM33 instead of Powerquad module, customers can not import SDK example, he has to create a new project, this is the procedures: 1)Create a new project by clicking New->Create a new C/C++ Project   2)select the processor like LPC55S69 3)In the following menu,click CMSIS Driver, and check the CMSIS_DSP_Library and CMSIS_DSP_Library_Source You have to click the Driver which can select your peripherals driver you will use.    3)as the following screenshot, after completion, you can see the CMSIS-DSP source code and library have included in the project    
View full article
As a free and open-source graphics library, LVGL provides great convenience for related series of chips in creating animations, building advanced graphics and building various blocks. LVGL has been integrated into the MCUXpresso SDK package, which can be imported either through the SDK download or directly in the GUI Guider. GUI-Guider is a ready-to-use GUI from NXP. On the basis of being free for NXP equipment, it has a series of advantages such as convenient operation, automatic programming, Chinese and English interface and input. The following takes the LPC54S018 development board as an example, by creating a simple UI interface, to let everyone familiar with its basic operation process and usage. Create new project Select V8 lvgl version, LPC54S018 development board, EmptyUI, set the name and path, click Finish Fig.1 Set the overall background Drag Widget Tab to the GUI Editor, and resize it to full screen size. Fig.2 Add time display and to-do functions. 1) Change the Tab Content1 name to Clock in the red box on the right. Fig.3 2) Drag aclock into editor, adjust its size and position, and set the time according to the red box in Figure 4. Fig.4 3) Drag the dclock clock into the editor, adjust its size and position, and set the time according to the red box in Figure 5. Fig.5 4) Drag the checkbox into editor, adjust its size and position, and edit its content according to Figure 6. Fig.6 In the second Tab content, add a simple counting function and set the progress bar to interact with it. 1) Add a background. Click Import to import the background image, in the widget, drag the image into the editor, set the size and position, select the imported image in the image path and set its transparency, as shown in Figure 7. Fig.7 2) Add count value, progress bar and button. Figures 8, 9 and 10. In Figure 8, when adding a progress bar, set the starting value in the second step. The range value of the progress bar is set by lv_bar_set_range(guider_ui.screen_progress_bar, 0, 100) which can be added to a key event, executing on every click. Therefore, it is recommended to add this code to the subsequent export file costomer.c, and set it once during initialization. Fig.8 Fig.9 Fig.10 3) Add some explanatory text to the progress bar. The operation steps are shown in Figure 11. Fig.11 4) Create an event in the corresponding button, select Customer Code, write the corresponding code, and complete the interaction. Take the ADD button as an example, as shown in Figure 12. Fig.12 In the Tab third content, 3D animation effect is shown. 1) Set the 3D picture. Select 3Dimg, drag it into the editor, set the image in the image path, and then select the rotation center and rotation angle, as shown in Figure 13. Fig.13 2) Set the display switch. Turn on the switch to display the 3D picture, and when the switch is turned off, the picture disappears. Such as Figure 14. Fig.14 In the fourth Tab content, add “help”. 1) Add logo. Add img, import image to set transparency. Fig.15 2) List the first three modules. Drag the list Widget into the editor, create new lines and modify pictures and texts. After completion, generate the code as shown in Figure 16. The results can be directly displayed by simulation or imported into the development board. Figure 17 shows the simulator and selectable target. The simulation results are shown in Figure 18. There are two ways to download the design to the development board. One is to select the available IDE in Figure 17 and download it directly through GUI Guider. The second is to export the source files first, replace them one by one in the relevant SDK demo code, build with application code in IDE and download/debug with IDE debugger. Fig.16 Fig.17 Fig.18 Video Class : https://www.youtube.com/watch?v=QM52Nu16zKQ  
View full article
This article mainly introduces how to re-enable SWD after disabled. 1.Problem description The Enhanced Code Read Protection (ECRP) of the LPC546xx series is used to configure different security levels for user programs. It is configured when the startup image file offset is 0x20 and is used in combination with OTP. Users of LPC546xx can disable SWD and ISP by configuring ECRP values. Some users need to re-enable SWD after disabling SWD, you can use the J-link commander "unlock LPC5460x" command or re-enable SWD based on LPC-LINK2 CMSIS-DAP these two methods, this article will introduce the two methods in detail. 2.Theoretical analysis and solutions Customer’s example: LPC54605:Configure ECRP to 0x00015800. After disabling SWD, it needs to be restored. When the ECRP value is 0x00015800, we analyze from high to low through  user manual. In ECRP, 31:18 bits are reserved, and 17:16 bits determine the status of SWD. In this example, 17:16=01 ,this means that SWD is disabled.   15: 14 =01, it is not allowed to enter ISP through IAP call.   13: 12 = 01, it is not allowed to enter ISP through pin.   11: 10 = 10, IAP sector erase / write protection is disabled, so sector protect (5:0) is ignored.   At this point,  SWD (17:16) is DISABLED, ISP Entry from ISP (15:14) is DISABLED, and ISP Entry from Bootloader (13:12) is DISABLED, the IAP Mass Erase can still be used to erase the entire Flash to recover a device. as long as the OTP MASS ERASE is ENABLED. If the OTP has been configured and bit 4 is set to 1, that is, disabled mass erase command, the SWD can never be recovered again. When Mass Erase is enabled, the Debug Mailbox is also enabled and allows a debugger to communicate with the bootloader to execute a Mass Erase.   Therefore, the Debug Mailbox can be used to perform Mass Erase operation and restore ECRP settings. To achieve the purpose of re-enabling SWD. 3. Re-enable SWD 3.1 Use "unlock LPC5460x" command re-enable SWD If use J-link debug probe, use "unlock LPC5460x" command to re-enable SWD. Open the J-Link commander and enter unlock to view supported devices. Enter the corresponding chip command. In this paper, the command is unlock LPC5460x. As shown in the picture below:   However, for some chips, this method still fails to re-enable SWD. The following is a method of SWD recovery based on LPC-LINK2 CMSIS DAP. If the unlock LPC546xx command does not work, use the following method. 3.2 LPC-LINK2 CMSIS-DAP re-enable SWD If use CMSIS-DAP debug probe, use below steps to re-enable SWD. IDE: MCUXpresso IDE v11.7.1_9221 or other version. IDE installation path: C:\nxp\ MCUXpresso IDE v11.7.1_9221. The development board emulator firmware uses LPC-LINK2 CMSIS-DAP. Tool script: LPC546xxMassErase.scp. Tool script path: C:\nxp\ MCUXpresso IDE v11.7.1_9221 \ide\binaries\Scripts. The operations are the same for other versions of MCUXpressoIDE and other installation paths. 1) Put LPC546xxMassErase.scp script in the path: C:\nxp\MCUXpressoIDE_11.7.1_922\ide\binaries\Scripts 2) Open a command prompt window. 3) Change the path to C:\nxp\ MCUXpresso IDE v11.7.1_9221 \ide\binaries.   4) Run the redlinkserv -commandline command. 5) After running the redlinkserv -commandline command, you should see the redlink> prompt.   6) Run the load command "C:\nxp\MCUXpressoIDE_11.7.1_9221\ide\binaries\Scripts\LPC546xxMassErase.scp". 7) After executing the load command, you should see that "LPC546xxMassErase.scp" is being loaded. 😎 Execute the run command. 9) After executing the run command, you should see the following message.   In this case, the SWD interface can be used normally. 4.Query ECRP level In the LPC546xx user manual, we can see  ISP-AP command, one function is query the ECRP  level, that is, to view the ECRP configuration of this chip.   From the log in part 3, we can see the returned ECRP level:   However, there is no explanation in the user manual, so here we show the meanings of each bit. There is a table translation from the ECRP level user defined and the ECRP definition used by the ROM code: /* Feature bit defines */ #define CRP_JTAG_EN_BIT         (1 << 6) #define CRP_MASS_ERASE_DIS_BIT  (1 << 7) #define CRP_IAP_PROT_EN_BIT     (1 << 😎 #define CRP_ISP_PINS_EN_BIT     (1 << 9) #define CRP_ISP_IAP_EN_BIT      (1 << 10) #define CRP_DBG_MBOX_EN_BIT     (1 << 11) #define CRP_COUNT_MASK          0x3F #define CRP_DEFAULT_FEATURES    0xFFFFFFFF #define CRP_MASS_ERASE_ONLY     (CRP_SECT_ERASE_DIS_BIT) For example: In CRP_JTAG_EN_BIT, 1 is JTAG/SWD enabled and 0 is disabled. It’s corresponding to ECRP value bit 17 and 16. In CRP_MASS_ERASE_DIS_BIT, 0 is Mass Erase allowed and 1 is disallowed. It’s corresponding to the combination of ECRP value bit 0~5, bit 10~11, and bit 14~15. In CRP_IAP_PROT_EN_BIT, 1 is IAP protection enabled and 0 is disabled. It’s corresponding to ECRP value bit 14~15. In CRP_ISP_PINS_EN_BIT, 1 is ISP pin enabled and 0 is disabled. It’s corresponding to ECRP value bit 12~13. In CRP_ISP_IAP_EN_BIT, 1 is ISP in IAP mode enabled and 0 is disabled. It’s corresponding to ECRP value bit 14~15. In CRP_DBG_MBOX_EN_BIT, 1 is ISP-AP or debugger mailbox enabled and 0 is disabled. It’s corresponding the combination of some reserved ECRP bits and OTP setting. Of course, all these ECRP value used by the ROM not only look into the user defined ECRP value but also check the OTP setting. When “Query ECRP Level” is called, it returns the value used by the ROM code, but not the ECRP value programmed in the image by the user. 5.Summary: In the LPC546xx series, even if SWD is disabled, the debugger can communicate with LPC5460x through the Debug mailbox. As long as OTP does not disable Mass Erase, the debugger can ask LPC5460x to perform mass erase through the Debug Mailbox to re-enable SWD functionality. In addition, the article also adds the specific meaning of the value returned by the ISP-AP command.    
View full article
Continuously reducing the power consumption of integrated circuits is a constant topic in the development of integrated circuits. Reduced power consumption helps save power, extend standby time and reduce product heat, etc. Needless to say, low power consumption has become one of the important factors to measure product performance.   We usually recommend customers to refer MCUXpresso SDK power_mode_switch_lpc demo as low power design reference code. With this demo, customers can use serial terminal to control MCU to enter four low power consumption modes:Sleep mode,Deep Sleep mode,Power Down mode and deep power down mode. Meanwhile, user can also choose a variety of wake-up methods to wake up MCU through UART command.   However, when customers take use of power_mode_switch_lpc demo to measure lower power static characteristics, they find discrepancies with data sheet. Take example with LPCXpresso845MAX board. In power down mode, the demo board current reaches to around 100uA in debug mode. But data sheet states the typical current value is 1.5uA, no more than 10uA (see the Table below). Where is the problem? The purpose of the power_mode_switch_lpc demo is to demonstrate several low power modes and multiple wake-up methods to customers. We can’t get similar low power current value with default demo board as spec shows, but let's walk through a step-by-step demonstration and modify the routine to get the data sheet values.   LAB ENVIRONMENT: Demo Board: LPCXpresso845MAX SDK: SDK_2.11.0_LPCXpresso845MAX Demo Code: power_mode_switch_lpc IDE:MCUXpresso IDE v11.5.0   STEP: 1. Download power_mode_switch_lpc to LPC845 development board and run it. The serial port selects low power mode, press (SW2 button) to wake up. The program runs into power down mode, with debugger connected, the measured Idd is 99.5uA To enter low power mode, the following code is used: POWER_EnterPowerDown(DEMO_ACTIVE_IN_DEEPSLEEP); In order to wake up, parameter DEMO_ACTIVE_IN_DEEPSLEEP is configured with PDSLEEPCFG. BOD and watchdog oscillator power domains are turned on. All these setting results in potential current loss, causing power supply current higher than expectation.   2. In this step, we will remove wakeup initialization code // DEMO_InitWkt(); Replace this line of code //POWER_EnterPowerDown(DEMO_ACTIVE_IN_DEEPSLEEP); //enter power down mode with BOD and watchdog osc with POWER_EnterPowerDown(0); //power down BOD and watchdog osc   The modification is to turn off BOD power domain and watchdog clock in power down mode, compile and download the code again and enter the power down mode. At this time, the measured Idd is 57.3uA   In this way, Idd is significantly reduced. However, 57.3uA is still far from the typical value of 1.5uA stated in the data sheet. This is due to MCU debug power domain is turned on by IDE debugger, which leads to extra current consumption.  3. Thus we disconnect debugger and let the development board work in stand-alone mode (power off and re-power on). After power on, LPC is in power down mode. At this time, the measured Idd is 1.4uA. This is quite similar as the current value in datasheet. Consider GPIO configuration: The spec data shown in datasheet are tested under a dedicated test board with almost no external peripheral devices, and unused pins are basically in a floating state. For custom board or  LPCXpresso804 EVK. Some of its IO pins have external pull-up resistors and LEDs. If the GPIO is configured to output low power, the small light will be lit, resulting in additional power consumption. So we configure all pins as pull-up inputs for low power measurement.   Consider package: The test is based on LPCXpresso845MAX equipped LPC845 64pin package. It also applies to LPC845 48pin package. 33 package doesn't have VDDA pin. Due to VDD and VDDA pin design are not exactly the same as other package, for instance, 33pin low power consumption in power down mode is slightly higher than 64/48pin, but no more than 10uA as our spec in DS. Summary: Low power current parameters of the data sheet are measured with all MCU oscillators and analog domains off. Besides, reasonable configuration of GPIO can further reduce MCU power consumption. Before entering the low power consumption mode, it is recommended to set the unused GPIO as a pull-up input according to the actual situation (It can also be set to output low when the pin is floating). In applications with high requirements for low power consumption, users need to carefully optimize the code design to obtain the best low power consumption design.
View full article
  需求: 客户需要对Image文件做出完整性检测,利用IDE固有功能添加这类信息简便且可靠,以往有类似的link提到了这些配置,对于LPC55系列,需要做一些更新。 CRC Checksum Generation with MCUXpresso IDE - NXP Community Solution 基于MCUX环境 下载 SRecord http://srecord.sourceforge.net/ srec_cat.exe是下载后我们主要使用的工具,通过为其添加一个系统变量名,将SRecord目录加入系统路径     重启MCUX IDE之后可以在工程配置中看到该变量:       创建一个脚本文件crc_add.txt,放在debug目录下,用于填充app后的flash空余位置为0xFF, 并后续生成CRC32值并放置0x00037FFC位置。最终生成的srec文件为包含所有内容的image。           # srec_cat command file to add the CRC and produce application file to be flashed # Usage: srec_cat @filename #first: create CRC checksum lpcxpresso55s06_hello_world_image_length_MCUX.srec # input file #-fill 0xFF 0x00000000 0x00038000 # fill blank code area with 0xff from 0x00000000 to 0x00038000 (0x00038000是把LPC55S06的末尾地址稍往前提,实际因为0x0003D7FF) -fill 0xFF 0x00000000 0x00037FFC #填充0-0x37FFC区间的未用地址为0xff -crop 0x00000000 0x00037FFC # just keep code area for CRC calculation below , 保留这段区间的内容,排除除此范围内的其他数据 #-CRC16_Big_Endian 0x00037FFE -CCITT # calculate big endian CCITT CRC16 at given address., 为以上空间数据计算CRC16,并放置在0x00037FFE地址,2字节 -CRC32_Little_Endian 0x00037FFC -CCITT #CRC32 -crop 0x00037FFC 0x00038000 # keep the CRC itself #second: add application file lpcxpresso55s06_hello_world_image_length_MCUX.srec # input file -fill 0xFF 0x00000000 0x00037FFC # fill code area with 0xff -crop 0x00000000 0x00037FFC #-crop 0x10000000 0x10000170 0x10000172 0x10010000 #keep all except CRC #finally, produce the output file -Output # produce output lpcxpresso55s06_hello_world_image_length_MCUX_crc.srec      创建一个crc_file_convert.txt文件,也放在debug目录下,用于将上一步生成的最终image的srec文件转换为bin文件,用于生成或者比对 # srec_cat command file to add the CRC and produce application file to be flashed # Usage: srec_cat @filename #third: create bin file lpcxpresso55s06_hello_world_image_length_MCUX_crc.srec -o lpcxpresso55s06_hello_world_image_length_MCUX_crc.bin -binary 在IDE的Post build栏目添加如下命令:     arm-none-eabi-size "${BuildArtifactFileName}"   默认自带的统计image size功能 arm-none-eabi-objcopy -v -O binary "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin"    将image转成bin文件,用于后续使用和比对 arm-none-eabi-objcopy -v -O srec "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.srec" & srec_cat.exe @CRC_add.txt 填充image,计算CRC32,整合成新的srec image srec_cat.exe @CRC_file_convert.txt  将上一步得到的srec image转化为bin文件,用于后续使用和比对   《hello_world_image_length_MCUX》例程会自行统计应用程序的CRC32值,并于IDE产生的CRC32值做比对   这里需要注意的是,由于MCUX IDE是借助于外部工具来填充flash和计算CRC32,所以默认IDE调试和下载选择afx文件并不包含这些信息。当校验程序开始运行,会发生: 读写未写入的flash,对于LPC55系列会发生hardfault CRC32值并不存在 所以测试这个程序需要单独下载包含所有的srec文件或者bin文件,而不是默认的afx文件。      
View full article
1    introduction The doc demonstrates how to use MRT(Multi-rate Timer) module to implement the delay function, the delay time is programmable. The MRT has a One-shot stall mode, with the mode, while the MRT channel counter counts down, the core stalls until the MRT channel counter reaches to zero. After the MRT channel counter reaches to zero, the MRT channel becomes idle, the core continues to work.   2 delay function description Sometimes, it is expected that there is a programmable delay between two instructions, for example Instruction 1 Delay Instruction 2 In general, the delay function can be implemented by forcing the core to execute __asm(“NOP”) instructions This code is like: Void delay(uint32_t interval) {        Uint32_t counter;        Counter=ConvertTimeToCounter(interval);        For(uint32_t i=0; i<counter); i++)        {        __asm(“nop”)        } }   The macro convertTimeToCounter is used to convert a time to a number of loop   1.   MRT feature The MRT module of LPC family provides a unique feature called One-shot stall mode, because the test is based on LPC55S69-EVK board, so I referred to the section 27.5.3 One-shot stall mode in UM11126.pdf. The MRT does not have external pad.   One-shot stall mode: Bus stall mode can be used when a short delay is need between two software controlled events, or when a delay is expected before software can continue. Since in this mode there are no bus transactions while the MRT is counting down, the CPU core stalls, consumes a minimum amount of power during that time until the MRT counter reaches to zero. Therefore the One-shot stall mode of MRT can make core stall during the MRT counting down process, the delay function can be implemented.   3 MRT clock source and delay time For the LPC55S69, the clock source of MRT module is the AHB Bus clock, which is the same as the core clock. For the LPC55S69 example, there is the code to set up the core clock void BOARD_InitBootClocks(void) {     BOARD_BootClockPLL150M(); } So the  MRT clock frequency is 150MHz.       The delay time is a time, but the MRT is a counter, so the delay time must be converted to the counter value. The counter value is dependent on the MRT clock frequency. The MRT clock source is AHB bus clock, or the core clock. The LPC55S69 core clock frequency is 150Mhz, so we can define #define MRT_CLOCK_FREQUENCY 150MHz If the required delay time is delay_time variable in second unit, the required MRT counter value is   MRT counter value=delay_time/(MRT clock cycle time)=delay_time* MRT_CLOCK_FREQUENCY.   For example, assume the required delay_time is 1mS or 1*10**(-3)  Second, the corresponding counter value is 1*(10**-3)*150*(10**6)=150 000   The MRT delay time restriction. The MRT counter register is 24 bits, the maximum counter value is 2**24= 16,777,216, the maximum delay time is 16777216/(150*10**6)=0.111848 S or 111 mS.     3 source code description MRT delay function source code is based on SDK package SDK_2_11_1_LPCXpresso55S69.zip, the tools is MCUXpresso IDE v11.5.0. The example is run on LPC55S69-EVK The example uses MRT to delay 100mS(0.1 Second), after the delay, a LED is toggled The MRT counter value is 0.1S*150*(10**6)=15 000 000   For the mrt_init() api function, it initializes the MRT and set the MRT channel0 in OneShotStall mode. Once the core executes the line MRT_StartTimer(MRT0, kMRT_Channel_0, 15000000); the MRT channel0 counter will count down from 15000000, during the counting process the Cortex-M33 will stall. After the counter reach to ZERO, the core finishes the stalling mode and continues to execute the next line, the MRT channel0 counter will be in idle mode.       /**  * @file    LPC55S69_Project_mrt_stall.c  * @brief   Application entry point.  */ #include <stdio.h> #include "board.h" #include "peripherals.h" #include "pin_mux.h" #include "clock_config.h" #include "LPC55S69_cm33_core0.h" #include "fsl_debug_console.h" #include "fsl_mrt.h" #include "fsl_iocon.h"   /* TODO: insert other include files here. */ #define BOARD_LED_PORT BOARD_LED_BLUE_GPIO_PORT #define BOARD_LED_PIN  BOARD_LED_BLUE_GPIO_PIN /* TODO: insert other definitions and declarations here. */ void mrt_init(void); /*  * @brief   Application entry point.  */ int main(void) {       /* Init board hardware. */     BOARD_InitBootPins();     BOARD_InitBootClocks();     BOARD_InitBootPeripherals(); #ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL     /* Init FSL debug console. */     BOARD_InitDebugConsole(); #endif     mrt_init();     PRINTF("Hello World\n");     for(;;)     {     MRT_StartTimer(MRT0, kMRT_Channel_0, 15000000);     GPIO_PortToggle(GPIO, BOARD_LED_PORT, 1u << BOARD_LED_PIN);     __asm("nop");       }     /* Force the counter to be placed into memory. */     volatile static int i = 0 ;     /* Enter an infinite loop, just incrementing a counter. */     while(1) {         i++ ;         /* 'Dummy' NOP to allow source level single stepping of             tight while() loop */         __asm volatile ("nop");     }     return 0 ; }   uint32_t mrt_clock; mrt_config_t mrtConfig; void mrt_init(void) {           /* mrtConfig.enableMultiTask = false; */         MRT_GetDefaultConfig(&mrtConfig);           /* Init mrt module */         MRT_Init(MRT0, &mrtConfig);           /* Setup Channel 0 to be repeated */         MRT_SetupChannelMode(MRT0, kMRT_Channel_0, kMRT_OneShotStallMode);           //MRT_StartTimer(MRT0, kMRT_Channel_0,  15000000);   }       }                                                                                                              When the above code is running, user can see the blue LED toggles on the LPC55S69-EVK board. Connecting the PIO1_4 pin signal ( the pin 5 of P18 connector) on LPC55S69-EVK, the PIO1_4 signal toggling frequency is 5Hz, the cycle time is 200mS, so the delay is 100mS.      
View full article
For the LPC8xx family, the peripheral module input or output signals are not connected to external pads fixedly as most processor does . With SWM module, the peripheral module input or output signals can be routed to any external GPIO pins via software configuration There is special requirement that one peripheral output signal functions as the input signal of another peripheral, in the case, the peripheral output signal and the peripheral input signal can be routed to the same pad via SWM so that the input and output signals are connected internally without external cable. The LPC802 has ACOMP module, CTimer module and SWM module, per customer requirement, the ACOMP output signal and CTimer0 capture 0 input signal can be routed to the same GPIO pin without external connection so that the ACOMP output signal can trigger CTimer0 capture 0 event internally. In the doc, I give the code to configure the CTimer, ACOMP and the SWM, explain the configuration,introduce the tools, board and result.  
View full article