MQX软件解决方案知识库

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MQX Software Solutions Knowledge Base

讨论

排序依据:
A pair of TCP server & client and a pair UDP server & client are implemented to demo socket API in RTCS. It supports K60N512 and K70F120M on IAR EWARM 6.50 at this moment. You can port it to other boards and IDE easily. 1) Copy Freescale_MQX_4_0 folder and override the default MQX folder 2) RTCS Socket Example Guide.doc can be found in ..\Freescale_MQX_4_0\rtcs\examples\socket
查看全文
Sharing notes taken during creation of MQX 4.0 K10 BSP. These particular notes are for 72 MHz version of K10 (part number K10DX128VLL7), so the baseline BSP for this is twrk20d72m, tested with CodeWarrior IDE. (I believe analogous steps could be taken for other K10 versions as well, just need to select appropriate baseline BSP.) For the K10 BSP, we need to remove USB related code (as there is no USB module on K10) and add #elif into some *mk20.c files such as adc_mk20.c and spi_mk20.c.      1. Add a new unique CPU ID into c:\Freescale\Freescale_MQX_4_0\mqx\source\psp\cortex_m\psp_cpudef.h. For example: #define PSP_CPU_MK10DX128       (PSP_CPU_NUM(PSP_CPU_ARCH_ARM_CORTEX_M4, PSP_CPU_GROUP_KINETIS_K1X, 4))      2. Copy processor header file MK10D7.h from c:\Freescale\CW MCU v10.3\MCU\ProcessorExpert\lib\Kinetis\iofiles\MK10D7.h to c:\Freescale\Freescale_MQX_4_0\mqx\source\psp\cortex_m\cpu\mk10d7.h      3. In the header file: c:\Freescale\Freescale_MQX_4_0\mqx\source\psp\cortex_m\kinetis.h add #include "MK10D7.h" for your processor. For example: #elif   (MQX_CPU == PSP_CPU_MK10DX128)    #include "MK10D7.h"      4. Use BSP clone tool to clone baseline BSP (twrk20d72m) into a new BSP with a new name such as "board_k10d72m".      5. In user_config.h of the new BSP, c:\Freescale\Freescale_MQX_4_0\config\board_k10d72m\user_config.h change MQX_CPU as it follows: #define MQX_CPU                 PSP_CPU_MK10DX128      6. PSP builds OK. From BSP, we need to remove USB related code in init_gpio.c comment lines 609 and 612 c:\Freescale\Freescale_MQX_4_0\mqx\source\bsp\board_k10d72m\init_gpio.c: /* SIM_SOPT2_REG(SIM_BASE_PTR) |= SIM_SOPT2_USBSRC_MASK | SIM_SOPT2_PLLFLLSEL_MASK;*/ /* SIM_SCGC4_REG(SIM_BASE_PTR) |= SIM_SCGC4_USBOTG_MASK;*/      7. In CW IDE, remove USB source code from "bsp_board_k10d72m" build project under "Peripheral IO Drivers". Remove complete "usb" virtual folder from the BSP build project. Remove "init_usb.c" from "board_k10d72m BSP Files"      8. In BSP source file "spi_mk20.c" c:\Freescale\Freescale_MQX_4_0\mqx\source\io\spi\spi_mk20.c add #elif for k10: #elif (MQX_CPU == PSP_CPU_MK10DX128) static const pointer dspi_address[] = {    (pointer)SPI0_BASE_PTR,    (pointer)SPI1_BASE_PTR, }; static const uint_32 /*PSP_INTERRUPT_TABLE_INDEX*/ dspi_vectors[][1] = {    { INT_SPI0 },    { INT_SPI1 }, }      9. Similar change need to adc_mk20.c c:\Freescale\Freescale_MQX_4_0\mqx\source\io\adc\kadc\adc_mk20.c: #elif (MQX_CPU == PSP_CPU_MK10DX128) static const pointer adc_address[] = {    (pointer)ADC0_BASE_PTR,    (pointer)ADC1_BASE_PTR };      10. BSP project builds OK.      11. MFS, RTCS, SHELL projects build OK.      12. If you wish to build an MQX application with this new BSP, don't forget to change the paths to MQX libs and include files in your application project: C compiler "-i" option:   (for Debug build configuration)     $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\bsp     $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\psp     $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\     $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\mfs     $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\rtcs     $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\shell     $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\bsp\Generated_Code Linker additional libraries:   psp.a, bsp.a, mfs.a, rtcs.a, shell.a Linker Library search paths:   $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\bsp   $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\psp   $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\mfs   $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\rtcs   $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\shell Path to linker command file:   $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\bsp\intflash.lcf
查看全文
Table of Contents Product Information on Freescale.com MQX Software Solutions Product Summary Page MQX Software Solutions Documentation MQX Software Solutions Downloads MQX Software Solutions Training Frequently Asked Questions (FAQ) General MQX FAQs Technical MQX FAQs Other Resources MQX Training Videos MQX Add-On Software
查看全文
The attached document explains how to create a C++ project using CW10.6 with GCC compiler, MQX 4.1. Regards, Carlos
查看全文
It took me a while, plus a few contradicting and confusing answers from ARM support until I managed to make this work. Therefore, I do want to share with you the easiest method in order to save you some precious time (tested with MQX 4.0): 1. Make sure to install keil's TAD plugin during the MQX installation (it can also be installed separately from MQX\tools\keil_extensions\uVision4). 2. Make the following changes in the MQX configuration file "user_config.h": #define BSPCFG_ENABLE_IODEBUG   1 #define BSP_DEFAULT_IO_CHANNEL  "iodebug:" 3. Rebuild BSP debug library. 4. Configure Debugger as detailed in your MQX release documentation, which can be found in the following folder: MQX\doc\tools\uv4\MQX-uVision4-Getting-Started.pdf That's it, you're good to go - now you can see printf's using your uVision4 IDE console!
查看全文
Hi Community, Based on How to add RTCS to a Processor Expert Project Using KDS and KSDK​,  below you can find the steps to include MFS and Shell to a KDS3.0 project using KSDK1.2 and Processor Expert. Thank you Carlos_Musich for his great document and for providing the draft of this document. Regards, Isaac Avila
查看全文
Hi Community members:   Here you can find the source code of a MSD ftp server, it is implemented on the  MQX 4.2 using the FRDM-K64 and IAR 7.40.3. The USB storage device should be connected to the board and the board to a Ethernet network. In this demo, usb stick is mounted as a:/ You can upload or download files saved in the memory device.   I hope this can be helpful.   Best regards Daniel Original Attachment has been moved to: shell.zip
查看全文
Store web pages externally step by step Web pages can be stored on any media accessible via MFS, such as USB memory stick, SD card. It is also possible to use FFS and store web pages on NAND flash. The following example is a step by step guide on how MQX can use nandflash on TWR-K70F120M, we start with the httpsrv demo. 1. Add FTP server  and nandflash flush support This demo starts with default HTTPSRV example, Shell console is enabled in the default httpdsrv.c. Ping, ipconfig and help commands are enabled by default. We add ftpsrv application to support FTP protocol , and nandflash support. 2. Allow RTCS for more sockets We will use two TCP servers. There is one socket need for HTTPSRV listening socket, second listening socket for FTP server. One socket for each connected client. 3 .Add MFS library to the HTTPSRV build project By default, MFS library is not enabled in the HTTPSRV project. It uses only TFS for web pages storage. We add path to MFS library into HTTPSRV build project   4. Add FFS support to the HTTPSRV build project Ffs library is not enabled by default. We need to add path into HTTPSRV build library. Install FFS driver and open it. 5. Resolve build errors When we try to build now the HTTPSRV example, we have compile errors. This is because by default the HTTPSRV example does not include MFS and FFS library head files. We need to add a path for MFS and FFS 6. Configure HTTPSRV root directory Web pages of this demo are to be stored in nandflash within web_pages folder. We need to set rootdir and index Before we can view the web page in browser, we need to copy web pages to nand flash. This is the purpose of FTP server, as one example how to copy files. If you wish to be sure the web pages survive power cycle, make sure you flush the FFS file system after “web_pages” are copied. 7. Build, Download, Execute As hardware we use TWR-K70F120M and TWR-SER. After you download the executable and run, start FTP server by issuing command “ftpsrv  start” on serial console; start FTP client; copy over files from PC host to TWR nandflash. Keep the folder structure of the copied files; now open your web browser (support for HTML5 is required); open Url http://192.168.1.202
查看全文
Hi All, The new Freescale MQX™ 4.1.1 GA release is now available on www.freescale.com/mqxrtos ·         Files available           # Name Description 1 FSL_MQX_RELEASE_NOTES_4_1_1 Freescale   MQX™ RTOS 4.1.1 Release Notes 2 Freescale   MQX RTOS 4.1.1 for Linux This   release has the same basic code as the 4.1.1 version, with just the changes   needed to build and debug on Linux systems. 3 Freescale   MQX RTOS 4.1.1 MQX™    Source code. Includes an RTOS, File System, TCP/IP and USB host/device   software stacks. ·         What is New? ·         New Board Support Package o   FRDM-K64F o   TWR-K64F120M ·         New Features and Updates o   MQX RTOS 4.1.1 enables development on Linux machines o   MQX RTOS 4.1.1 supports the new Freescale IDE, Kinetis Design Studio o   Example ISR and related documentation is updated to give guidance on setting up a Kernel ISR (a.k.a Gorilla ISR) - extremely high priority ISR o   Power PC (PX) family support has been dropped o   Readme files are added to examples without a description o   Register definition header files for Kinetis MCUs are added for convenience when porting to an MCU sub-family device o   Both interrupt driven I2C master and slave mode drivers are changed to support synchronous blocking mode and share the same API with the polling driver variant.  Improves performance by eliminating the need to poll for data availability. ·         Known issues o   For known issues and limitations please consult the release notes
查看全文
Freescale MQX incluye un BSP que soporta funciones y periféricos comúnmente usados. Sin embargo en aplicaciones muy específicas puede ser necesario el desarrollo o modificación de uno o varios “Drivers”. El siguiente documento explica cómo crear y agregar un nuevo driver al BSP en MQX. El documento está escrito en español. Espero que les sea útil. Saludos Sol
查看全文
MQX 4.1.0 provides a USB Host CDC demo in the folder of "C:\Freescale\Freescale_MQX_4_1\usb\host\examples\cdc\cdc_serial", but to get it work, several steps need to be done: 1. Change CDC_EXAMPLE_USE_HW_FLOW in cdc_serial.h to 1. #define CDC_EXAMPLE_USE_HW_FLOW 1 2. In config\twrk70f120m\user_config.h, interrupt mode for UART should be set.//It depends on the platform, here given TWR-K70F120M is used. #define BSPCFG_ENABLE_TTYC 0 #define BSPCFG_ENABLE_ITTYC 1 In mqx\source\bsp\twrk70f120m\twrk70f120m.h, specify 'ittyc' instead of 'ttyc' #ifndef BSP_DEFAULT_IO_CHANNEL #if BSPCFG_ENABLE_ITTYC #define BSP_DEFAULT_IO_CHANNEL "ittyc:" /* OSJTAG-COM polled mode */ #define BSP_DEFAULT_IO_CHANNEL_DEFINED #else #define BSP_DEFAULT_IO_CHANNEL NULL #endif #else 3. In usb\host\source\classes\cdc\usb_host_cdc.c, pass fd_ptr instead of data_instance as the argument. a. Around line 977 //usb_hostdev_tr_init(&#38;tr, (tr_callback) usb_class_cdc_in_data_callback, (void *) data_instance); usb_hostdev_tr_init(&#38;tr, (tr_callback) usb_class_cdc_in_data_callback, (void *) fd_ptr); b. Around line 1116 //usb_hostdev_tr_init(&#38;tr, (tr_callback) usb_class_cdc_in_data_callback, (void *) data_instance); usb_hostdev_tr_init(&#38;tr, (tr_callback) usb_class_cdc_in_data_callback, (void *) fd_ptr); c. Around line 1226 //usb_hostdev_tr_init(&#38;tr, (tr_callback) usb_class_cdc_out_data_callback, (void *) data_instance); usb_hostdev_tr_init(&#38;tr, (tr_callback) usb_class_cdc_out_data_callback, (void *) fd_ptr); With above modification , the Host CDC demo can work with a Device CDC demo, such as the one in "C:\Freescale\Freescale_MQX_4_1\usb\device\examples\cdc\virtual_com", which is an echo demo, it would send back anything charactor that it receives. But to see the echo more clearly, I made it echo back the charactor that greater than what is received, for example, if you type A, and will see B from the HyperTerminal. To do that , you have to change Virtual_Com_App(void) in the virtual_com.c as below: void Virtual_Com_App(void) {     /* User Code */     if(g_recv_size)     {         _mqx_int i;                 /* Copy Buffer to Send Buff */         for (i = 0; i < g_recv_size; i++)         {             printf("Copied: %c\n", g_curr_recv_buf[i]);             g_curr_send_buf[g_send_size++] = g_curr_recv_buf[i]+1;         }         g_recv_size = 0;     }         if(g_send_size)     {         uint8_t error;         uint8_t size = g_send_size;         g_send_size = 0;         error = USB_Class_CDC_Send_Data(g_app_handle, DIC_BULK_IN_ENDPOINT,             g_curr_send_buf, size);         if (!error && !(size % DIC_BULK_IN_ENDP_PACKET_SIZE)) {             /* If the last packet is the size of endpoint, then send also zero-ended packet,             ** meaning that we want to inform the host that we do not have any additional             ** data, so it can flush the output.             */             error = USB_Class_CDC_Send_Data(g_app_handle, DIC_BULK_IN_ENDPOINT, NULL, 0);         }         if(error != USB_OK)         {             /* Failure to send Data Handling code here */         }     }     return; } After you download code into, for example, TWR-K70F120(Host) and TWR-K60D100M(Device), and assemble them with TWR-SER and TWR-ELEV, you may connect them via USB port as below: Please also pay attention to J10(USB VBUS Select) and J16(USB Mode Select) according to the function of each tower system. With HyperTerminal connected with TWR-K70F120M system, you may type in any charactor ended with ENTER, and you will see the charactor echoed back as the attached video. This issue would be fixed in the next release, and sorry for the inconvenience that has caused.
查看全文
TWR-K70F120M running MQX and RTCS can work with the Dual Phy on TWR-SER2. Below I list the modifications I did to the default BSP: 1) I add phy_dp83xxx.c and phy_dp83xxx.h to the bsp_twrk70f120m build project. These files are with MQX in /mqx/source/io/enet/Phy 2) I modify the BSP to use DP83xxx PHY for the Ethernet MACNET: in the /mqx/source/bsp/twrk70f120m/init_enet.c: #include "phy_dp83xxx.h" const ENET_IF_STRUCT ENET_0 = {      &MACNET_IF,      //&phy_ksz8041_IF,      &phy_dp83xxx_IF,      MACNET_DEVICE_0,      MACNET_DEVICE_0,      BSP_ENET0_PHY_ADDR,      BSP_ENET0_PHY_MII_SPEED }; 3) MDIO line requires an external pull up resistor, per DP83849I Data sheet. As I didn't have one at the moment, I enable internal pull up on MCU pin PTB0. in the /mqx/source/bsp/twrk70f120m/init_gpio.c: //pctl->PCR[0] = PORT_PCR_MUX(4) | PORT_PCR_ODE_MASK; /* PTB0, RMII0_MDIO/MII0_MDIO   */ /* PTB0, RMII0_MDIO/MII0_MDIO   */ /* internal pull up enabled on MDIO */ pctl->PCR[0] = PORT_PCR_MUX(4) | PORT_PCR_ODE_MASK | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK; With these changes, the RTCS applications work over TWR-SER2 Dual PHY channel A. On TWR-SER2, J8 and J9 are un-shunted, SW1 = 11000000, SW2 = 10100000 on TWR-K70F120M, J18 is configured to disable 50 MHz OSC, as I use 50 MHz clock source from TWR-SER2 U504 50 MHz output. This clock is used to provide reference clock for the MCU (EXTAL), as well as for the Dual PHY X1 input (RMII reference clock).
查看全文
Hello all, This document describes how to create a FreeRTOS project in KDS using the Kinetis SDK Project Generator tool. If you are interested in how to Create a FreeRTOS project using KDS and Kinetis SDK Project V2.0 please check the below link: https://community.freescale.com/docs/DOC-330183 In order to follow this document, first it is necessary to install: Kinetis Design Studio (KDS) Kinetis Design Studio Integrated Development |NXP KINETIS-SDK: Software Development Kit for Kinetis MCUs Software Development Kit for Kinetis MCUs|NXP KSDK Project Generator tool Software Development Kit for Kinetis MCUs|NXP Creating a new project using the Project Generator tool Kinetis SDK Project Generator tool is a supplement to the KSDK. It is intended to provide users with a convenient method for generating KSDK based projects for their intended target hardware. The KSDK Project Generator requires the user to install an instance of KSDK 1.2.0 or 1.3.0 before generating new projects. The KSDK Project Generator requires operates on Windows, Linux, and Mac OSX. 1. Launch the Project Generator executable. 2. Introduce the Project Name and choose the board used. For this example it is used the TWR-K64F120M. 3. In order to generate a FreeRTOS project, click on the "Advanced" button. 4. Choose the operating system, in this case FreeRTOS, the IDE KDS and select Generate standalone project. 5. After that, click on "Advanced Generate" button to create the project. Open the project in KDS Every application/example created using the KSDK Project Generator tool has one associated working set description file which includes the path to the example project file and the dependent RTOS library project file. Simply import that file into KDS working space. At this point you should be able to build the library and the project created. Developing a FreeRTOS with KSDK application Operating System Abstraction layer (OSA) provides a common set of services for drivers and applications so that they can work with or without the operating system. OSA provides these services: task management, semaphore, mutex, event, message queue, memory allocator, critical part, and time functions. An easy method to create a task is using  the OSA_TASK_DEFINE macro and the function OSA_TaskCreate(). The macro OSA_TASK_DEFINE declares a task handler and task stack statically. The function OSA_TaskCreate() creates task base-on the resources declared by OSA_TASK_DEFINE. The parameters for this function are: The stack size in byte. Pointer to the stack. The stack size in byte. Pointer to the stack. Initial priority of the task: OSA supports task priorities 0∼15, where priority 0 is the highest priority and priority 15 is the lowest priority. Pointer to be passed to the task when it is created. If this task will use float register or not. Pointer to the task handler. NOTE: The disadvantage with this method is that task function can only create one task instance. The project created using the Project Generator tool creates one  task (task_example) implementing OSA. For more information about functions, macros and drivers please consult the Kinetis SDK v.1.3 API Reference Manual. This is located, after install Kinetis SDK, at the path: <install_KSDK_1.3.0_path>\doc GPIO Example 1. Add a new task named task_led. Add also a macro for OSA_TASK_DEFINE, the priority of the task and the prototype. To initialize and start RTOSes, OSA uses abstract functions OSA_Init() and OSA_Start(). Call OSA_Init() after calling hardware_init(). 2. Create the empty body of task_led 3. Add the following code initialization code for GPIO driver. PRINTF("\nLED TASK is running \n"); /* Enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); //Initializes GPIO driver GPIO_DRV_Init(switchPins, ledPins); 4. Now add logic to toggle a LED when a button is pressed. while(1) { //  check if SW2 is pressed if(GPIO_DRV_ReadPinInput(kGpioSW3) == 0) { GPIO_SW_DELAY; GPIO_DRV_TogglePinOutput(BOARD_GPIO_LED_BLUE); } } 5. It is needed a delay for the push buttons debounce. In this case it is GPIO_SW_DELAY which is defines as follows: /*Delay for Switch debounce*/ #define GPIO_SW_DELAY \ do \ { \ uint32_t i; \ for (i = 0; i < 0x2FFFFF; i++) \ { \ __asm("nop"); \ } \ } while (0) GPIO 6. Build and debug the project. Enjoy...
查看全文
The attached document shows how to get the MQX4.1 Virtual Com Port Example. This document is located in the following path: C:\Freescale\Freescale_MQX_4_1\usb\device\examples\cdc\virtual_com Regards, Carlos
查看全文
The Freescale MQX Software Solution includes a comprehensive Board Support Package (BSP) supporting common peripherals and functions. However, some applications will require customization of the available drivers or the development of new ones. Pulse width modulation (PWM) is a technique used to encode a message into a pulsing signal. PWM is in used in an extensive variety of applications, ranging from motor control, measurement and communications to power control and conversion, among others. PWM driver is not part of the MQX however there is possible to add your own driver. The purpose of this document is show two different ways to implement PWM signal using MQX and Kinetis devices: a) using bareboard code b) using processor expert in order to create a driver. USING BAREBOARD CODE: As there is no MQX driver for FTM peripheral, customers should create their own drivers. The AN3902 application note guides developers through the process of creating and testing I/O drivers under MQX. http://cache.freescale.com/files/32bit/doc/app_note/AN3902.pdf A simple PWM code can be as simple as shown below: /*Using FTM2_CH0 FTM2_CH1 output PWM with 90% high, 10% low wave*/ void FTM_EPWM(void) { SIM_SCGC6 |= SIM_SCGC6_FTM2_MASK;          SIM_SCGC3 |= SIM_SCGC3_FTM2_MASK;             PORTA_PCR10 = (0|PORT_PCR_MUX(3)); /* FTM2_CH0 enable on PTA10 */        PORTB_PCR18 = (0|PORT_PCR_MUX(3)); /* FTM2_CH0 enable on PTB18 */        PORTA_PCR11 = (0|PORT_PCR_MUX(3)); /* FTM2_CH1 enable on PTA11 */        PORTB_PCR19 = (0|PORT_PCR_MUX(3)); /* FTM2_CH1 enable on PTB19 */        FTM2_MOD = 0x0063;  /* 0x0063 / 60MHz = 1.6666uS PWM period */        /* Configure timers for edge aligned PWM High True Pulses */        printf("FTM2_ Edge_Aligned Test 1\r\n");        printf("Please check the waveform, 90% High True EPWM\r\n");        FTM2_C0SC = 0x28; /* No Interrupts; High True pulses on Edge Aligned PWM */        FTM2_C1SC = 0x28;         FTM2_C0V = 0x005A;  /* 90% pulse width */        FTM2_C1V = 0x005A;         FTM2_SC = 0x08;     /* Edge Aligned PWM running from BUSCLK / 1 */ } The function shown above can be called from any MQX task. Only care will be in case interrupts are needed for FTM application. There are two ways to add user interrupts into an MQX system - kernel_isr or MQX managed isr. Kernel_isr is fast but it bypasses MQX, thus, no MQX API function can be called from such a kernel_isr. MQX managed isr is slower, as it runs dispatcher in case a higher priority task becomes ready during isr. USING PROCESSOR EXPERT IN ORDER TO CREATE A DRIVER: All MQX BSP's are PE capable and Processor Expert is integrated with CodeWarrior and KDS but it is also a standalone tool that can generate code for IAR, Keil, GCC, etc. http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=PE_DRIVER_SUITE&tid=PEH There is an easy way to add device drivers to the MQX RTOS BSP using PE. It is necessary to activate the PE views, for do that go to Processor Expert -> Show Views Show PE views After select the PE views there is possible to look at the properties of the each component. For example, the below figure shows the properties of the MQX1 component.  Component MQX1 The below figure shows the Cpu component, here it is possible to modify the clock configurations, it is possible to find more information about this in the MQX_CW10_Getting_Started document located, after install MQX, at the path: <Freescale_MQX_4_2>\doc\tools\cw. Component CPU In order to configure a PWM signal using PE, it is necessary to follow these steps:      1. Select the PWM component. Component PWM      2. By default, the PWM component configures Channel 0 in Flex Timer 0 a PWM of 4096 timer-ticks, however it is possible to modify this values according the needs. Component PWM properties.       3. Besides Properties, Components also include Methods and Events that it is possible to enable or disable. Methods and events. Methods are user-callable functions/subroutines intended for the component functions control. Init: Initializes the device. Allocates memory for the device data structure, allocates interrupt vectors and sets interrupt priority, sets pin routing, sets timing, etc. If the property "Enable in init. code" is set to "yes" value then the device is also enabled (see the description of the Enable method). In this case the Enable method is not necessary and needn't to be generated. This method can be called only once. SetPeriodTicks: The method sets timer re-initialization period (in timer ticks). This method is available only if the property "Counter restart" is switched to 'on-match' value. ResetCounter: Resets counter. If counter is counting up then it is set to zero. If counter is counting down then counter is updated to the reload value. The method is not available if HW doesn't allow resetting of the counter. GetCounterValue: Returns the content of counter register. This method can be used both if counter is enabled and if counter is disabled. The method is not available if HW doesn't allow reading of the counter. SetOffsetTicks: Sets the new offset value to channel specified by the parameter ChannelIdx. It is user responsibility to use value below selected period. This method is available when at least one channel is configured. GetCaptureValue: Returns the content of capture register specified by the parameter ChannelIdx. This method is available when at least one channel is configured. Events are call-back functions called when an important event occurs. OnCounterRestart: Called if counter overflow/underflow or counter is reinitialized by modulo or compare register matching. OnCounterRestart event and Timer unit must be enabled. This event is available only if an Interrupt is enabled. OnChannel(x): Called if compare register match the counter registers or capture register has a new content. OnChannel(x) event and Timer unit must be enabled. This event is available only if an Interrupt is enabled.      4. If there is some change click on Generate Code and Build the project:      5. The PWM driver was created. In order to use the driver it is necessary to create a new MQX project.      6. For this example, we will edit the main task that is defined after create a new MQX project. To use PE driver some ‘handler’ variables must be declared:        7. It is necessary to initialize the component.    8. To enable de component, the PWM_Enable() function is required .       9. Finally implement the events.      10. At this point you should be able to build and run the example. Remember to check the jumper settings for the board you are using in order to debug a MQX example. The Getting Started with Freescale MQX™ RTOS document provides board-specific information related to the MQX RTOS, this document is located at the path: <Freescale_MQX_4_2>\doc It is important to connect the tower board to the elevators and check the PWM signal on A67.   Below you can check the entire code: #include "main.h" #if !BSPCFG_ENABLE_IO_SUBSYSTEM #error This application requires BSPCFG_ENABLE_IO_SUBSYSTEM defined non-zero in user_config.h. Please recompile BSP with this option. #endif #ifndef BSP_DEFAULT_IO_CHANNEL_DEFINED #error This application requires BSP_DEFAULT_IO_CHANNEL to be not NULL. Please set corresponding BSPCFG_ENABLE_TTYx to non-zero in user_config.h and recompile BSP with this option. #endif TASK_TEMPLATE_STRUCT MQX_template_list[] = { /* Task number, Entry point, Stack, Pri, String, Auto? */ {MAIN_TASK,   Main_task,   1500, 9,   "main", MQX_AUTO_START_TASK}, {0,           0,           0,     0, 0,      0,                 } }; /*TASK*----------------------------------------------------- * * Task Name    : Main_task * Comments     : * This task prints " Hello World " * *END*-----------------------------------------------------*/ #define TERMINAL_CURSOR_POSITION_MAX    (80) static int                  pwm_task_count; static LDD_TDeviceData     *PWM_DeviceData; static LDD_TError           PWM_Error; volatile PWM_TValueType     PWM_Value; volatile PWM_TValueType     PWM_MaxValue; volatile PWM_TValueType     PWM_Step; volatile int                PWM_Freguency; void Main_task(uint32_t initial_data) {        static int terminal_cursor_position = 1;        printf("\n Hello World \n");        /* Initialize PWM device on FTM0 device */             puts("\nInitializing PWM device.....");            PWM_DeviceData = PWM_Init(NULL);            if (PWM_DeviceData == NULL)  {            puts("failed");                _task_block();            }            else  {                puts("done");            }            PWM_Value       = 0;            PWM_Step        = PWM_PERIOD_TICKS / 32;            PWM_MaxValue    = PWM_PERIOD_TICKS;            PWM_Freguency   = (PWM_CNT_INP_FREQ_U_0/PWM_PERIOD_TICKS);          printf("\n - PWM frequency              = %d Hz", PWM_Freguency);            puts("\nThe PWM signal is generated on FTM0 Channel 0");            puts("\n");            /* Enable PWM device */            PWM_Error = PWM_Enable(PWM_DeviceData);            while(1)            {                pwm_task_count++;                /* Suspend task for 250ms */                _time_delay(250);                /* Print dot on console to see that application is running */                if (terminal_cursor_position++ > TERMINAL_CURSOR_POSITION_MAX) {                    terminal_cursor_position = 1;                    puts("\n");                }                else {                    puts(".");                }            }        } void PWM_OnCounterRestart(LDD_TUserData *UserDataPtr) { /* Increment PWM duty-cycle from 0-100% */ PWM_Value += PWM_Step; if (PWM_Value > PWM_MaxValue) PWM_Value = 0; /* Set new PWM channel value */ PWM_Error = PWM_SetOffsetTicks(PWM_DeviceData, 0, PWM_Value); } /* EOF */
查看全文
When working on Cortex-M4 platform, an exception which has not been expected (an interrupt without ISR, an access to an illegal address, etc). The code below shows how to implement it. static void expt_frm_dump(pointer ext_frm_ptr) {   static char *expt_name[] = {     "None",     "Reset",     "NMI",     "HardFault",     "MemManage",     "BusFault",     "UsageFault",     "Rsvd",     "Rsvd",     "Rsvd",     "SVCall",     "Debug Monitor",     "Rsvd",     "PendSV",     "SysTick"   };   uint_32 excpt_num = __get_PSR() & 0x1FF;   printf("Opps, bad thing happened.\n");   if(excpt_num < 16){     printf("The exception [%s] invoked in TASK 0x%x\n",          expt_name[excpt_num] , _task_get_id());     printf("Dump the exception frame as :\n");     printf("R0:\t0x%08x\n", *((uint_32 *)ext_frm_ptr));     printf("R1:\t0x%08x\n", *((uint_32 *)ext_frm_ptr + 1));     printf("R2:\t0x%08x\n", *((uint_32 *)ext_frm_ptr + 2));     printf("R3:\t0x%08x\n", *((uint_32 *)ext_frm_ptr + 3));     printf("R12:\t0x%08x\n", *((uint_32 *)ext_frm_ptr + 4));     printf("LR:\t0x%08x\n", *((uint_32 *)ext_frm_ptr + 5));     printf("PC:\t0x%08x\n", *((uint_32 *)ext_frm_ptr + 6));     printf("PSR:\t0x%08x\n", *((uint_32 *)ext_frm_ptr + 7));   }else{     printf("The external interrupt %d occured while no handler to serve it.\n");   } } void  task_exception_handler(_mqx_uint para, pointer stack_ptr) {     pointer expt_frm_ptr = (pointer)__get_PSP();     expt_frm_dump(expt_frm_ptr); } void test_task(unsigned long para) {   unsigned int *p_bad = (unsigned int *)0;   printf("Install the _int_exception_isr to replace the _int_default_isr\n");   _int_install_exception_isr();   /* Set the exception handler of the task */   _task_set_exception_handler(_task_get_id(), task_exception_handler);   *p_bad = 0;     // an access to address 0    _task_block(); }
查看全文
Hello I want to share this document that describes steps to configure and use the MQXLite Performance Tool to analyze and debug the applications of the Freescale MQXLite operating system. I hope this helps!! Regards Soledad
查看全文
MQX RTCS Memory Configuration Parameters Introduction         RTCS uses some global variables when an application creates it. All the variables have default values. If you want to change the values, the application must do so before it creates RTCS. There are various configuration parameters that allow to fine tune RTCS memory usage. Next I will introduce the parameters, and I hope it will help beginners in configuration the RTCS correctly 1    _RTCSPCB / _RTCS_msgpool / _RTCS_socket_part RTCSPCB represents the pool of Packet Control Blocks - the number of packets you want RTCS to handle at any given time. RTCSPCB has influence on losing packets. RTCS_msgpool represents the pool of RTCS messages, used to encapsulate application requests to RTCS – the number of simultaneous application requests to RTCS. RTCS_Sockets represents the pool of sockets – the number of sockets in existence at any point in time. “_init” is pre-allocated count, allocation happens when RTCS starts. During runtime, when RTCS needs more of these resources, it allocates more by "_grow" chunks until the "_max" is consumed, which is the effective limit for RTCS resources. These parameters must be called before _RTCS_start By default these parameters are defined as RTCSCFG_PCBS_INIT, RTCSCFG_PCBS_GROW, RTCS_PCBS_MAX, RTCSCFG_MSGPOOL_INIT, RTCSCFG_MSGPOOL_GROW, RTCSCFG_PCBS_MAX, RTCSCFG_SOCKET_PART_INIT, RTCSCFG_SOCKET_PART_GROW,  RTCSCFG_SOCKET_PART_MAX. In application we can override these defaults by _init, _grow, _max. We also can override these in user_config.h. How to configure these parameters?   We don’t have a formal method how to configure these for a specific application. We can start with the defaults and then spent some time increasing these parameters, then we can use RTCS TAD window to see, what RTCS resources are out. Then increase the one a bit. Example:  the configuration in web_hvac demo _RTCSPCB_init = 4; _RTCSPCB_grow = 2; _RTCSPCB_max = 20; _RTCS_msgpool_init = 4; _RTCS_msgpool_grow = 2; _RTCS_msgpool_max  = 20; _RTCS_socket_part_init = 4; _RTCS_socket_part_grow = 2; _RTCS_socket_part_max  = 20; RTCS_Create(); 2  Tx Window Size and Rx Window Size Each socket requires to allocation Tx and Rx window size for a listening socket and then for each connected client.  The default tx window size and rx window size are 4380 bytes. With TAD, we can see that every new TCP socket connection needs extra 500+4392x2+148=9432B   as follows: MQX -> Lightweight Memory Block Summary Size (Decimal) Owner    Type 500      0x10001 TCP Control Block;RTCS/TCP 4392 0x10001  TCP Tx Window;RTCS/TCP 4392 0x10001  TCP Rx Window;RTCS/TCP 148 0x10001  TCP Send Clock;RTCS/TCP (TCP/IP Task id is 0x10001) If we call setsockopt() to reduce these two buffers, for example,            uint_32 value; … value = 1024; setsockopt(sock, SOL_TCP,OPT_TBSIZE,&value,sizeof(value)); setsockopt(sock, SOL_TCP,OPT_RBSIZE,&value,sizeof(value)); The memory usage to open a new TCP socket will drop as follows: MQX -> Lightweight Memory Block Summary Size (Decimal) Owner    Type 500  -> 500   0x10001  TCP Control Block;RTCS/TCP 4392 -> 1108   0x10001 TCP Tx Window;RTCS/TCP 4392 -> 1108   0x10001  TCP Rx Window;RTCS/TCP 148  -> 84   0x10001  TCP Send Clock;RTCS/TCP So we can see that, every new socket connection needs extra 500+1108*2+84=2800
查看全文
Hi everybody, Some times it is necessary to work with short interrupts in MQX or get smaller delays. MQX measures time in ticks, instead of in seconds and milliseconds. This document describes how to get a smaller delay or Interrupt, editing the BSP_ALARM_FREQUENCY in order to have smaller ticks. In addition the document shows how to use the MQX hwtimer driver. I hope you like it. Best regards, Soledad Godinez Technical Support Engineer
查看全文
If you have noticed many TCP Retransmission, Out Of Order or Duplicate Acknowledge packets while running a TCP/IP application based on MQX RTCS then you may be interested in this article. After some investigation it comes to be that the default value of global variable _TCP_rto_min may cause this congestion depending on your application. Finally this problem was solved by setting a new value to this variable after calling function RTCS_create(). This article explains what is behind this behavior and how _TCP_rto_min affects the performance in an application using RTCS.
查看全文