Kinetis微控制器知识库

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

Kinetis Microcontrollers Knowledge Base

讨论

排序依据:
  (para español continua mas abajo) Blind deaf-mute comunication system   Materials Used : A Freedom- KL25Z card A USB Cable A 16x2 LCD Display Three buttons A breadboard A USB cable   Project description Thinking about the difficulties a blind, deaf-mute person has to convey a message, we designed a device to facilitate their communication. Using the Morse key system, the disabled person can write a short message on a LCD screen. For this, you need to press three buttons, and depending on the duration, a function will be performed. 1. If you short-press the button on the left, this will erase the last character typed, however, if you long-press, this will erase everything written. 2. If the middle button with the green label is short-pressed, this will print a dot at the bottom of the screen. If you long press the button, it will print a dash. In Morse code, the dot represents a single signal and the dash represents a triple signal. 3. If the button on the right, with the yellow label is short pressed, the LCD display space will be added to the message. But if he was held down with a longer duration, the set of ¨ Short ¨ and ¨ Long ¨ will be transformed in to a letter in the alphabet and it will be printed on the screen. Note: * If the set of Short and Long does not match any sequence in the matrix, no character is added to the message. **The system to display and write the message on the LCD display are separate.     Modifications for the second stage of the prototype 1. Delete button on the right, the yellow label, Send and Space. a. It is intended that the third button is eliminated by increasing the code efficiency. Instead of sending the sequence of short and long pressing a button, they are sent after a desired time interval. b. Wanted to enter the space with a sequence of short and long. 2. Currently the project is divided into two boxes, one that displays the buttons and other writing. The goal is to have a single box which can write and display the message. 3. With a potentiometer seek to change the time it takes to push a button to be recognized among one short and one long signal.   Modifications for the third stage of the prototype 1. Perform the division again in two boxes , interconnected by Bluetooth modules , as the system is designed to generate a communication between two people, using a system of sending data to harvest deaf -mute person in the future by Braille .       Sistema de Comunicación para Persona Ciega, Sorda y Muda   Materiales Utilizados: Una tarjeta Freedom-KL25Z Un Cable Una Pantalla LCD 16x2 Tres botones Una placa de pruebas (protoboard) Un cable USB   Descripción de Proyecto             Pensando en las dificultades que una persona ciega, sorda y muda tiene para transmitir un mensaje, se ha diseñado un aparato para facilitar su comunicación. Utilizando el sistema de clave morse, la persona con discapacidad puede escribir un mensaje corto en una pantalla LCD. Para esto, se deben presionar tres botones que dependiendo la duración del toque, será la función que efectuará. 1. Si al botón de la izquierda, con la etiqueta azul, apenas se le presiona este borrará el ultimo carácter escrito; sin embargo, si se le presiona con una mayor duración este borrará todo lo escrito. 2. Si al botón del medio, con la etiqueta verde, apenas se le presiona este imprimirá en la parte inferior de la pantalla un punto. El punto representa, un corto en el sistema de clave morse. Sin embargo, si se le mantiene presionado por un momento mas largo, este imprimirá un guión. El guión representa un comando largo en el sistema de clave morse. 3. Si al botón de la derecha, con la etiqueta amarilla, apenas se le presiona, en la pantalla LCD se agregará un espacio al mensaje. Sin embargo si se le mantiene presionado con una mayor duración, se enviará el conjunto de ¨Cortos¨ y ¨Largos¨ a una matriz para que la secuencia se busque y cuando esta se haya, en la LCD se agrega la letra deseada al mensaje. Nota: *Si el conjunto de Cortos y Largos no coincide con ninguna secuencia en la matriz, ningún carácter se agregará al mensaje. ** El sistema para mostrar el mensaje con la LCD esta separado a los botones para escribirlo.     Modificaciones para la segunda etapa del prototipo 1.      Eliminar el botón de la derecha, con etiqueta amarilla,  de Enviar y Espacio. a.       Se pretende que el tercer botón sea eliminado mediante el aumento en la eficiencia del código. En vez de enviar la secuencia de Cortos y Largos al presionar un botón, estos se enviarían después de un intervalo de tiempo deseado. b.      Se busca que el espacio se introduzca con una secuencia de cortos y largos. 2.      Actualmente el proyecto está dividido en dos cajas, una que muestra el mensaje y otra con los botones para escribir. El objetivo es tener una sola caja con el que se pueda escribir y mostrar el mensaje. 3.      Con un potenciómetro se busca cambiar el tiempo que se necesita apretar un botón para que se reconozca entre un toque corto y uno largo.   Modificaciones para la tercera etapa del prototipo 1.      Realizar de nuevo la división en dos cajas, comunicadas entre sí por módulos bluetooth, ya que el sistema está pensado para poder generar una comunicación entre ambas personas, utilizando en un futuro, un sistema de envío de datos a la persona siega sordo-muda mediante el sistema braille.
