MQX Software Solutions Knowledge Base

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

MQX Software Solutions Knowledge Base

Discussions

Sort by:
Hello All, Next document lists the steps needed to install a basic NIO driver in MQX for KSDK 1.3. In this document, a basic SPI driver for FRDM-K64F was created in order to serve as guidance for any user's driver. Source and header file for this NIO SPI are attached as well as hello.c source files that was taken from hello_world example in order to test this driver. I hope you can find it helpful! Best Regards, Isaac Avila
View full article
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...
View full article
Hello All, This document explains how to add GPIO pins to the default BSP configurations. This example shows how add a LED pin for the BSP TWR-K70FN1M board. The procedure is the same for other ports and peripherals, using Kinetis devices. MODIFY THE TWRK70F120M.h FILE The TWR-K70F120M Tower Module contains two pushbutton switches connected to GPIO/interrupt signals, one pushbutton connected to the master reset signal, four capacitive touch pad electrodes, four user controllable LEDs, and a potentiometer connected to an ADC input signal. The following table provides details on which K70FN1M0 pins are used to communicate with the LEDs and switches onboard the TWR-K70F120M.  Feature Connection Port Pin Pin Function Pushbuttons SW1 (IRQ0) PTD0 PTD0 SW2 (IRQ1) PTE26 PTE26 SW3 (RESET) RESET_b RESET_b LEDs E1 / Orange LED PTA11 PTA11 E2 / Yellow LED PTA28 PTA28 E3 / Green LED PTA29 PTA29 E4 / Blue LED PTA10 PTA10 Touch Pads E1 / Touch PTA4 TSI0_CH5 E2 / Touch PTB3 TSI0_CH8 E3 / Touch PTB2 TSI0_CH7 E4 / Touch PTB16 TSI0_CH9 Table 1. I/O Connectors and Pin Usage Table NOTE: Some port pins are used in multiple interfaces on-board and many are potentially connected to off-board resources via the Primary and Secondary Connectors. Take care to avoid attempted simultaneous usage of mutually exclusive features. For more information please consult the “TWR-K70F120M Tower Module User's Manual”. http://cache.freescale.com/files/microcontrollers/doc/user_guide/TWRK70F120MUM.pdf?fpsp=1&WT_TYPE=Users%20Guides&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation The <board>.h file is used to provide information needed by an application program using the kernel running on the Freescale Evaluation board. This file contains the GPIO board specifications.  It is located at the next path: <Freescale_MQX_4_x_install_path>\mqx\source\bsp\<name_board> Figure 1. GPIO board specifications for the TWR-K70F120M. The twrk70f120m.h file contains the GPIO board definition for the TWR-K70F120M, however if customer creates his own board and he needs to connect LEDs in deferent pins to the TWR-K70F120M, it is necessary to modify this file. Suppose a custom_board where is connected a LED to PTE18 pin, in order to add this pin definition it is necessary to follow the below steps, the pin will be called BSP_LEDCustom. 1. Define the pin name and assign the port and pin number. #define BSP_LEDCustom               (GPIO_PORT_E | GPIO_PIN18) 2. Assigning the requested functionality to the pin for the GPIO mode or any other peripheral mode. #define BSP_LEDCustom_MUX_GPIO (LWGPIO_MUX_E18_GPIO) 3. Save and close the twrk70f120m.h file. USE THE NEW LED IN A PROJECT   The following example shows one task named LEDCustom_TASK, where the LEDCustom is used. 1. Open a new MQX project. 2. In the main.h module replace the following lines: #define MAIN_TASK 1 extern void Main_task(uint_32); With the next lines: #define LEDCustom_TASK 5 extern void ledCustom_task(uint_32); 3. In main.c, modify the MQX_template_list entry for the Main_Task. Replace the following line: {MAIN_TASK, Main_task, 1500, 9, "main", MQX_AUTO_START_TASK}, With the next line: { LEDCustom_TASK, ledCustom_task, 1500, 9, "init", MQX_AUTO_START_TASK, 0, 0}, NOTE The last entry in the MQX_template_list must be all zeros. 4. In main.c, comment out the Main_task. /*void Main_task(uint_32 initial_data) { print(“/n Hello World /n”); _mqx_exit(0); } */ 5. It is necessary to write the tasks code. This task uses LWGPIO driver in order to toggle a pin. The lwgpio_init() function has to be called prior to calling any other API function of the LWGPIO driver. This function initializes the LWGPIO_STRUCT structure. The pointer to the LWGPIO_STRUCT is passed as a handle parameter. To identify the pin, platform-specific LWGPIO_PIN_ID number is used. It is necessary to have a variable to assign the pointer to the LWGPIO_STRUCT, for do that it is required to add the following line: LWGPIO_STRUCT ledC; The following lines initialize lwgpio handle for LWGPIO_MUX_E18_GPIO pin. The BSP already knows the address and the pin number for each GPIO PORT and each PIN. This is defined in mqx/source/bsp/<bsp_name>/<bsp_name>.h file. That is the reason the twrk70f120m.h file was modified. if (!lwgpio_init(&ledC, BSP_LEDCustom, LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_NOCHANGE))   {             printf("Initializing Port TE pin18 GPIO of the K70 as output failed.\n");     _task_block();   } 6. Once it is initialized, it is necessary to assign the requested functionality to the pin like GPIO mode or any other peripheral mode. The lwgpio_set_functionality() function sets the functionality of the pin. The value of the functionality parameter represents the number stored in the multiplexer register field which selects the desired functionality. For the GPIO mode, you can use the pre-defined macros which can be found in the lwgpio_ <mcu>.h file. Add the following lines switch pin functionality to GPIO mode: lwgpio_set_functionality(&ledC, BSP_LEDCustom_MUX_GPIO); The lwgpio_set_value() function sets the pin state (low or high) of the specified pin. In order to toggle the pin value write the following code: while (TRUE)   {     _time_delay(1000);     lwgpio_set_value(&ledC, value); /* toggle pin value */     value = value^1;   } 7. Create the other three functions. The name of each function, delay, and the first parameter must be different in LWGPIO functions use (lwgpio_init(), lwgpio_set_functionality(), lwgpio_set_value()). 8. At this point it is possible to build the project, flash it to the board and run the project; for more details about building, flashing and running please refer to the compiler documentation of your choice, that is located at the next path:  C:\Freescale\Freescale_MQX_4_x\doc\tools\cw  Thanks!!!!     a. main.c /**************************************************************************** * *   This file contains MQX only stationery 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? */   {LEDCUSTOM_TASK, ledCustom_task, 1500, 9, "init", MQX_AUTO_START_TASK, 0, 0}, {0,         0,         0, 0,   0,     0,                  0, 0} }; /*TASK*----------------------------------------------------- * * Task Name    : Main_task * Comments     : *    This task prints " Hello World " * *END*-----------------------------------------------------*/ void ledCustom_task(uint_32 initial_data) {       int value = 0;       LWGPIO_STRUCT ledC;                 printf("\n LedCustom task \n");                 /* initialize lwgpio handle for LWGPIO_MUX_TC0_GPIO pin (defined in mqx/source/bsp/<bsp_name>/<bsp_name>.h file) */         if (!lwgpio_init(&ledC, BSP_LEDCustom, LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_NOCHANGE))           {             printf("Initializing Port TE pin18 GPIO of the K70 as output failed.\n");           _task_block();         }                 /* swich pin functionality to GPIO mode */         lwgpio_set_functionality(&ledC, BSP_LEDCustom_MUX_GPIO);                  while (TRUE)           {             _time_delay(5000);             lwgpio_set_value(&ledC, value); /* toggle pin value */             value = value^1;           }       } /* EOF */     b. main.h #ifndef __main_h_ #define __main_h_ #include <mqx.h> #include <bsp.h>   #define LEDCUSTOM_TASK 5   extern void ledCustom_task(uint_32);    /* PPP device must be set manually and ** must be different from the default IO channel (BSP_DEFAULT_IO_CHANNEL) */ #define PPP_DEVICE      "ittyb:" /* ** Define PPP_DEVICE_DUN only when using PPP to communicate ** to Win9x Dial-Up Networking over a null-modem ** This is ignored if PPP_DEVICE is not #define'd */ #define PPP_DEVICE_DUN  1 /* ** Define the local and remote IP addresses for the PPP link ** These are ignored if PPP_DEVICE is not #define'd */ #define PPP_LOCADDR     IPADDR(192,168,0,216) #define PPP_PEERADDR    IPADDR(192,168,0,217) /* ** Define a default gateway */ #define GATE_ADDR       IPADDR(192,168,0,1) #endif /* __main_h_ */
View full article
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 */
View full article
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
View full article
Quick Overview of FreeRTOS vs MQX RTOS MQX  real-time operating system is designed for uniprocessor, multiprocessor, and distributed-processor embedded real-time system. Freescale semiconductor adopted this software platform for its microprocessors.  This includes Kinetis, Coldfire, PowerPC, ARC,ARM, StrongARM, xscale CPUs. The main features of MQX RTOS are scalable size, component-oriented architecture and easy of use. FreeRTOS is a popular real-time operating system kernel for embedded devices, that has been ported to 35 architectures. It is distributed under the GPL with an optional exception. FreeRTOS provides a very small footprint, low overhead and very fast execution. The kernel itself consist of only three or four C files. 4-8k bytes of flash minimum. Similar features : [to be done] Tasks, events, semaphores,mutex, message queues, power saving when idle                                                                  Freertos unique features : 1 Task nofifications: Each RTOS task has a 32-bit notification value which is initialized to zero when the RTOS task is created. An RTOS task notification is an event sent directly to a task that can unblock the receiving task, and optionally update the receiving task’s notification value. 2 Recursive mutex:  A mutex used recursively can be 'taken' repeatedly by the owner. The mutex doesn't become available again until the owner has called xSemaphoreGiveRecursive() for each successful xSemaphoreTakeRecursive() request. For example, if a task successfully 'takes' the same mutex 5 times then the mutex will not be available to any other task until it has also 'given' the mutex back exactly five times. 3 Stack overflow hook/notification: Each task maintains its own stack. The memory used by the task stack is allocated automatically when the task is created, and dimensioned by a parameter passed to the xTaskCreate() API function. Stack overflow is a very common cause of application instability. FreeRTOS therefore provides two optional mechanisms that can be used to assist in the detection and correction of just such an occurrence 4 Deferred interrupt handling:  Used from application interrupt service routines to defer the execution of a function to the RTOS daemon task. A mechanism is provided that allows the interrupt to return directly to the task that will subsequently execute the pended function. This allows the callback function to execute contiguously in time with the interrupt - just as if the callback had executed in the interrupt itself 5 Blocking on multiple objects:  Queue sets are a FreeRTOS feature that enables an RTOS task to block (pend) when receiving from multiple queues and/or semaphores at the same time. Queues and semaphores are grouped into sets, then, instead of blocking on an individual queue or semaphore, a task instead blocks on the set. MQX unique features: 1 Destruction of resource based on ownership:  [to be done] 2 Name services:  tasks can associate a 32-bit number with a string or symbolic name.MQX RTOS stores the association in a names database that all tasks on the processor can use. The database avoids global variables. 3 Inter-Processor Communication:  An application can run concurrently on multiple processors with one executable image of MQX RTOS on each processor. The images communicate and cooperate using messages that are transferred by memory or over communication links using inter-processor communication. The application tasks in each image need not be the same and, indeed, are usually different. 4 Watchdogs: Watchdogs are option components that let the user detect task starvation and deadlock conditions at the task level. 5 Task Queue Scheduling:  you can use task queues to explicitly schedule tasks or to create more complex synchronization mechanisms. Because task queues provide minimal functionality, they are fast. An application can specify a FIFO or round robin scheduling policy when it creates the task queue
View full article
Introduction the BSP configuration file in MQX for Kinetis SDK 1  Overview of BSP directory in MQX classic  and MQX for KSDK If you compare the BSP directory of MQX classic and MQX for KSDK , you will find that there are significant differences in how the Board Support Package for MQX for KSDK and classic MQX are configured.  For MQX classic directory, the compiled BSP library is used for drivers and hardware configuration (see picture 1), there are 35 files, while for MQX for KSDK directory (see picture 2), the BSP directory is nearly empty, much of the equivalent functionality of the BSP library is now moved to the example board directory. See picture 3. If you want to port your application to your custom board, these files are very important, you need to review them carefully. Picture 1   BSP in MQX classic Picture 2  BSP in MQX for KSDK Picture 3   board directory in MQX for KSDK 2  Introduction of the BSP configuration file in MQX for KSDK The BSP configuration  files are located at  sdk_install_folder/examples. Please see picture 3. We need to modify these files according to schematic and reference manual 2.1 Board.c/h: The C file contains clock and oscillator initialization functions. The header file contains board-specific configuration macros for things such as debug terminal configuration, push buttons, LEDs and other board-specific items. 2.2 Gpio_pins.c/h: Kinetis SDK uses pin configuration structures for each pin --Pin configuration structures in gpio_pin.c configures input/output, pull-up/pull-down, pin filtering, interrupt enabled/disabled, initial output polarity, slew rate and driver strength setting Gpio_pins.h --declares Pin names used by board, PORT pin to use  (ie: PTE3) --contains definitions for LED, switch, and SD card chip select /*! @brief Pin names */ enum _gpio_pins_pinNames{   kGpioSW2      = GPIO_MAKE_PIN(GPIOC_IDX, 6U),   kGpioSW3      = GPIO_MAKE_PIN(GPIOA_IDX, 4U),   kGpioSdhc0Cd  = GPIO_MAKE_PIN(GPIOE_IDX, 6U),   kGpioLED1     = GPIO_MAKE_PIN(GPIOE_IDX, 26U),   kGpioLED2     = GPIO_MAKE_PIN(GPIOB_IDX, 22U),   kGpioLED3     = GPIO_MAKE_PIN(GPIOB_IDX, 21U), }; #endif Gpio_pins.c Contains GPIO options for each pin const gpio_output_pin_user_config_t ledPins[] = {   {     .pinName = kGpioLED1, .config.outputLogic = 1,     .config.slewRate = kPortSlowSlewRate,     .config.isOpenDrainEnabled = false, .config.driveStrength = kPortLowDriveStrength,   },   {     .pinName = kGpioLED2, .config.outputLogic = 1,     .config.slewRate = kPortSlowSlewRate, .config.isOpenDrainEnabled = false, .config.driveStrength = kPortLowDriveStrength,   },   {     .pinName = kGpioLED3, .config.outputLogic = 1,     .config.slewRate = kPortSlowSlewRate, .config.isOpenDrainEnabled = false, .config.driveStrength = kPortLowDriveStrength,   },   {     .pinName = GPIO_PINS_OUT_OF_RANGE,   } }; 2.3  Pin_mux.c/h: Kinetis devices provide great flexibility in muxing signals, each digital port pin has up to 8 signals muxed on pin, some peripherals route same signals to multiple pins. In Pin_mux.c:  It implements functions to set pin mux option for all pins used on board, and functions for each peripheral type, like configure_can_pins() void configure_can_pins(uint32_t instance) {   /* PORTB_PCR19 */   PORT_HAL_SetMuxMode(PORTB,19u,kPortMuxAlt2);   /* PORTB_PCR18 */   PORT_HAL_SetMuxMode(PORTB,18u,kPortMuxAlt2); } Not all instances will be populated so may need to add void configure_i2c_pins(uint32_t instance) {   switch(instance) {        case I2C0_IDX:                       /* I2C0 */       /* Affects PORTE_PCR24 register */ PORT_HAL_SetMuxMode(PORTE,24u,kPortMuxAlt5);       PORT_HAL_SetOpenDrainCmd(PORTE,24u,true);       /* Affects PORTE_PCR25 register */ PORT_HAL_SetMuxMode(PORTE,25u,kPortMuxAlt5); PORT_HAL_SetOpenDrainCmd(PORTE,25u,true);       break;     case I2C1_IDX:                       /* I2C1 */       /* Affects PORTC_PCR10 register */ PORT_HAL_SetMuxMode(PORTC,10u,kPortMuxAlt2); PORT_HAL_SetOpenDrainCmd(PORTC,10u,true);       /* Affects PORTC_PCR11 register */ PORT_HAL_SetMuxMode(PORTC,11u,kPortMuxAlt2); PORT_HAL_SetOpenDrainCmd(PORTC,11u,true);       break;     default:       break;   } 2.4  hardware_init: Project specified hardware initialization, it uses functions provided in board configuration layers in pin_mux.c during startup void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); } 3   Kinetis SDK Porting example—Change Default UART To change default UART port, we need to change the UART instance in board.h, and change the pin muxing in pin_mux.c 3.1   Modify board.h to select the UART and baud rate to use /* The UART to use for debug messages. */ #ifndef BOARD_DEBUG_UART_INSTANCE     #define BOARD_DEBUG_UART_INSTANCE   0     #define BOARD_DEBUG_UART_BASEADDR   UART0 #endif #ifndef BOARD_DEBUG_UART_BAUD     #define BOARD_DEBUG_UART_BAUD       115200 #endif 3.2  Modify pin_mux.c to select the pins to use void configure_uart_pins(uint32_t instance) {   switch(instance) {        case UART0_IDX:                      /* UART0 */       /* Affects PORTB_PCR16 register */ PORT_HAL_SetMuxMode(PORTB,16u,kPortMuxAlt3);       /* Affects PORTB_PCR17 register */ PORT_HAL_SetMuxMode(PORTB,17u,kPortMuxAlt3);       break;     case UART4_IDX:                      /* UART4 */       /* Affects PORTC_PCR14 register */ PORT_HAL_SetMuxMode(PORTC,14u,kPortMuxAlt3);       /* Affects PORTC_PCR15 register */ PORT_HAL_SetMuxMode(PORTC,15u,kPortMuxAlt3);       break;     default:       break;   } }
View full article
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
View full article
If you are interested in a PPP connection between your PC and your board using Win 7 OS you may find the attached document useful. This project (ATTACHED) starts PPP service and waits for a Windows connection. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- If you are interested in getting started with MQX for KSDK please see the following document: How To: Create a New MQX RTOS for KSDK Project in KDS If you are interested in using RTCS with Processor Expert please see the following document: How to add RTCS to a Processor Expert Project Using KDS and KSDK Regards, Carlos
View full article
Hi Community, Based on How To: Create an MQX RTOS for KSDK project with Processor Expert in Kinetis Design Studio IDE from macl​ and dereksnell you can find in the attached document the steps to include RTCS to a KDS3.0 project using KSDK1.2 and Processor Expert as well as the final project. Thank you RBORB​ for providing the first draft of this process. For information about creating a new KSDK project with MQX and without Processor Expert please see the following document. How To: Create a New MQX RTOS for KSDK Project in KDS If you are looking for a simple document to get started with KSDK please see the following document. Writing my first KSDK1.2 Application in KDS3.0 - Hello World and Toggle LED with GPIO Interrupt Regards, Carlos
View full article
Hi everybody, As there is not a New MQX 4.2 Project Wizard, it is necessary to create a project from scratch. Here, we will create a new project making a copy from an example Project, for this example we are using FRDM-K64F120M but the process is similar for all the Freescale boards. 1. Import hello_frdmk64f example and just copy-paste it using Ctrl + C and Ctrl + V keys. 2. Delete the virtual folder to avoid editing the original file. 3. Create a New physical folder and named it Sources. 4. In Sources folder create a New Source file and name it main.c 5. Go to menu Project > Properties > C/C++ Build > Settings > Cross ARM GNU Assembler > Includes and delete all the paths. 6. Go to menu Project > Properties > C/C++ Build > Settings > Cross ARM C Compiler > Includes, delete all the paths and replace them with the following: C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\bsp\Generated_Code C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\bsp C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\psp C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\mfs C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\rtcs C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\shell C:\Freescale\Freescale_MQX_4_2\usb_v2\<used_board>.kds\debug\usbh\mqx ${eclipse_home}../toolchain/lib/gcc/arm-none-eabi/4.8.4/include ${eclipse_home}../toolchain/lib/gcc/arm-none-eabi/4.8.4/include-fixed ${eclipse_home}../toolchain/arm-none-eabi/include For the FRDM-K64F120M C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug\bsp\Generated_Code C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug\bsp C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug\psp C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug\mfs C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug\rtcs C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug\shell C:\Freescale\Freescale_MQX_4_2\usb_v2\output\frdmk64f.kds\debug\usbh\mqx ${eclipse_home}../toolchain/lib/gcc/arm-none-eabi/4.8.4/include ${eclipse_home}../toolchain/lib/gcc/arm-none-eabi/4.8.4/include-fixed ${eclipse_home}../toolchain/arm-none-eabi/include Note: You can use  Ctrl + C and Ctrl + V keys. 7. Go to menu Project > Properties > C/C++ Build > Settings > Cross ARM C Linker > General and replace the linker file path with the following C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\bsp\intflash.ld For the FRDM-K64F120M C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug\bsp\intflash.ld   8. Go to menu Project > Properties > C/C++ Build > Settings > Cross ARM C Linker > Miscellaneous and replace all Other objects with the following: C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\bsp\bsp.a C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\psp\psp.a C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\mfs\mfs.a C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\rtcs\rtcs.a C:\Freescale\Freescale_MQX_4_2\lib\<used_board>.kds\debug\shell\shell.a C:\Freescale\Freescale_MQX_4_2\usb_v2\output\<used_board>.kds\debug\usbh\mqx\libusbh_mqx.a ${eclipse_home}../toolchain/lib/gcc/arm-none-eabi/4.8.4/armv7e-m/fpu/libgcc.a ${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/fpu/libc.a ${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/fpu/libsupc++.a ${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/fpu/libm.a ${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/fpu/libnosys.a For the FRDM-K64F120M C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug\psp\psp.a C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug\mfs\mfs.a C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug\rtcs\rtcs.a C:\Freescale\Freescale_MQX_4_2\lib\frdmk64f.kds\debug\shell\shell.a C:\Freescale\Freescale_MQX_4_2\usb_v2\output\frdmk64f.kds\debug\usbh\mqx\libusbh_mqx.a ${eclipse_home}../toolchain/lib/gcc/arm-none-eabi/4.8.4/armv7e-m/fpu/libgcc.a ${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/fpu/libc.a ${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/fpu/libsupc++.a ${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/fpu/libm.a ${eclipse_home}../toolchain/arm-none-eabi/lib/armv7e-m/fpu/libnosys.a 9. Click to Apply and Ok buttons. 10. Go to C:\Freescale\Freescale_MQX_4_2\mqx\examples\hello and copy all the content in hello.c to main.c in your project 11. At this point you can be able to build and debug your New project. Enjoy...
View full article
CREATE MQX FOR KSDK PROJECT FROM SCRATCH IN IAR IDE Note: ${KSDK_PATH} is used in this guide line to instead of path of KSDK source (Example: C:/Freescale/KSDK_1.2.0/). This procedure was created for TWR-K64f120M 1     Create new workspace                 Open IAR  --> File  --> New  --> Workspace                 2     Create new project Project --> Create New Project  --> C  -> main --> OK                    Select project directory                              3    Add project lib to workspace         Project  -->  Add Existing Project … then select projects: {SDK_PATH}/lib/ksdk_mqx_lib/iar/K64F12/ksdk_mqx_lib.ewp {SDK_PATH}/rtos/mqx/mqx/build/iar/mqx_twrk64f120m/mqx_twrk64f120m.ewp {SDK_PATH}/rtos/mqx/mqx_stdlib/build/iar/mqx_stdlib_twrk64f120m/mqx_stdlib_twrk64f120m.ewp                        4    Build All Lib project                   5    Setting Project On the left workspace pane, right click on Mqx Project and select Options. Setting General Options         Select device:                       Setting C/C++ Compiler          Add include file and define symbols for project at Preprocessor tab: Additional include directories: {SDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug {SDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug/config {SDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug/mqx {SDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug/mqx_stdlib {SDK_PATH}/platform/osa/inc {SDK_PATH}/platform/CMSIS/Include {SDK_PATH}/platform/devices {SDK_PATH}/platform/hal/inc {SDK_PATH}/platform/drivers/inc {SDK_PATH}/platform/system/inc {SDK_PATH}/platform/devices/MK64F12/include {SDK_PATH}/platform/devices/MK64F12/startup {SDK_PATH}/platform/system/inc {SDK_PATH}/platform/hal/inc {SDK_PATH}/platform/drivers/inc {SDK_PATH}/platform/startup {SDK_PATH}/platform/utilities/inc {SDK_PATH}/examples/twrk64f120m {SDK_PATH}/rtos/mqx/config {SDK_PATH}/rtos/mqx/mqx/source/include Defined symbols: CPU_MK64FN1M0VMD12 TWR_K64F120M FSL_RTOS_MQX                         Setting Linker option           Use linker file in KSDK source:             {KSDK_PATH}/platform/devices/MK64F12/linker/iar/MK64FN1M0xxx12_flash.icf           Set stack/heap size and define __ram_vector_table__ __stack_size__=0x400 __heap_size__=0x400 __ram_vector_table__=1                           The project request three librarys: lib_mqx.a, lib_mqx_stdlib.a, libksdk_platform_mqx.a {KSDK_PATH}/lib/ksdk_mqx_lib/iar/K64F12/Debug/libksdk_platform_mqx.a {KSDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug/mqx/lib_mqx.a {KSDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug/mqx_stdlib/lib_mqx_stdlib.a              MQX uses owner’s startup-code (boot.S), We need to override default program entry                        6     Create project template Project structure and create group:          Specific file for board in: {KSDK_PATH}\examples\twrk64f120m\board.c {KSDK_PATH}\examples\twrk64f120m\board.h {KSDK_PATH}\examples\twrk64f120m\gpio_pins.c {KSDK_PATH}\examples\twrk64f120m\gpio_pins.h {KSDK_PATH}\examples\twrk64f120m\pin_mux.c {KSDK_PATH}\examples\twrk64f120m\pin_mux.h          BSP file in: {KSDK_PATH}\rtos\mqx\mqx\source\bsp\bsp.h {KSDK_PATH}\rtos\mqx\mqx\source\bsp\bsp_config.h {KSDK_PATH}\rtos\mqx\mqx\source\bsp\init_bsp.c {KSDK_PATH}\rtos\mqx\mqx\source\bsp\mqx_main.c {KSDK_PATH}\rtos\mqx\mqx\source\include\mqx.h          Config files in: {KSDK_PATH}\rtos\mqx\config\common\small_ram_config.h {KSDK_PATH}\rtos\mqx\config\common\verif_enabled_config.h {KSDK_PATH}\rtos\mqx\config\board\twrk64f120m\user_config.h {KSDK_PATH}\rtos\mqx\config\mcu\MK64F12\mqx_sdk_config.h           Utilities files in: {KSDK_PATH}\platform\utilities\src\print_scan.c {KSDK_PATH}\platform\utilities\src\print_scan.h {KSDK_PATH}\platform\utilities\src\fsl_debug_console.c {KSDK_PATH}\platform\utilities\inc\fsl_debug_console.h                                                                7    Write code The code below is used to turn on the LED and print out “hello world”. #include "stdio.h" #include "fsl_os_abstraction.h" #include "board.h" #include "fsl_debug_console.h" #define MAIN_TASK        8 void main_task(uint32_t param); const TASK_TEMPLATE_STRUCT  MQX_template_list[] = {    { MAIN_TASK, main_task, 0xC00, 20, "main_task", MQX_AUTO_START_TASK},    { 0L, 0L,        0L,    0L, 0L,         0L } }; void main_task(uint32_t param) {     LED1_EN;     LED1_ON;     PRINTF("Hello World\r\n");     while(1)     {} } 8    Run example: Build project:                   Select debug target                     - Set serial console 115200 baud rate, no parity, 8 data bits, 1 stop bit, without flow control - Set project as active prior we run project Run project                         See Led1 is On status and string “Hello World” is printed to screen                           
View full article
1. Few basic questions and answers about FlexNVM and FlashX. 1.1 What is FlexNVM? FlexNVM is additional separate block of flash memory which could be used as data flash, as non volatile storage for emulated EEPROM or as combination both option. I will focus on first option in this document – FlexNVM will work simply as data flash. FlexNVM you can find in MCU parts which contain “X” at dedicated place in part number. For example: MK64FX512VMD12 contains 1 block (512 KB) of program flash and 1 block (128 KB) of FlexNVM MK64FN1M0VMD12 contains 2 blocks (512 KB each) of program flash only. For more details about FlexNVM and flash blocks, please see your MCU reference manual. For example chapter “Flash Memory Sizes”. 1.2 What is FlashX? MQX FlashX driver provide ability to write to and read from internal flash. Unfortunately FlexNVM memory is supported only partially in default state – Some of BSPs has implemented configuration and functions for emulated EEPROM (flexnvm example code). For more details, please check MQX_IO_User_Guide.pdf in c:\Freescale\Freescale_MQX_4_2\doc\mqx folder. 1.3 Can I use BSP for MCU without FlexNVM for my own board which has MCU with FlexNVM? It is not recommended. However you can use this BSP as base for your own board BSP. Please check MQX_BSP_Cloning_Wizard_Getting_Started.pdf, MQX_BSP_Porting_Guide.pdf  and MQX_BSP_Porting_Example_User_Guide.pdf documents in C:\Freescale\Freescale_MQX_4_2\doc folder. 1.4 Can I use FlashX in my KSDK project? Unfortunately FlashX driver was not implemented into KSDK. KSDK contains its own Standard Software Driver (SSD) for C90TFS/FTFx Flash family, however this is just low level driver without high level abstraction layer like in case of FlashX driver. 2. Procedure for update MQX FlashX driver to support FlexNVM. 2.1 Please backup these files: user_config.h, <your BSP>.h, init_flashx.c, flash_ftfl.c and flash_ftfe.c files. Note: user_config.h, <your BSP>.h and init_flashx.c are part of your BSP code. 2.2 Enable FlashX in user_config.h file by definition: #define BSPCFG_ENABLE_FLASHX                      1 2.3 Updates of <your BSP>.h file: 2.3.1 Please check MCU reference manual and update BSP_INTERNAL_FLASH_BASE, BSP_INTERNAL_FLASH_SIZE, BSP_INTERNAL_FLASH_SECTOR_SIZE if necessary. Typically we have to decrease BSP_INTERNAL_FLASH_SIZE in case when BSP without FlexNVM was used as base for own BSP. 2.3.2 Add new macros which will define FlexNVM in memory map. For example: #define BSP_INTERNAL_FLEXNVM_BASE  0x10000000 #define BSP_FLEXNVM_SECTOR_SIZE         0x400 #define BSP_INTERNAL_FLEXNVM_SIZE  0x00008000 2.4 Update init_flashx.c in your BSP folder: 2.4.1 Add FlexNVM file block into _bsp_flashx_file_blocks[] table. For example:     // data flash file block     { "dflash", BSP_INTERNAL_FLEXNVM_BASE, (uint32_t) (BSP_INTERNAL_FLEXNVM_BASE+ BSP_INTERNAL_FLEXNVM_SIZE - 1) },    Parameters are {name of file block, start address, end address}.    Note: This is pure software interface; range of addresses doesn’t need fit to physical flash block parameters. You can organize file blocks according your needs. 2.4.2 If you used non-FlexNVM BSP as base for your own BSP, you have to change HW block map for KinetisX devices. Please change _flashx_kinetisN_block_map into _flashx_kinetisX_block_map in _bsp_flashx_init structure. 2.5 Update flash_ftfl.c or flash_ftfe.c file: 2.5.1 Look at MCU reference manual whether your MCU has FTFL or FTFE flash memory module and select appropriate file for editing. 2.5.2 Add FlexNVM memory block into _flashx_kinetisX_block_map[] table. For example: { BSP_INTERNAL_FLEXNVM_SIZE / BSP_FLEXNVM_SECTOR_SIZE, (_mem_size) BSP_INTERNAL_FLEXNVM_BASE,  BSP_FLEXNVM_SECTOR_SIZE }, // FlexNVM block Parameters are {number of sectors, start address, sector size}. Note: This is description of physical hardware memory block; range of addresses must fit to physical flash block parameters. 2.5.3 Now we have to fix problem with FlexNVM address. Both Program Flash and FlexNVM Flash are programmed trough FTFL_FCCOBn / FTFE_FCCOBn registers where FCCOB1.. FCCOB3 contains address in 24bit format. Therefore we cannot work directly with FlexNVM addresses – they will not fit into 24bit due to FlexNVM base 0x10000000. FTFL/FTFE modules specifies that most significant bit in 24bit address (bit 23) will be used for distinguish between Program Flash and FlexNVM Flash. We can use for example such code: //Set 23th bit when FlexNVM flash address     if (write_addr & BSP_INTERNAL_FLEXNVM_BASE)     { write_addr = write_addr | (1 << 23);     }   and add this code into necessary functions prior write into command_array[] (content of command_array[] will be used for filling FTFL_FCCOBn / FTFE_FCCOBn registers). For basic work of FlashX example code is necessary update at least ftfl_flash_erase_sector()/ftfe_flash_erase_sector() and ftfl_flash_write_sector()/ftfe_flash_write_sector() functions. 2.6. After these changes, you can try using FlashX example code in flash_demo.c where you simply open FlexNVM file block instead of default program flash file block. For example: //#define FLASH_NAME "flashx:bank0" #define FLASH_NAME "flashx:dflash" In attachment file you can find example of modification for MQX4.2.0 and MK20DX72 MCU. 3. How to rewrite flash - general notes: Flash data must be in the erased state before being programmed. Cumulative programming of bits (adding more zeros) is not allowed. In case of both FTFL and FTFE modules we program flash by aligned phrases (typically 64 bits). If we want program by smaller chunks (e.g by bytes), FTFL module will allow you write into this phrase even if it is not recommended. However FTFE module will cause bus fault in case of second write into the same phrase. So, only save way how to change data in FTFE phrase which was already written is erase whole sector and rewrite data back. Therefore please use ioctl command FLASH_IOCTL_ENABLE_SECTOR_CACHE for FTFE module. The sector cache allocation is not required in case of Full sector write and partial sector overwrite when the destination area (aligned to phrases) is blank.
View full article
Hi, Many people has been asking about migrating from MQX RTOS to MQX RTOS for KSDK. Such guide is now available in the following link: http://www.freescale.com/files/soft_dev_tools/doc/support_info/MQXKSDKPUG.pdf?fsrch=1​ If you need to create a new MQX RTOS for KSDK project please note that there is not a New MQX for KSDK Project Wizard, therefore it is necessary to create it manually. You can find a guide in the link below. How To: Create a New MQX RTOS for KSDK Project in KDS Best regards, Carlos Musich Technical Support Engineer
View full article
Accelerometer and magnetometer FXOS8700CQ example code for MQX4.1.1 This example code was written for FRDM-K64F board and it is based on Tom’s bare-metal code (Thank you). Content of attached zip file could be unpacked directly to examples directory (c:\Freescale\Freescale_MQX_4_1\mqx\examples\..). It contains generated projects for CW10GCC, IAR, KDS, make and KEIL toll chains. Note: unfortunately this example project cannot be used as source for New Project Wizard in CW10. Example code uses polled I2C MQX driver for communication with FXOS8700CQ chip and it contains two options for acquisition sensors data. We can use polled (0) or interrupt (1) mode according SENSOR_USE_INTERRUPT macro definition. In polled mode we periodically read sensor status until new data are available. In interrupt mode sensor drives interrupt pin when new data are available. Example code contains calibration functions for increasing accuracy. Magnetometer calibration function collects data during 30s interval where we should rotate with board around z-axis in 360° range (leave board on table and rotate from north to south and back to north). It acquires approximately 3 samples per second. For change this ODR rate, we have to modify CTRL_REG1 value. Note: Interrupt mode works correctly up to 200Hz ODR. Higher ODRs was not tested due to capacitance on interrupt pin (C56). Polled mode was tested up to 800Hz ODR (accelerometer only). Example code displays received data on debug console and drives RGB LEDs according measured g’s. If you are interested in more complex algorithms please refer to our Freescale Sensor Fusion Library for Kinetis MCUs. I hope it helps you. RadekS
View full article
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
View full article
This blog shares several issues reported by China customers when they use NAND FFS in MQX4.1.1. NAND FFS open failure issue Customer reported they can use a pressure test code to continuously open file, write file and close file, each time write about 20 bytes with append and they will find after running for a while, file open will fail and it returns error code 0x3067 (MFS_EOF). Each time file open failed, file has been written with 20480 bytes. This is a typical use case at customer side for data logging. The test code is attached named as "nand_pressure_test.cpp". Attached patch file named "mfs_write.patch" can resolve this issue. Memory allocation issue when using MFS & NAND FFS Customer run pressure test for MFS and NAND FFS by creating multiple levels of sub-folders (up to 100 levels) and in each sub-folder they create random number of files (up to 50). For each file, they will write 250 bytes. They found code failed to open new file when create sub-folders to 41 level. Traced the code on K70 tower and found actually this is not problem with MFS to search clusters for the new file, instead when the issue occurs, it's the drive_ptr (MFS_DRIVE_STRUCT) which is corrupted when MFS use memory allocation routine to allocate file path. The pressure test code for this case is attached. File named "MultiLevel_Folder_Test.zip". The memory corruption for MFS drive info is due to there is no protection in MFS_Parse_pathname() on whether the actual path name used passed from fopen will be exceeding 260 bytes which is fixed in mfs.h file to be compatible with Windows. So need to take care of this internal limitation when handling multiple level folders. MFS deadlock issue when using NAND FFS Customer reported random code block issue when running pressure test against NAND FFS. The issue is quite random, sometimes takes 12 hrs to reproduce the issue. Test code attached. Name is "MFS deadlock issue.zip". The resolution and description on this issue is in attached file named "MQX-4919 NandFFS explanation". Hao
View full article
MQX ppp communication. Could be imported to wireshark as hexdump.
View full article
The new Freescale MQX™ 4.1.2 GA for Vybrid release is now available on www.freescale.com/mqxrtos ·      Files available                   # Name Description 1 Freescale MQX RTOS 4.1.2 for Vybrid Linux Base This   release has the same basic code as the 4.1.2 version, with just the changes   needed to build and debug on Linux systems. 2 Freescale MQX RTOS 4.1.2 for Vybrid MQX™ Source   code. Includes an RTOS, File System, TCP/IP and USB host/device software   stacks. Does not require MQX™ 4.1.1 installation. ·         What is New? ·         New Board Support Package ·         X-SVF522R-EVB Vybrid Evaluation Board Rev. B with the SVF522R3MK4 processor. ·         TWR-VF65GS10 Development Kit Rev. H with the MVF61NS10MK50 processor. ·         New Features and Updates ·         BSP package for TWR-VF600 was replaced by new TWR-VF65GS10 ·         Vybrid Auto EVB board was replaced by new X-SVF522R-EVB board ·         MFS library was updated ·         New USB stack was added ·         Exception support for cortex A kernel ·         Video ADC + VIU example application ·         RTCS package was updated ·         Known issues ·         For known issues and limitations please consult the release notes
View full article
The new Freescale MQX™ 4.1.1 Cloning Wizard patch is now available on the www.freescale.com/mqxrtos ·         Patch Description o   BSP Cloning Wizard is now based on Eclipse 4.4 o   Kinetis Design Studio support for generating projects (libraries, examples) and working sets (.wsd files for Project of Projects plug-in) o   Remembering opened boards (cloned or opened by user) from previous application run o   BSP Cloning Wizard saves users selection of IDEs, Libraries and Examples in project generator section for all currently opened boards o   Fix the issue of the BSP Cloning Wizard not working in MQX 4.1.1 To get the patch follow the next instructions: Go to www.freescale.com/mqxrtos Click on the big Download Button.  - You will have to log in if you aren’t already.  Click on MQX RTOS for Kinetis, Vybrid, Coldfire v4.1.1….. The patch for the cloning wizard is on the list of files.
View full article