查看全文
SSD1963驱动4.3寸屏原理图。
查看全文
Hello Kinetis community, High accuracy metering is an essential feature of an electronic power meter application. Metering accuracy is a most important attribute because inaccurate metering can result in substantial amounts of lost revenue. Moreover, inaccurate metering can also undesirably result in overcharging to customers.  The common sources of metering inaccuracies, or error sources in a meter, include the sensor devices, the sensor conditioning circuitry, the Analog FrontEnd (AFE), and the metering algorithm executed either in a digital processing engine or a microcontroller In this post you will find the description of the implementation of a Two Phase Power Meter firmware featuring Kinetis KM34 device using a metering algorithm known as Filter Based Algorithm. The showed firmware was implemented on the hardware design described in the Reference Manual DRM149 (the software implementation shown in the DRM149 is using a more complex metering algorithm called Fast Fourier Transform). Firmware Design The firmware implements the basic functions for an e-meter application such as: Power meter calibration: Performs power meter calibration and stores calibration parameters. Data processing: Read digital values form the AFE and performs scaling. Calculation of quantities: Calculates billing and non-billing quantities HMI control: Updates LCD with the new values and transitions to new LCD screen. Powe Meter Calibration The calibration task runs whenever a non-calibrated power meter is connected to the mains. First it checks if the calibration flag is already stored in the microcontroller flash, if not, then it runs the calibration. More detail about the calibration process can be found in the DRM143 document. The function: int16 CONFIG_CalcCalibData (tCONFIG_FLASH_DATA *ptr)‍‍‍ is in charge of calculating the calibration data and store the calibration flag in the flash. You can refer to the next code section for the complete usage and definition.   /* if calibration data were collected then calibration parameters are       */   /* calculated and saved to flash                                            */   if (CONFIG_CalcCalibData ((tCONFIG_FLASH_DATA *)&ramcfg) == TRUE)     CONFIG_SaveFlash ((tCONFIG_FLASH_DATA *)&ramcfg, ramcfg.flag);‍‍‍‍ The calibration task terminates by storing calibration gains, offsets and phase shift into the flash and by resetting the microcontroller device. Data Processing Reading the phase voltage and phase current samples from the analog front-end (AFE) occurs periodically every 166.6 μs. This task runs on the highest priority level (Level 0) and is triggered asynchronously when the AFE result registers receive new samples. The task reads the phase voltage and phase current samples from the AFE result registers, scales the samples to the full fractional range, and writes the values to the temporary variables for use by the calculation task. While kWh values is being calculated every 6000 Hz the remaining quantities: kVARh, QAVG, PAVG, URMS and IRMS are being calculates every 1500 Hz (666.6 μs). This is according to the decimation factor and to reduce the CPU usage since those values are not needed every AFE sample. The meter definition used for this application can be found in the meterlib2ph_cfg.h files, this file was generated using the Filter-Based Metering Algorithms Configuration Tool, for more information on how to use the tool you can refer to the AN4265 document. This is the Meter configuration: Here you can see the expected error behavior against Frequency: The configuration of the AFE module and channels is the following:   /* Current Phase 1                                                          */   AFE_ChInit (CH0,               AFE_CH_SWTRG_CCM_PGAOFF_CONFIG(DEC_OSR1024),                    0,               PRI_LVL1,               (AFE_CH_CALLBACK)NULL);     /* Current Phase 2                                                          */   AFE_ChInit (CH1,               AFE_CH_SWTRG_CCM_PGAOFF_CONFIG(DEC_OSR1024),               0,               PRI_LVL1,               (AFE_CH_CALLBACK)NULL);     /* Voltage Phase 1                                                          */   AFE_ChInit (CH2,               AFE_CH_SWTRG_CCM_PGAOFF_CONFIG(DEC_OSR1024),                    0,               PRI_LVL1,               (AFE_CH_CALLBACK)NULL);     /* Voltage Phase 2                                                          */     AFE_ChInit (CH3,               AFE_CH_SWTRG_CCM_PGAOFF_CONFIG(DEC_OSR1024),               0,               PRI_LVL1,               (AFE_CH_CALLBACK)afech3_callback);     /* AFE Initialization @ 6 KHz                                               */   AFE_Init    (AFE_MODULE_RJFORMAT_CONFIG(AFE_PLL_CLK, AFE_DIV2, 12.288e6));  ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍ As you can see only the CH3, which is measuring the Voltage phase 2, is configured with interrupt. During the CH3 callback the remaining channels are sampled to get the 4 values at the same time and performs scaling: /* measurements callback @ 6000 Hz                                            */ static void afech3_callback (AFE_CH_CALLBACK_TYPE type, int32 result) {   static int cnt_1 = 0;     if (type == COC_CALLBACK)   {      /* Current and Voltage reading                                            */     u24_sample[0] = AFE_ChRead (CH2) << U_SCALE;            /* Voltage 1 reading ... */     i24_sample[0] = AFE_ChRead (CH0) << I_SCALE;            /* Current 1 reading ... */     u24_sample[1] = AFE_ChRead (CH3) << U_SCALE;            /* Voltage 2 reading ... */     i24_sample[1] = AFE_ChRead (CH1) << I_SCALE;            /* Current 2 reading ... */     . . . . }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍ Calculation of Quantities Within the CH3 interrupt the metering algorithm functions are called to process the data of the active energy, the calculation task scales the samples using calibration offsets and calibration gains obtained during the calibration phase: METERLIB2PH_ProcSamples removes DC bias from phase voltage and phase current samples together with performing an optional sensor phase shift correction. METERLIB2PH_CalcWattHours recalculates active energy using new voltage and current samples. CONFIG_UpdateOffsets updates offset of the phase voltage and current measurements conditionally. The CH3 calls the next software interrupt, auxcalc_callback where non-billing quantities are calculated: METERLIB2PH_CalcVarHours recalculates reactive energy. METERLIB2PH_CalcAuxiliary recalculates URMS, IRMS, PAVG, QAVG and S auxiliary quantities. You can find more information about the Filter-Based Algorithm function in the AN4265 document.   HMI Control The display_callback task is called every 3 Hz by the auxcalc_callback and is executed on the lowest priority. For this application it update the clock data structure, refresh the watchdog timer and call some metering algorithm functions to read the values of the billing and non-billing quantities: METERLIB2PH_ReadResultsPh1 reads URMS, IRMS, PAVG, QAVG and S auxiliary quantities from phase 1. METERLIB2PH_ReadResultsPh2 reads URMS, IRMS, PAVG, QAVG and S auxiliary quantities from phase 2. A timer interrupt is used to update the the LCD content every 1500 ms. static void lptmr_callback (void) {   lcd_all_off();   /* update menu index                                                    */   menu_fcn[menu_idx]();   if ((++menu_idx) >= DIM(menu_fcn))   {     menu_idx = 0;   } }‍‍‍‍‍‍‍‍‍‍ Results The two-phase hardware has been calibrated using the test equipment ELMA8303. During accuracy calibration and testing, the power meter measured electrical quantities generated by the test bench, calculated active and reactive energies, and generated pulses on the output LEDs; each generated pulse was equal to the active and reactive energy amount kWh (kVARh)/imp3. The deviations between pulses generated by the power meter and reference pulses generated by test equipment defined the measurement accuracy.   The next figure shows the calibration protocol of the power meter. The protocol indicates the results of the power meter calibration performed at 25 °C. The accuracy and repeatability of the measurement for various phase currents and angles between phase current and phase voltage are shown in these graphs. The first graph indicates the accuracy of the active and reactive energy measurement after calibration. The x-axis shows variation of the phase current, and the y-axis denotes the average accuracy of the power meter computed from five successive measurements The second graph (on the bottom) shows the measurement repeatability; i.e. standard deviation of error of the measurements at a specific load point.  You will find attached a ZIP file containing the IAR source code of the application and a PDF file showing the complete results of the protocol. I hope the information helps. Regards, Adrian Cano
查看全文
Latest published errata for ISF 2.1
查看全文
VREF module provide one input pin VREF, this pin can provide reference voltage for both external circuit but also for internal Sigma Delta ADCs, AFE and DAC.  Also it includes trim function in it. In this document, I would like to use my testing to do a linearity analysis. From figure1 and 2, you can find how to make VREF as reference voltage of different analog module. For example, you can find when S1 switches down, S0 closes and S2 select VREF, VREF will be voltage resource of SAR ADC.                                               Figure 1: Voltage reference function configuration                                   Figure 2: Voltage reference module diagramming I do a testing for VREF trim value linear analysis. The process is connecting the voltmeter to VREFH pin, then record measure result for each setting of VREF trim. There will be 64 records for every different setting. Testing chip is MKM34Z256. Please find my testing result from testing data table. From testing result, you can get the formula that y = kx + x0, where k is about 0.005 (5mV) and x0 is about 1.1881, x is trim value.  You can find there is only a little offset from offset curve.                                         Table 1: Trim voltage testing date                                                                 Figure 3: Offset curve
查看全文
Hi everyone,      I have got customer queries on unavailability of complementary mode PWM on KL25Z . So, I thought let me experiment something and post it onto the community.      The timer module on KL25 is TPM, not FTM!. There are 3 TPMs, TPM0 with 6 channels, TPM1 and TPM2 with 2 channels each. To generate a PWM signal, PWM component can be used. But the PWM bean doesnot provide option to generate complementary PWM. So, we need to configure different channels to get the complementary PWM. Again, there is a limitation for this. PWM component doesn't allow to generate initial polarity high. It says "the inherited component doesnot support this feature". But in run time can set or clear value on the PWM output pin using the SetValue() and ClrValue(). But again the inherited component"TimerUnit_LDD" doesn't support generating SetValue() and ClrValue().      So, I came to a conclusion 'not to use PWM component' and started using Init_TPM. Using this component, 2 channels are configured to have opposite polarity during initialization. They are configured to have the same period. Deadtime is also inserted by configuring different duty cycle on each channel. But methods are not available since the component only provides the initialization function which is good enough to start . Dynamically if dutycycle needs to be changed, methods have to be written explicitly     Project and oscilloscope captures are attached for reference. Hi Note that this is also supported in the uTasker project - see http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF See specifically the final page - this is compatible for K and KL processors. Regards Mark http://www.utasker.com/kinetis.html This document was generated from the following discussion: Complementary PWM on FRDM-KL25Z using processor expert
查看全文
The following (after the "- - - - - -" is debugged code for flashing Green, Red, and Blue LEDs on the FRDM-K22F module. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "fsl_device_registers.h" #include "board.h" static int i = 0; int main(void) {   // LEDs are common-anode, with cathodes connected to port pins.   // Therefore, logic high (1) turns them off, and logic low   // (0) turns them on.   short OFF = 1;   short ON = 0;         hardware_init();           GPIO_DRV_SetPinDir(kGpioLED1, kGpioDigitalOutput); //Green LED      GPIO_DRV_SetPinDir(kGpioLED2, kGpioDigitalOutput); //Red LED      GPIO_DRV_SetPinDir(kGpioLED3, kGpioDigitalOutput); //Blue LED      GPIO_DRV_WritePinOutput(kGpioLED1, OFF); //Green LED initially off      GPIO_DRV_WritePinOutput(kGpioLED2, OFF); //Red LED initially off      GPIO_DRV_WritePinOutput(kGpioLED3, OFF); //Blue LED initially off      while (1)           {           for (i = 0; i<0xFFFFFF; i++)           {           }           GPIO_DRV_WritePinOutput(kGpioLED1, ON); //Green LED on           for (i = 0; i<0xFFFFFF; i++)           {           }           GPIO_DRV_WritePinOutput(kGpioLED1, OFF); //Green LED off           for (i = 0; i<0xFFFFFF; i++)           {           }           GPIO_DRV_WritePinOutput(kGpioLED2, ON); //Red LED on           for (i = 0; i<0xFFFFFF; i++)           {           }           GPIO_DRV_WritePinOutput(kGpioLED2, OFF); //Red LED off           for (i = 0; i<0xFFFFFF; i++)           {           };           GPIO_DRV_WritePinOutput(kGpioLED3, ON); //Blue LED on           for (i = 0; i<0xFFFFFF; i++)           {           }           GPIO_DRV_WritePinOutput(kGpioLED3, OFF); //Blue LED off           }      return 0; }
查看全文
This manual explains how to create a project in CW and add components to Processor Expert. It also includes a couple of examples to print and get data with the printf and scanf functions from the stdio library by using Serial component (UART).
查看全文
Recently I have received a report which said the customers met compiling issue when they imported the an2295sw CW project file and started to build it, the error message is like the following: When I looked into this issue, I found it was mainly due to some asm source file which was dedicated for Keil wrongly included in the CW project , so there would syntax error during compiling, and the linker issue was due to the path of linker file was wrongly defined, fix them would solve most of the compiling. 1. Fix source file issue: deselect the bootloader.asm file. 2. Fix linker file issue: redefine the correct path for linker file There is also an exception when you try to compile with the configuration for K70 120MHz part, it is due to some files can not be opened because the including path are missing: so besides the above changes, you have to add the paths below to solve this issue for Kinetis 120MHz part.    BTW, during debugging, I also found it is not convenient to switch between different configurations because users have to choose the proper header file for different platforms manually, so I add the following changes to support automatic switching platform according to the configuration but just with an exception for Kinetis K-1M 100MHz part, which still have to choose the proper platform manually. Customers who have downloaded an2295sw may directly replace the following files with that I attached in this document, which have included all above changes mentioned. an2295sw\src\Kinetis\CW_10.3\AN2295_Kinetis\.project an2295sw\src\Kinetis\CW_10.3\AN2295_Kinetis\.cproject an2295sw\src\Kinetis\CommonSource\bootloader_cfg.h Hope that helps, Kan
查看全文
The document describes how to port yaffs2 file system for MQX. The detailed porting user guide can refer to the attached doc which use TWR-K70F120M as example. The reference code can be found in the attached source code package. Now, the yaffs2 for MQX can support NFC and non-NFC at the same time, the only difference is NAND driver. For NFC, you should use NFC driver and for non-NFC, you should use softnand driver. In yaffs2 porting package, include the files which should be modified in MQX release package. user_config.h should be placed at \config\platform name\ init_nandflash.c should be placed at \mqx\source\bsp\platform name\ \nandflash is the NAND driver, should be at \mqx\source\io\ \yaffs2 is the yaffs2 porting codes should be at the root directory of MQX release package softnand2K.c is the NAND driver for non-NFC(simulated by flexbus).
查看全文
Abstract         Kinetis M series MCU is Freescale’s Metrology microcontrollers based on ARM Cortex M0+ cores. The SPI module of KM provides for full-duplex, synchronous, serial communication between the MCU and peripheral devices, it also has programmable 8 or 16 bit data transmission length, 64bit FIFO mode for data transfers, DMA transmit and receive features, single wire bidirectional mode, etc. This document is mainly use the KM34Z256VLQ7 SPI module realize the erase, program and read operation in external flash MX25L6404EM2I, it also gives sample code of the detail command external flash operation, and at last, print the testing code via UART. 1.SPI pin assignment and basic code (1) SPI pin assignment SPI signal Pin name Description SPI_SS PTD1 Slave select SPI_SCK PTD2 SPI serial clock SPI_MOSI PTD3 Master data out, slave data in SPI_MISO PTD4 Master data in, slave data out External flash MX25L6404EM2I circuit: (2) SPI initialization   SPI initialization configuration the SPI pin, SPI module baud, master or slave mode, module enable, etc. the code just as following: SIM_SCGC4 |= SIM_SCGC4_SPI0_MASK|SIM_SCGC4_SPI1_MASK;                             SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK; void serial_flash_init(void) {     PORTD_PCR1 &= ~PORT_PCR_MUX_MASK;            PORTD_PCR1 |= PORT_PCR_MUX(1) |0X03;                                           //Use PTD1 as SPI0_SS  // configure it as the GPIO     PORTD_PCR2 &= ~PORT_PCR_MUX_MASK;     PORTD_PCR2 |= PORT_PCR_MUX(3) |0X03;                                           //Use PTD2 as SPI0_SCK     PORTD_PCR3 &= ~PORT_PCR_MUX_MASK;     PORTD_PCR3 |= PORT_PCR_MUX(3) |0X03;                                           //Use PTD3 as SPI0_MOSI      PORTD_PCR4 &= ~PORT_PCR_MUX_MASK;     PORTD_PCR4 = PORT_PCR_MUX(3) |0X03;                                            //Use PTD4 as SPI0_MISO     GPIOD_PDDR |=  0X02; // SS pin output     GPIOD_PDOR |=  0X02; //  SS pin high     SPI0_C1 |= SPI_C1_MSTR_MASK; // SPI0 master mode                             SPI0_BR = 0x43;  //SPPR = 4, SPR = 3, bps div = (SPPR+1)*2^(SPR+1) = 80, baudrate= 24Mhz/80=300khz     SPI0_C1 |= SPI_C1_SSOE_MASK;                              SPI0_C1 &= (~SPI_C1_CPHA_MASK);  // clock polarity     SPI0_C1 &= (~SPI_C1_CPOL_MASK);  //clock phase     SPI0_C1 &= (~SPI_C1_LSBFE_MASK);  // LSB:most significant     SPI0_C1 &= (~SPI_C1_SPIE_MASK);                  //Disable RX interrrupt      SPI0_C1 &= (~SPI_C1_SPTIE_MASK);         //Disable the transmit interrupt     SPI0_C2 |= SPI_C2_MODFEN_MASK;             SPI0_C1 |= SPI_C1_SPE_MASK;  // enable SPI module } (3) One byte transfer code uint8 hal_spi_transfer_one_byte(uint8 v) {    int dummy =0;    char buff=0;    while ((SPI0_S & SPI_S_SPTEF_MASK) == 0)  // wait for transmit buffer empty    {                 dummy++;     }    dummy = SPI0_S;    SPI0_DL = v;   // send one byte to transmit buffer    while ((SPI0_S & SPI_S_SPRF_MASK) == 0); // wait ready buffer full    buff = SPI0_DL;  // read one received byte    return buff;         // return the received byte   } 3 Code realization for external flash operation command     At first, refer to the external flash program / erase flow, then I will give the according command code realization one by one. Take flash sector erase flow as an example, the according code is : void hal_spi_dev_flash_erase_sector(uint8 addr) { write_enable();      // WREN command spi_wait(WEL);     // RDSR command and wait WEL=1 hal_spi_transfe_start();    // enable CS pin , CS=0 hal_spi_transfer_one_byte(CMD_SECTOR_ERASE);   // erase one sector (4KByte)command hal_spi_transfer_one_byte(addr>>16);  // address hal_spi_transfer_one_byte(addr>>8); hal_spi_transfer_one_byte(addr>>0); hal_spi_transfe_stop();  // disable CS pin, CS=1 spi_wait(WIP);    // RDSR command and wait WIP=0;   } (1)Write enable (WREN) command : 0X06 static void write_enable(void) {     hal_spi_transfe_start();  // enable CS pin , CS=0     hal_spi_transfer_one_byte(CMD_WRITE_EN);  // Send WREN command     hal_spi_transfe_stop();  // disable CS pin, CS=1   } (2)Read status register (RDSR) sequence: 0X05 static void spi_wait(uint8 CMD) { if(CMD == WEL) while(get_sr()&0x02 != 0x02); // wait until WEL bit =1 else if(CMD == WIP) while(get_sr()&0x01 != 0x00); // wait until WIP bit =0 } static uint8 get_sr(void) {     uint8 v;     hal_spi_transfe_start(); // enable CS pin , CS=0     hal_spi_transfer_one_byte(CMD_GET_SR);  // Send RDSR command     v = hal_spi_transfer_one_byte(0x00); // read states register data     hal_spi_transfe_stop();    // disable CS pin, CS=1     return v;   } (3) Sector erase (SE) sequence: 0X20 hal_spi_transfe_start();    // enable CS pin , CS=0 hal_spi_transfer_one_byte(CMD_SECTOR_ERASE);   // erase one sector (4KByte)command hal_spi_transfer_one_byte(addr>>16);  // address hal_spi_transfer_one_byte(addr>>8); hal_spi_transfer_one_byte(addr>>0);   hal_spi_transfe_stop();  // disable CS pin, CS=1 (4) Page program (PP) sequence : 0x02 #define PAGE_SIZE 256       hal_spi_transfe_start();// enable CS pin , CS=0 hal_spi_transfer_one_byte(CMD_PROGRAM); //send flash program command hal_spi_transfer_one_byte(addr>>16); // flash page base address hal_spi_transfer_one_byte(addr>>8); hal_spi_transfer_one_byte(addr>>0); for(i=0;i<(PAGE_SIZE-1);i++) // send program data to the flash page hal_spi_transfer_one_byte(buf[i]); hal_spi_transfer_one_byte(buf[i]);   hal_spi_transfe_stop();// disable CS pin, CS=1 (5) Read at higher Speed(FAST_READ) Sequence: 0X0B void hal_spi_dev_flash_read_page(uint8 addr, char *buf) { int i; hal_spi_transfe_start();  // enable CS pin , CS=0 hal_spi_transfer_one_byte(CMD_READ); // read command hal_spi_transfer_one_byte(addr>>16);  // base address hal_spi_transfer_one_byte(addr>>8); hal_spi_transfer_one_byte(addr>>0); hal_spi_transfer_one_byte(0x00); // dummy byte for(i=0;i<(PAGE_SIZE-1);i++)    // read data back from the flash buf[i] = hal_spi_transfer_one_byte(0x00); buf[i] = hal_spi_transfer_one_byte(0x00); hal_spi_transfe_stop();  // disable CS pin, CS=1   } 4 Experimental result The test code function is to realize one sector (4KB) erasing, then read one page (256Byte) and print it out, after that, program one page , read and print it out to check the data. (1)The main function code is : static char buf[256]; int i; serial_flash_init();  // SPI initialization hal_spi_dev_flash_erase_sector(0); // erase one sector(4KByte) printf("reading page...\n"); hal_spi_dev_flash_read_page(0,buf); // read one page(256Byte) print_buf(buf,PAGE_SIZE);  // print the read data out printf("programing a page...\n"); for(i=0;i<256;i++) buf[i] = i;     // define the data which will write to the flash hal_spi_dev_flash_program_page(0,buf); // write 256BYTE to the flash page0 printf("clearing buffer..\n"); for(i=0;i<256;i++)    // clear buff buf[i] = 0; printf("reading page...\n"); hal_spi_dev_flash_read_page(0,buf); // read the page0 data out print_buf(buf,PAGE_SIZE);  // print the read data out   printf("demo end.\n"); (2) print test data reading page... 0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,  programing a page... clearing buffer.. reading page... 0x0,0x1,0x2,0x3,  0x4,0x5,0x6,0x7,  0x8,0x9,0xA,0xB,  0xC,0xD,0xE,0xF,  0x10,0x11,0x12,0x13,  0x14,0x15,0x16,0x17,  0x18,0x19,0x1A,0x1B,  0x1C,0x1D,0x1E,0x1F,  0x20,0x21,0x22,0x23,  0x24,0x25,0x26,0x27,  0x28,0x29,0x2A,0x2B,  0x2C,0x2D,0x2E,0x2F,  0x30,0x31,0x32,0x33,  0x34,0x35,0x36,0x37,  0x38,0x39,0x3A,0x3B,  0x3C,0x3D,0x3E,0x3F,  0x40,0x41,0x42,0x43,  0x44,0x45,0x46,0x47,  0x48,0x49,0x4A,0x4B,  0x4C,0x4D,0x4E,0x4F,  0x50,0x51,0x52,0x53,  0x54,0x55,0x56,0x57,  0x58,0x59,0x5A,0x5B,  0x5C,0x5D,0x5E,0x5F,  0x60,0x61,0x62,0x63,  0x64,0x65,0x66,0x67,  0x68,0x69,0x6A,0x6B,  0x6C,0x6D,0x6E,0x6F,  0x70,0x71,0x72,0x73,  0x74,0x75,0x76,0x77,  0x78,0x79,0x7A,0x7B,  0x7C,0x7D,0x7E,0x7F,  0x80,0x81,0x82,0x83,  0x84,0x85,0x86,0x87,  0x88,0x89,0x8A,0x8B,  0x8C,0x8D,0x8E,0x8F,  0x90,0x91,0x92,0x93,  0x94,0x95,0x96,0x97,  0x98,0x99,0x9A,0x9B,  0x9C,0x9D,0x9E,0x9F,  0xA0,0xA1,0xA2,0xA3,  0xA4,0xA5,0xA6,0xA7,  0xA8,0xA9,0xAA,0xAB,  0xAC,0xAD,0xAE,0xAF,  0xB0,0xB1,0xB2,0xB3,  0xB4,0xB5,0xB6,0xB7,  0xB8,0xB9,0xBA,0xBB,  0xBC,0xBD,0xBE,0xBF,  0xC0,0xC1,0xC2,0xC3,  0xC4,0xC5,0xC6,0xC7,  0xC8,0xC9,0xCA,0xCB,  0xCC,0xCD,0xCE,0xCF,  0xD0,0xD1,0xD2,0xD3,  0xD4,0xD5,0xD6,0xD7,  0xD8,0xD9,0xDA,0xDB,  0xDC,0xDD,0xDE,0xDF,  0xE0,0xE1,0xE2,0xE3,  0xE4,0xE5,0xE6,0xE7,  0xE8,0xE9,0xEA,0xEB,  0xEC,0xED,0xEE,0xEF,  0xF0,0xF1,0xF2,0xF3,  0xF4,0xF5,0xF6,0xF7,  0xF8,0xF9,0xFA,0xFB,  0xFC,0xFD,0xFE,0xFF,    demo end From the print data, we can find the code can realize flash sector erasing , flash program and flash data read out, and the test result is correct. The following wave is the page read data out after flash page program. The attachment is the testing code.
查看全文
1. Introduction MCUboot is a common used bootloader for most of Kinetis and i.mx RT devices. It can support download application via UART/USB/CAN/I2C/SPI. It enables quick and easy programming of Kinetis MCUs and i.mx RT MPU through the entire product life cycle, including application development, final product manufacturing, and beyond. K64 is a very popular device in Kinetis family. It has a M4 core, 512k and above flash, 120M main frequency and plenty of interface, such as I2C/SPI/UART/CAN/USB/ENET. But it is a bit awkward that the MCUboot demo of K64 is not include CAN. Does K64’s CAN can’t support bootloader application? No, of course not. Here we are going to port CAN function to K64 bootloader. There are two kind of CAN peripheral in Kinetis family, FlexCAN and MSCAN. FlexCAN is more complex than MSCAN. K64 has a FlexCAN. To speed up our work, we can port FlexCAN driver and related code from TWR-KV46 bootloader. Hardware: two TWR-SER board two sets of TWR-ELEV TWR-K65F150M TWR-K64F120M   Software: MCUXpresso 11.0 MCUBoot 2.0.0 package SDK_2.6.0_TWR-K64F120M 2. Software porting Step 1, copy below files to twrk64f120m_tower_bootloader project. \drivers\fsl_flexcan.c \drivers\fsl_flexcan.h        \source\bootloader\src\flexcan_peripheral_interface.c   Step 2, modify the project to enable the FlexCAN.       In bootloader_config.h, change BL_CONFIG_CAN definition to 1.        In peripherals_MK64F12.c, add #if BL_CONFIG_CAN     // CAN0     {.typeMask = kPeripheralType_CAN,      .instance = 0,      .pinmuxConfig = can_pinmux_config,      .controlInterface = &g_flexcanControlInterface,      .byteInterface = &g_flexcanByteInterface,      .packetInterface = &g_framingPacketInterface }, #endif    // BL_CONFIG_CAN       Pin mux setting. In peripherals_pinmux.h, add #define BL_ENABLE_PINMUX_CAN0 (BL_CONFIG_CAN) //! CAN pinmux configurations #define CAN0_RX_PORT_BASE PORTB #define CAN0_RX_GPIO_PIN_NUM 18             // PIN 13 in the PTA group #define CAN0_RX_FUNC_ALT_MODE kPORT_MuxAlt2 // ALT mode for CAN0 RX functionality for pin 13 #define CAN0_TX_PORT_BASE PORTB #define CAN0_TX_GPIO_PIN_NUM 19             // PIN 12 in the PTA group #define CAN0_TX_FUNC_ALT_MODE kPORT_MuxAlt2 // ALT mode for CAN0 TX functionality for pin 12       Set clock. FlexCAN clock source can be OSCERCLK or bus clock. Here we use bus clock run at 48Mhz. In flexcan_peripheral.c, add these code. const flexcan_timing_config_t bit_rate_table48m[] = {     { 23, 3, 4, 4, 4 }, /* 125 kHz */     { 11, 3, 4, 4, 4 }, /* 250 kHz */     { 5, 3, 4, 4, 4 },  /* 500 kHz */     { 3, 3, 4, 4, 4 },  /* 750 kHz */     { 2, 3, 4, 4, 4 }   /* 1   MHz */ }; change line 621 FLEXCAN_SetTimingConfig((CAN_Type *)baseAddr, &bit_rate_table48m[s_flexcanInfo.baudrate]); Step 3, compile the project.   3. Function test Software preparation To connect bootloader via CAN bus, NXP has TWR-K65 as bridge. But its source code is not in K64 SDK. It is in MCUBoot2.0.0 package. User can download the package from https://www.nxp.com/design/software/development-software/mcuxpresso-software-and-tools/mcuboot-mcu-bootloader-for-nxp-microcontrollers:MCUBOOT The bridge project is called buspal which can be found in NXP_Kinetis_Bootloader_2_0_0\apps\bus_pal\MK65F18. BusPal is an embedded software tool that is available as a companion to blhost. The tool acts as a bus translator with an established connection with blhost over UART and with the target device over I2C, SPI, or CAN, and assists blhost in carrying out commands and responses from the USB target device. The BusPal is available for selected platforms. The source code for BusPal is provided with the Kinetis bootloader release, it support FRDM-KL25, TWR-KV46F150M and TWR-K65F180M and can be customized to run on other platforms. More detail of buspal is in Kinetis blhost User's Guide appendix C.   Hardware connection TWR-SER has TJA1050 as transceiver. We can connect J7 on both boards. When construct the Tower system, user should take care the power. The power tree is very flexible. Improper setting may cause TJA1050 can’t work.   The Buspal project on TWR-K65F180M use UART1 to connect with computer. The port is on TWR-SER. To make the connection simple, we can share the openSDA UART port. The openSDA UART use UART2, we can jump UART1 signal to J33 and J34 on K65 tower board.     Testing: Open a command window, type >blhost -p com4,57600 –buspal can,0,321,123 – get-property 10 This command can check if the whole system work properly. Then, you can download the code to K64 now. Please type >blhost -p com4,57600 –buspal can,0,321,123 – flash-image xxxxxx.s19 erase
查看全文
El programador USBDM es una interfaz de programación y depuración para los microcontroladores Freescale, existen varias versiones de esta herramienta, el programador MantaRay USBDM está basada en la versión para los microcontroladores HCS08(BDM) y Kinetis (SWDIO). Toda la información acerca de este proyecto puedes encontrarlo en http://usbdm.sourceforge.net/index.html BDM (Background debug mode) El puerto de programación BDM es una interfaz de programación desarrollada por Freescale para los microcontroladores HCS08 (8 bits) y Coldfire V1 (32 bits). Las características más sobresalientes sobre este puerto de programación es que solo utiliza un pin de programación (BKGD). Además de permitir la programación de la memoria flash, también permite el "debug in circuit" esto quiere decir que podemos depurar nuestro codigo en tiempo real a través del software Codewarrior. SWDIO Es la versión minima del JTAG para los microcontroladores Kinetis (Cortex ARM 32 bits) en la cual solo utiliza una linea de comunicación (SWDIO) y una señal de reloj (SWCLK). Este puerto esta en los Cortex M0 como son KL01, KL02, KL03, KL1x,KL2x,KE02,KE04 y KE06. El programador MantaRay USBDM permite la programación y la depuración de los microcontroladores de Freescale de la gama de 8 bits y 32 bits. Shrimp El complemento perfecto para el programador MantaRay USBDM es Shrimp, una pequeña tarjeta que tiene el tamaño exacta de un integrado con montaje DIP28 600mil, la cual, la hace una herramienta flexible, al hacer prototipos en una protoboard, y después en un prototipo final. La tarjeta Shrimp es compatible con los microcontroladores de 8 bits MC9S08PA16 y de 32 bits MKE02Z16, los dos totalmente compatibles en pines y periféricos. MC9S08PA16 8-Bit S08 central processor unit (CPU) – Up to 20 MHz bus at 2.7 V to 5.5 V across temperature range of -40 °C to 105 °C – Supporting up to 40 interrupt/reset sources – Supporting up to four-level nested interrupt – On-chip memory – Up to 16 KB flash read/program/erase over full operating voltage and temperature – Up to 256 byte EEPROM; 2-byte erase sector; program and erase while executing flash – Up to 2048 byte random-access memory (RAM) – Flash and RAM access protection MKE02Z16 • Operating characteristics – Voltage range: 2.7 to 5.5 V – Flash write voltage range: 2.7 to 5.5 V – Temperature range (ambient): -40 to 105°C • Performance – Up to 40 MHz ARM® Cortex-M0+ core and up to 20 MHz bus clock – Single cycle 32-bit x 32-bit multiplier – Single cycle I/O access port • Memories and memory interfaces – Up to 16 KB flash – Up to 256 B EEPROM – Up to 2 KB RAM Más información técnica la puedes encontrar en el siguiente link http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KE02&nodeId=01624698C90DE4 http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=S08P&nodeId=01624684491437EDDD Muy pronto mas adelantos de este proyecto
查看全文
Hi All: when someone program FSL MCU  by theirself program tool, and the flash size is over 64KByte , please reference the document. the document is chinese version Br Felix
查看全文
Some of our customers encountered clock stretching issue when using the I2C. Actually the first should been in mind is the clock stretching is usually done by the slave, not the master.  In the case for the Kinetis as master to connect with I2C device, the clock stretching should been done by the slave device. In this case the slave device should hold the clock signal low until it has data available. There isn’t anything that needs to be done to enable clock stretching on the master side. So how the code do with the clock stretching? The slave should toggling read_start high first and reading the data register to actually start the transfer. Be remember that the read from the data register is what actually triggers the transfer. Customer always missed this point.
查看全文
MAPS-KS22 Board Introduction: MAPS boards are localization evaluation boards for Chinese customers. The MAPS boards are suitable for NXP MCU product, with low coat, more flexibility and easy-copy features, which matching with local customer requirements and better for learning and product evaluation. MAPS board includes four parts board, which are MCU Board, Peripheral Board, Application Board & Socket Board. The naming of MAPS are using the four-part board initial letter. MCU board is NXP Kinetis MCU based evaluation main board with chip related special module interface/device, such as graphic LCD/ENET interface and etc. The MCU board fan out all MCU pins as test points for measuring. The MCU board also provide two 32-pin socket to connect external peripheral board or application board. Peripheral Board collects more general device into one board and using two 32-pin socket connects with MCU board. The MAPS-Dock is the first peripheral board, which with below configuration: Micor-SD card slot; six touch pads; USB FS interface; IrDA transceiver; one SPI Interface (SPI-Flash); two UART interface; four buttons; one I2S interface (audio codec); one CAN interface; two potentionmeter; one DAC output interface; 128x64 monochrome LCD; one 5-way button. It also with SWD debugger on board and USB CDC virtual COM. Application Board designed for special applications, such as motor control, IOT, Smart Home, Wireless Charger and etc. Socket Board provides interface for FreeDOM boards/Arduino boards/Customer defined boards. MAPS-KS22 board MCU board for KS22 chip evaluation. KS22 MCU is based on the ARM® Cortex®-M4 core with 120MHz MCUs with FPU, offering full-speed USB 2.0 OTG, in addition to other features like USB crystal-less functionality. MAPS-KS22 oobe demo porting process MAPS-KS22 oobe demo is based KSDK V1.0, which will show Freescale LOGO on the SPI color LCD and meanwhile use FlexIO I2S to play an audio on microphone. Step1: visit Kinetis Expert website (http://kex.nxp.com/en/welcome) to download MAPS-KS22 KSDK V2.0 software: Step2: download [Kinetis SDK Project Generator Tool] from below link and generate oobe demo project based on MAPS-KS22 SDK V2.0 software: https://www.nxp.com/webapp/sps/download/license.jsp?colCode=KSDK-PROJECT-GENERATOR-TOOL&appType=file1&location=null&DOWNLOAD_ID=null Step 3: After that, open the oobe project, which located at default path: C:\Freescale\SDK_2.0_MAPS-KS22\boards\mapsks22\user_apps\oobe\iar The default project is based on <hello-world> demo, it need to add LED control code. Those part of code could be found at <main.c> file and related pin muxing code at <pin_mux.c> file. Step 4: Modify ili9341 related driver: For the oobe project with two major functions, the first one is to display Freescale LOGO at LCD. The MAPS-KS22 board graphic LCD is using ili9341 TFT LCD driver with SPI interface with KS22 chip. The previous oobe project is using GPIO pins emulate SPI communication, we will make the similar application with KSDK V2.0 driver. Most modification based on the GPIO pins control. Please check below code at <ili9341.h> file, which call KSDK V2.0 GPIO driver: #define ILI9341_CS_HIGH()       GPIO_SetPinsOutput(BOARD_LCD_CS_GPIO, 1U << BOARD_LCD_CS_PIN) #define ILI9341_CS_LOW()        GPIO_ClearPinsOutput(BOARD_LCD_CS_GPIO, 1U << BOARD_LCD_CS_PIN) #define ILI9341_CLK_HIGH()      GPIO_SetPinsOutput(BOARD_LCD_CLK_GPIO, 1U << BOARD_LCD_CLK_PIN)  #define ILI9341_CLK_LOW()       GPIO_ClearPinsOutput(BOARD_LCD_CLK_GPIO, 1U << BOARD_LCD_CLK_PIN) #define ILI9341_MOSI_HIGH()     GPIO_SetPinsOutput(BOARD_LCD_MOSI_GPIO, 1U << BOARD_LCD_MOSI_PIN) #define ILI9341_MOSI_LOW()      GPIO_ClearPinsOutput(BOARD_LCD_MOSI_GPIO, 1U << BOARD_LCD_MOSI_PIN)      #define ILI9341_MISO_HIGH()     GPIO_SetPinsOutput(BOARD_LCD_MISO_GPIO, 1U << BOARD_LCD_MISO_PIN) #define ILI9341_MISO_LOW()      GPIO_ClearPinsOutput(BOARD_LCD_MISO_GPIO, 1U << BOARD_LCD_MISO_PIN) And it also need to add ili9341 control pin muxing initialization code at <pin_mux.c> file. Step 5: We could modify the Freescale logo with new NXP logo, which could using [Embedded GUI Conversion Utility3.0] tool. This tool could be downloaded from below link:  http://tinyurl.com/eGUI-Convert  The conversion result of the graphic data is 16-bit array, which need be transfer to 8-bit array. After that, compile and download the image to the board, it with below result: Step 6: The oobe demo provide another function to play music with MAPS-DOCK board WM8960 codec chip, then using headphone will hear the sound. For the KS22 with FlexIO module, the demo will use FlexIO emulating I2S bus to transfer data to WM8960 codec chip. About I2S bus MCLK clock source, the MAPS-KS22 provide two selection, one is using TPM1_CH1 pin, the other one is using I2S0_MCLK pin with JP5 jumper selection. In oobe demo, we use TPM1_CH1 pin to generate 12MHz MCLK clock with TPM module output compare mode. Related code, please refer below tpm_init_output_compare() function at <main.c> file: //enable clock gating of tpm1 CLOCK_EnableClock(kCLOCK_Tpm1); //set TMP output compare mode TPM_SetupOutputCompare(BOARD_TPM_BASEADDR, BOARD_TPM_CHANNEL, kTPM_ToggleOnMatch, 1U); BOARD_TPM_BASEADDR->MOD = 0x1; TPM_StartTimer(BOARD_TPM_BASEADDR, kTPM_SystemClock);   //TPM counter increments on every TPM counter clock Step 7: WM8960 is a stereo CODEC chip provide I2C port for chip configuration. There need to initialization the WM8960 chip before using it with related driver <wm8960.c> & <wm8960.h> files. The MAPS-KS22 board using LPI2C0 module connects with WM8960 chip, so there need to port using LPI2C driver of KSDK V2.0 and modify the WM8960 driver related. The LPI2C module initialization code located at <main.c> with lpi2c_master_init() function. The WM8960 driver major modification with WOLFSON_WriteReg() function at <wm8960.c> file, calling the LPI2C driver of KSDK V2.0 with below code:  wolfson_status_t WOLFSON_WriteReg(uint8_t reg, uint16_t val) {       uint8_t cmd,buff;        status_t ret;        cmd = (reg << 1) | ((val >> 😎 & 0x0001);    // register address        buff = val & 0xFF;     //data        reg_cache[reg] = val;      // copy data to cache         uint8_t data[2];         data[0] = cmd;         data[1] = buff;         //start lpi2c tx operation                   ret = LPI2C_MasterStart(LPI2C0, WM8960_I2C_ADDR, kLPI2C_Write);           // send two data with register address and related value          ret = LPI2C_MasterSend(LPI2C0, data, 2);                //stop lpi2c tx operation                  ret = LPI2C_MasterStop(LPI2C0);               if(ret != kStatus_Success)          {  return kStatus_WOLFSON_I2CFail;  }          return kStatus_WOLFSON_Success; } After WM8960 chip driver modification, there could call related driver to initialize WM8960 chip and configure the communication interface with I2S bus. Following steps focus on how to transfer data to WM8960 codec with I2S bus. Step 8:  The FlexIO modul will simulate I2S bus call FlexIO_I2S_MasterInit() function in <main.c> file to initialize FlexIO module as I2S master. There using FXIO0_D4 pin as I2S bit clock pin, using FXIO0_D5 pin as I2S Transmit pin and using FXIO0_D6 pin as I2S Transmit Frame Sync pin. KSDK V2.0 provide FlexIO for I2S driver located at <fsl_flexio_i2s.h> file. Step 9: There will call eDMA with FlexIO module to reduce the core work load during the I2S data transfer. It will initialize the eDMA & DMAMUX modules for FlexIO. Related code located at <main.c> file with ConfigDMAforFlexIOI2STX() function: void ConfigDMAforFlexIOI2STX(void) { EDMA_GetDefaultConfig(&dmaConfig); EDMA_Init(EXAMPLE_DMA, &dmaConfig); EDMA_CreateHandle(&dmaHandle, EXAMPLE_DMA, EXAMPLE_CHANNEL); DMAMUX_Init(DMAMUX0); DMAMUX_SetSource(DMAMUX0, EXAMPLE_CHANNEL, EXAMPLE_DMA_SOURCE); DMAMUX_EnableChannel(DMAMUX0, EXAMPLE_CHANNEL); }    Step 10: KSDK V2.0 software provides FlexIO I2S eDMA driver located at <fsl_flexio_i2s_edma.c> file, with below codes to initialize FlexIO I2S master DMA handler and to configure the sample rate & audio data format to be transferred: FLEXIO_I2S_TransferTxCreateHandleEDMA(&base, &txHandle, callback, NULL, &dmaHandle); FLEXIO_I2S_TransferSetFormatEDMA(&base, &txHandle, &format, 48000000); Step 11: After above preparation, following action will start to transfer music data to WM8960 codec with below code. When the music data transfer finished, the callback function will be called to start next round data transferred. Then we could hear the sound with endless loop. static void callback(FLEXIO_I2S_Type *i2sBase, flexio_i2s_edma_handle_t *handle, status_t status, void *userData) {   // Initiate FlexIO I2S transfer again after previous transfer finished  FLEXIO_I2S_TransferSendEDMA(&base, &txHandle, &xfer); } About more detailed oobe demo software info, please check attached file. The default oobe demo located path is: C:\Freescale\SDK_2.0_MAPS-KS22\boards\mapsks22\user_apps\oobe
查看全文
在工业热电偶数据采集与处理方面,ADI,MAXIM的模拟芯片几乎占据了90%以上的市场,尽管他们的单片售价高的吓人。1片16位的AD芯片没有个2个美金是买不到的,24位的更不用多说。现在他们的竞争对手来了,飞思卡尔针对表计市场推出的基于M0+内核的KM1x,KM3x,片上集成24位的Σ-Δ模拟前端, 其中2路带有独立的可编程最高32倍PGA,无论是市场上应用最多的K型热电偶、还是专注于低温测量的T型热电偶,通过合理的配置都可以满足他们极宽范围的量程。确切的讲,KMxx和这两种产品根本不能算是一个数量级的PK对手,无论从资源上还是从价格上。但是尽管这样,就一定能打败竞争对手吗?首先得有的说服力的参考设计吧,不着急,已经开始设计了。 处理器:MKM33Z128CLH5 暂定功能: 1. K型热电偶+T型热电偶兼容采集处理,板上预留2种热电偶接口,带冷端温度补偿功能 2. 按键切换热电偶类型 3. 段码式LCD显示采集的实时温度,状态显示 4. 低功耗演示,面向手持式设备市场 5. 音乐变调蜂鸣器 主要针对竞争目标:Maxin的 MAX31855KASA (T型热电偶) 关于精度嘛,等参考设计完成了测试一下就知道了。 以上参考设计敬请等待,也欢迎多提宝贵建议。
查看全文
This is a port of the TWR_K60N512 "Audio" Demo into Kinetis Design Studio and into eGUI 3.0 (from 2.1). The original demo is from Petr Gargulak and was under "Freescale_embedded_GUI_SW.zip\_Official_Demos\EGUI_D4D_Demo\TWR_K60N512\BareMetal\CW_10_1" avaiable on the freescale website. Some of the major porting differnces (this may help others porting similar projects): KDS: KDS by default does not define 'asm()', switch these to '__asm()' or change compiler settings (see: Sorting out asm(); in KDS: How to change your compiler language to GNU ISO90) eGUI 2.1 -> 3.0: Autosize feature has gone, all object sizes now need to be declared Objects seem to add padding of some sort: even with objects where size was previously declared, these had to be increased by ~3px in each direction, else text/images would not render. 'D4D_OBJECT_SYS_FUNCTION' structure no longer contains 'type'. It suggests using strName instead to identifier object. D4D_TEXTBOX no longer has title or icon functionality. When building this project there will be ~7 warnings from the compiler, including 2 of my own. The code should function fine. note: TWR_LCD settings for this project, switches are set up with in following sequence: "01111110". regards, Rael S-R
查看全文
Producto dirigido para terapias visuales y motrices. Consiste en una matriz de 6x3 LEDs, una columna verde, una amarilla y una roja. Aleatoria mente, se encenderá un LED que se encuentra hasta arriba, y ese irá bajando por la columna de su color hasta llegar al ultimo. Cuando eso suceda, se deberá presionar el botón del color correspondiente. Si esto se realiza correctamente, se suma un punto, de lo contrario se restan tres y suena un buzzer. Los puntos se despliegan en pantalla. La velocidad del juego se puede controlar con un potenciometro y un motor Servo se mueve dependiendo del puntaje.
查看全文