Kinetis Microcontrollers Knowledge Base

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

Kinetis Microcontrollers Knowledge Base

Discussions

Sort by:
For Jorge_Gonzalez Subject: MKE04 interrupt latency in Kinetis microcontrollers This is the code I was using to measure interrupt latency. David Hollinrake
View full article
The Kinetis K70 MCU family includes 512KB-1MB of flash memory, a single precision floating point unit, Graphic LCD Controller, IEEE 1588 Ethernet, full- and high-speed USB 2.0 On-The-Go with device charge detect, hardware encryption, tamper detection capabilities and a NAND flash controller. 256-pin devices include a DRAM controller for system expansion. The Kinetis K70 family is available in 196 and 256 pin MAPBGA packages. For more information visit www.freescale.com/kinetis
View full article
You probably have heard of what's new on Kinetis side of the house. YES, talking about KL02, measuring only 1.9mm x 2.0mm. Take a look at the picture in which this powerful ARM based chip gets compared real scale, and being this tiny yet delivers 60 percent more GPIO than the nearest competing MCU. :smileygrin:!!!
View full article
    类似前段时间我写的两篇关于知识产权保护芯片加密的文章,这次再说说产品量产时常需要考虑的另一个问题——烧写序列号。     在产品批量生产的时候,很多客户会有这样的需求,即将每个芯片烧写一个唯一的ID号(Serial Number),以方便对产品进行跟踪和管理或者满足对芯片进行绑定ID号加密的需要。而为了提高整个批量生产过程的效率,选择一个好的烧写工具则至关重要。对飞思卡尔的Kinetis系列来说,可用的烧写方案包括P&E官方的Cyclone MAX(支持在线烧写和脱机烧写,当然价格较贵)和J-Link(仅支持在线烧写,需要仿真器+上位机配合)等,本篇就以最近比较火的Freescale M0+ Kinetis L系列为例详细介绍一下J-Link+J-Flash批量烧写串号的方案(说到此,不得不感叹J-Link的强大,高速的下载和调试,丰富的IDE支持和调试组件和强有力的调试功能,不是土豪人家是金啊,怎一个强大了得): 开发平台:Kinetis L系列KL15Z128 烧写工具:J-Link + J-Flash(v4.76f) (1) 这里不单独对J-Flash多作介绍,可以参考我之前的一篇文章《教你用J-Flash ARM工具单独烧写程序到Kinetis》,至于包括J-Flash在内的软件包可以直接到SEGGER官网下载http://www.segger.com/jlink-software.html,建议下载最新版的,支持的芯片系列较全,相应的组件功能也更强大; (2) 打开J-Flash(路径为Start->All Programs->SEGGER->J-Link ARM V4.76f->J-Flash),在最新版本中会直接弹出选择已有工程选项卡,根据需要在路径"安装路径\SEGGER\JLinkARM_V476f\Samples\JFlash\ProjectFiles\Freescale”下选择自己的目标芯片(我这里选择MKL15Z128xxx4.jflash),选择如下图: (3) 点击“start J-Flash”进入工程管理界面,然后点击File->Open data file,找到需要下载的bin文件或者S19文件,将其加载到jflash工程里面,加载之后的界面如下图: (4) 万事具备,接下来就开始进行烧写序列号的设置。点击“Options->Project Settings->Production”,选中“Program Serial Number”,设置如下: (5) 点击“OK”,设置完毕(只设置一次即可),然后连接目标芯片“Target->Connect”,连接成功,点击“Auto”,系统会自动将设置好的序列号添加到s19文件相应的地址然后启动下载,同时也会在Jflash的工程目录(之前加载的sample prject的目录)下生成一个“<JFlashProjectName>_Serial.txt”,内容如下图,其中“12345679”为下次要写入的数据,系统自动为其加1了(由“Increment”决定): (6) 我们回读烧写到片子中的数据(Target->Read Back->Entire chip),然后跳转到“0x2000”地址,可以看到序列号(12345678的十六进制)已经写入,如下图: 注意事项: (1) 在烧写的时候,必须点击“Auto”下载,这样才会生成“<JFlashProjectName>_Serial.txt”文件,且会把序列号自动添加到s19文件然后烧进去,直接点击“Program”或者“Program&Verify”等烧写功能只会烧写原始S19文件,不会添加序列号; (2) J-Flash烧写序列号最多支持4个字节,高于四个字节的数据J-Flash会将前四个字节取反再烧进去,所以实际上起作用的还是4个字节,不过单纯作为序列号的话肯定是足够了,4个字节32个比特位,IPv4的地址也就这些吧,呵呵,想不到会有什么产品会超过这个范围,那样的话Freescale超越当年的Motorola也不是问题了啊,哈哈; (3) 关于烧写地址的问题,理论上只要在目标芯片的Code Flash地址范围内并且不与原始运行代码地址重叠即可,因为J-Flash烧写的原理是先添加数据到原始bin或者S19文件相应的位置然后整个文件一块烧写进去,所以写序列号的时候不需要额外的再擦写扇区一次也就是不会破坏同在一个扇区的原始数据,不过当然如果flash空间足够大的话不建议将序列号烧写地址挨着原始代码太近,建议将序列号写到Flash的最后,规避风险; (4) 实际上采用J-Flash也可以烧写多余4个字节的数据,不过这需要手动添加编辑txt文件,这里就不多说了,可以参考附件中文档。
View full article
Este proyecto está siendo desarrollado por alumnos del Tecnológico de Monterrey Campus Guadalajara, el cual está orientado para servir como un tipo de terapia para personas discapacitadas. El proyecto en sí consiste en el control de un vehículo de juguete por medio de pulsaciones que serán realizadas con pelotas anti-estrés, de esta forma la persona podrá realizar un ejercicio de fortalecimiento en sus extremidades superiores de una forma más entretenida y menos tediosa que las clásicas terapias. Es importante mencionar que para poder realizar este proyecto es necesario el uso de dos tarjetas Freedom KL25Z de Freescale®, dos módulos Bluetooth®, dos servomotores de rotación continua y dos sensores de presión, los cuales serán incorporados dentro de las pelotas anti-estrés. El vehículo de juguete estará compuesto por los servomotores, que servirán como llantas; un módulo Bluetooth®, el cual recibirá las señales del otro módulo; y una de las tarjetas Freedom KL25Z. Por otro lado una de las tarjetas Freedom KL25Z estará conectada con los sensores integrados en las pelotas anti-estrés y a un módulo cuya función es mandar la información capturada por los sensores al vehículo de juguete. La mecánica del proyecto depende de la pelota que sea presionada, pues si se presiona solamente una pelota, el vehículo avanzará, por otro lado si se presiona la otra pelota, el vehículo girará sobre su propio eje. Este proyecto tiene como fin la implementación de conocimiento prácticos y teóricos en busca de una aportación en beneficio de la sociedad. También es relevante comentar que las visiones a futuro de este proyecto es que pueda ser implementado como una especie de control para una silla de ruedas, con el fin de facilitar la movilidad y aumentar la comodidad al momento de usar este tipo de vehículo. Original Attachment has been moved to: Codigo-tarjetas-freedom.zip
View full article
中文版本:     在KL25的官方Demo 源代码中只有I2C驱动的PE代码而没有I2C驱动的baremental代码,对于不习惯用PE生成代码的用户直接上手有难度,于是考虑将K60的 I2C baremental 驱动代码中移植到KL25上,以供大家参考。但在移植过程中遇到了两个比较典型的问题,所以这里分享出来,希望能帮助遇到同样问题的用户迅速定位并解决问题。 测试硬件:TWR-K60D100M开发板  K60+MMA8451(MMA8451为三轴加速传感器,与K60通过I2C总线连接。K60作为master,MMA8451作为slave)                 FRDM-KL25Z开发板       KL25+MMA8451 开发环境:IAR 6.6 1.问题描述: 配置I2Cx_F寄存器MULT位不为0时,Repeat start信号无法产生 问题提出: K60示例代码(如附件1)中I2C demo的功能是通过I2C接口读取板载的加速度传感器MMA8451的数据,并且I2C数据控制采用查询ACK标志位的方式,在TWR-K60D100M开发板上运行该Demo一切正常。使用几乎相同的I2C驱动代码,在FRDM-KL25Z开发板上执行发现:程序总是停在如下Function 1的红色字体行i2c_wait(I2C0_B),进入这个函数内部,它实际上是停在while((p->S & I2C_S_IICIF_MASK)==0),一直等待传输完成的中断标志IICIF置位。 Function 1. u8 hal_dev_mma8451_read_reg(u8 addr) {     u8 result;     i2c_start(I2C0_B);     i2c_write_byte(I2C0_B, I2C_ADDR_MMA8451 | I2C_WRITE);     i2c_wait(I2C0_B);     i2c_get_ack(I2C0_B);     i2c_write_byte(I2C0_B, addr);     i2c_wait(I2C0_B);     i2c_get_ack(I2C0_B);     i2c_repeated_start(I2C0_B);     i2c_write_byte(I2C0_B, I2C_ADDR_MMA8451 | I2C_READ);     i2c_wait(I2C0_B);     i2c_get_ack(I2C0_B);     i2c_set_rx_mode(I2C0_B);     i2c_give_nack(I2C0_B);     result = i2c_read_byte(I2C0_B);     i2c_wait(I2C0_B);     i2c_stop(I2C0_B);     result = i2c_read_byte(I2C0_B);     pause();     return result; } Function 2. void i2c_wait(I2C_MemMapPtr p) {     while((p->S & I2C_S_IICIF_MASK)==0)  ; // wait flag     p->S |= I2C_S_IICIF_MASK;    // clear flag } 原因分析:      初步判断可能是上一步数据的传输 i2c_write_byte()没有完成,导致IICIF未能被置位。于是通过示波器去捕捉这个过程,发现在执行 i2c_repeated_start(I2C0_B)时,KL25并没有产生一个 Repeat start信号。经过一番谷哥和度娘,终于在Kinetis L的Errata中找到了答案:Repeat start cannot be generated if the I2Cx_F[MULT] field is set to a non-zero value. 这也就意味着,当 I2Cx_F[MULT]位被设置为非0值时,I2C Master不能产生一个Repeat start信号。而在应用程序的I2C初始化I2C_init()代码中, 我恰好设置I2Cx_F[MULT]=01,这正好是符合了Errata描述的错误产生的条件。 解决方案:      I2C的C1寄存器中MULT位是I2C SCL时钟的倍乘因子,用于控制I2C的波特率。为解决上面的问题,FSL官方提供了两种workaround的办法: 1)如果repeat start必须产生时,配置 I2Cx_F[MULT]为0; 2)在置位 I2Cx_F register (I2Cx_C1[RSTA]=1)的Repeat START产生位之前临时设置 I2Cx_F [MULT],然后再在repeated start信号产生后恢复I2Cx_F [MULT]位的设置。 按照第一种方法,我修改程序中I2Cx_F[MULT]的设置从01到00,然后程序在FRDM-KL25Z 开发板上运行正常,能正常读取板载的加速度传感器MMA8451的数据。 2.问题描述: I2C单字节读取时序问题 问题提出: 在上面的Function 1中, KL25读取MMA8451的基本过程是:发送要访问的从机地址及对从机的写命令->发送要访问的从机的寄存器地址->发送Repeat Start信号到从机->发送要访问的从机地址及读命令->读取从机返回的数据,如下Figure1 MMA8451的单周期读时序图所示,其过程和上面代码的描述一致。但是有一点值得注意的是Figure 1中红色方框部分,按照Figure 1的表述,Master是在从Slave从机读取DATA[7:0]之后返回NAK信号的,用于指示本数据是Master要接收的最后一个DATA,最后发送stop signal终止数据的传送。按照这个思路得到的KL25的程序代码如下Section 2,它首先去读取从机返回的数据 i2c_read_byte(I2C0_B),然后发送NACK信号到从机i2c_give_nack(I2C0_B)。然而从KL25实际的物理时序的角度看,这个顺序是错误的,正确的应该是如下Section 1,应该在读取从机返回的数据 i2c_read_byte(I2C0_B)之前,首先发送NACK信号到从机i2c_give_nack(I2C0_B)。 Section 1.   i2c_set_rx_mode(I2C0_B);   i2c_give_nack(I2C0_B);----line1   result = i2c_read_byte(I2C0_B);----line2   i2c_wait(I2C0_B);----line3   i2c_stop(I2C0_B);----line4   result = i2c_read_byte(I2C0_B);----line5 Section 2.   i2c_set_rx_mode(I2C0_B);   result = i2c_read_byte(I2C0_B);-   i2c_wait(I2C0_B);   i2c_give_nack(I2C0_B);-   i2c_stop(I2C0_B); 原因: 主机发送的NACK信号只有在下一个数据接收之后才会被push到总线上,KL25的RM手册中的描述为the No acknowledge signal is sent to the bus after the following receiving data byte (if FACK is cleared)。 具体分析: 按照两个时序分别做了一个测试,并用示波器捕捉了相应的波形:执行Section 1的代码得到的波形如下Figure 2所示,NACK(1)信号刚好在第9个pluse脉冲上升沿被push总线上,然后在Stop信号后总线处于idle状态(SCL和SDA均为高)。执行Section 2的代码得到的波形如下Figure 3所示,ACK(0)信号在第9个pluse脉冲上升沿被push总线上,说明后面还有数据要传输,一直处于等待MMA8451数据的再次传送中,这明显违背了读取单字节数据的原本意图。总之,KL的I2C应用中Section 1的代码操作顺序是正确的,实际的物理时序和 Figure 1的示意图时序是不一样的,这点需要特别注意。 Figure 1. MMA8451's 单周期读时序示意图 Figuire 2. Section 1 代码对应的时序 Figure 3. Section 2 代码对应的时序 为方便大家验证这些问题,我这里在附件中一并上传了K60的I2C的示例代码,KL25的示例代码,以及Kinetis L关于I2C的Errata。 —————————————————————————————————————————————————————————————————————— English Version:      Recently, I migrate the K60’s I2C demo code to the KL25, but found it can't works when the same demo code runs on FRDM-KL25Z board while it runs well on the K60 board. After a painful struggling, I finally get the cause, so here I make a record, wish it could be helpful when other users happen to meet same problem. Repeat start can't be generated when configure I2Cx_F[MULT] to non-zero      The K60’s demo( the attached 1) is to communicate with the onboard accelerometer MMA8451 by I2C, and in the demo it finish a data transmission by quering I2C’s flag bit. With almost same code, it always stops at below Function 1's red line i2c_wait(I2C0_B), also this function's defination is shown as below Function 2, it stops at while((p->S & I2C_S_IICIF_MASK)==0) to wait IICIF flag. Function 1. u8 hal_dev_mma8451_read_reg(u8 addr) {     u8 result;     i2c_start(I2C0_B);     i2c_write_byte(I2C0_B, I2C_ADDR_MMA8451 | I2C_WRITE);     i2c_wait(I2C0_B);     i2c_get_ack(I2C0_B);     i2c_write_byte(I2C0_B, addr);    i2c_wait(I2C0_B);     i2c_get_ack(I2C0_B);     i2c_repeated_start(I2C0_B);     i2c_write_byte(I2C0_B, I2C_ADDR_MMA8451 | I2C_READ);     i2c_wait(I2C0_B);     i2c_get_ack(I2C0_B);     i2c_set_rx_mode(I2C0_B);     i2c_give_nack(I2C0_B);     result = i2c_read_byte(I2C0_B);     i2c_wait(I2C0_B);     i2c_stop(I2C0_B);     result = i2c_read_byte(I2C0_B);     pause();     return result; } Function 2. void i2c_wait(I2C_MemMapPtr p) {     while((p->S & I2C_S_IICIF_MASK)==0)  ; // wait flag     p->S |= I2C_S_IICIF_MASK;    // clear flag }      Then what's the matter? when I capture the I2C's wave form, found it didn't generate a Repeat start signal when excute i2c_repeated_start(I2C0_B);  After a struggle, In the Kinetis L's Errata do I find the answer: Repeat start cannot be generated if the I2Cx_F[MULT] field is set to a non-zero value. That means there is a bug in KL's design, if the I2Cx_F[MULT] field is set to a non-zero value, the I2C master can't generate a Repeat start signal. Coincidentally, in the I2C_init function I happen to set theI2Cx_F[MULT]=01, so it just meets the I2C's Errata.      Considering the MULT bits define the multiplier factor mul. and  used along with the SCL divider to generate the I2C baud rate. In the Errata, FSL gives two possible workarounds: 1) Configure I2Cx_F[MULT] to zero if a repeat start has to be generated. 2) Temporarily set I2Cx_F [MULT] to zero immediately before setting the Repeat START bit in the I2C C1 register (I2Cx_C1[RSTA]=1) and restore the I2Cx_F [MULT] field to the original value after the repeated start has occurred. To verify it easily, I revise the I2Cx_F[MULT] from 01 to 00. After that the same code runs well on FRDM-KL25Z board.    2. The Timing Sequence Of I2C's single byte Reading      In the above Function 1, there are a MMA8451 data read section like below after  Write Device Address->Write Register Address->Repeat Start->Write Device Address, and these steps is same as MMA8451's single byte read Timing Sequence requirment which is shown as below Figure 1. But referring to Figure 1, it looks like Section2 we should first excute below line2 to read the data, and then line1 give a nack  to suggest it's the last data, at last excute line4 to send a I2C stop signal. But unfortunately the idea is wrong, because in the phasical timing sequence the No acknowledge signal is sent to the bus after the following receiving data byte (if FACK is cleared) ,which means we need to give NACK signal before a read. And the captured wave form is like below Figure 2, you can find the NACK in the Ninth pluse, while the captured wave form is like below Figure 3 if excute Section 2 code instesd of Section 1 code, you can find the ACK in the Ninth pluse. it means the master will read another data, but the original intention is to read only one byte, so the I2C bus blocks. In a word, the section 1 code is right, the physical timing is different from the Figure 1's sketch map. Section 1.     i2c_set_rx_mode(I2C0_B);     i2c_give_nack(I2C0_B);----line1     result = i2c_read_byte(I2C0_B);----line2     i2c_wait(I2C0_B);----line3     i2c_stop(I2C0_B);----line4     result = i2c_read_byte(I2C0_B);----line5 Section 2.    i2c_set_rx_mode(I2C0_B);    result = i2c_read_byte(I2C0_B);-    i2c_wait(I2C0_B);    i2c_give_nack(I2C0_B);-    i2c_stop(I2C0_B); Figure 1. MMA8451's single byte read Timing sketch map Figuire 2. Section 1 code's Timing Figure 3. Section 2 code's Timing
View full article
Hello Kinetis fans, This time I bring to you a document which explains what is and how to configure scatter/gather feature which is present in the Enhanced Direct Memory Access (eDMA). This document includes an example project for the Kinetis Design Studio (KDS) which works in the FRDM-K64F board but the configuration is the same for any MCU which includes the eDMA peripheral. If you are interested in the channel linking feature, please take a look into the document What is and how to configure the eDMA channel linking feature​. I hope you find this document useful. Best regards, Earl Orlando Ramírez-Sánchez Technical Support Engineer NXP Semiconductors
View full article
The AOI and Crossbar modules are inregrated in DSC, Kinetics KV and i.mxrt families, user can use them to generate complicated trigger signal for the on-chip peripherals. The DOC discusses the AOI function, crossbar fuction based on KV58. It gives the example, the example demos how to implement AND operation of two signals via crossbar switch A and B and AOI modules. The two logic signals are connected to the pads of KV58, and routed to AOI inputs via Crossbar switch B, the AOI sub-module0 implements the AND operation of the two signals, and output the AND output signal Event0  to pad of KV58 via crossbar switch A. Connect input pads and output pad of KV58 to oscilloscope, from the waveform of the three signals on scope, we can see that the AND logic  is implemented.
View full article
  MCU Bootloader2.0.0 enables quick and easy programming of Kinetis MCUs through the entire product life cycle, including application development, final product manufacturing, and beyond. It supports many kinds of peripherals, include UART, I2C, SPI, USB, CAN and so on. Among these peripherals, UART is most common used. In reference manual, it only says that feature can be turned on or off by using #define statement in bootloader_config.h. In fact, you can use UART0 by default. But if you want to use other UART port, change TERM_PORT_NUM to other value is useless. If you traced this value, you’ll find it is not used at all, nor the TERMINAL_BAUD. Here we use FRDM-KV31F512 as the example. We want to download image by UART2. First, we should modify peripherals_pinmux.h. #define BL_ENABLE_PINMUX_UART2 (BL_CONFIG_SCUART)     //line 38   //! UART pinmux configurations #define UART2_RX_PORT_BASE PORTE #define UART2_RX_GPIO_BASE PTE #define UART2_RX_GPIO_PIN_NUM 17               // PIN 16 in the PTB group #define UART2_RX_FUNC_ALT_MODE kPORT_MuxAlt3   // ALT mode for UART0 RX #define UART2_RX_GPIO_ALT_MODE kPORT_MuxAsGpio // ALT mode for GPIO functionality #define UART2_RX_GPIO_IRQn PORTE_IRQn #define UART2_RX_GPIO_IRQHandler PORTE_IRQHandler #define UART2_TX_PORT_BASE PORTE #define UART2_TX_GPIO_PIN_NUM 16             // PIN 17 in the PTB group #define UART2_TX_FUNC_ALT_MODE kPORT_MuxAlt3 // ALT mode for UART0 TX   The original define is UART0, here we change it to UART2. It is strongly recommended to do so. Otherwise you’ll find that UART can’t work at all. Another comment here is PTE16 and PTE17 is conflict with SPI. You must disable SPI or change SPI function to other pins.   Next we must modify peripherals_KV31F512.h. const peripheral_descriptor_t g_peripherals[] = { #if BL_CONFIG_SCUART    // UART0    {.typeMask = kPeripheralType_UART,      .instance = 2, // change this value from 0 to 2      .pinmuxConfig = uart_pinmux_config,      .controlInterface = &g_scuartControlInterface,      .byteInterface = &g_scuartByteInterface,      .packetInterface = &g_framingPacketInterface },   Although there is a baud rate definition TERMINAL_BAUD, but it is never used too. MCU bootloader2.0.0 use auto baud rate detection. When power on, bootloader will go to autobaud detection mode. KinetisFlashTool sends ‘0x ’ every second. Bootloader check this byte and calculate baud rate.   After getting this value, bootloader will change to normal communication mode. Baud rate will not change until reset. If blhost is used, subsequent blhost invocations must specify the same baud rate as was used for the initial invocation unless the bootloader is reset. If the baud rate is not specified using the -p COMx, <baudrate> option, the UART baud rate will be set to 57600. Since Kinetis MCU UART module don’t have auto frequency detect function, the bootloader detects frequcny by software. It uses GPIO interrupt and timer to measure frequency. But in bootloader, there is only code for UART0, there isn’t code for other UART port. We must add the code. In hardware_init_KV31F512.c, modify the function get_uart_clock()   uint32_t get_uart_clock(uint32_t instance) {    switch (instance)    {        case 0:        case 1:            // UART0 and UART1 always use the system clock            return SystemCoreClock;        case 2:            return get_bus_clock();        default:            return 0;    } }   KV31 has 4 UART, include three UART modules and one low-power UART. They have different clock source. UART0 and UART1 use System clock while UART2 and LPUART0 use Bus clock. Thus, we finished the work. UART2 can work as the download port now.
View full article
       FreeRTOS is a high quality, risk free, supported, free RTOS, and now it is already successful to porting more 35 architectures. As a popular RTOS, more and more embedded engineers considering it for their next project.        Next, I’m going to show you the steps of creating a MAPS-K22 FreeRTOS demo by IAR and I’ve also attached a template demo and FreeRTOS source code (Fig 1). Fig 1 FreeRTOS source code directories and files     1. Copy the FreeRTOS source code to ~\MAPSK22_SC\Libraries     2. Create FreeRTOS_Source group in the workspace, then add the source code (Fig 2) Fig 2 3. Add an application code in the main.c This is a very simple configuration. It creates two tasks, one software timer, and also uses a button interrupt. The two tasks communicate via a queue. The receiving task toggles the LED3 each time a value is received. Pressing user button K5 generates an interrupt. The interrupt service routine for which resets a software timer, then turn the LED1 on. The software timer has a five second period. The timer will expire when K5 has not been pressed again for a full five seconds. The callback function that executes when the timer expires simply turn the LED1 on again. Therefore, pressing K5 will turn the LED1 on, and the LED1 will remain on until a full five seconds pass without the button being pressed again. 4. Modify the Include Directories 5. Run the FreeRTOS demo After build the modified application code, then run it on MAPS-K22 board (Fig 3) Fig 3 IMPORTANT! Cortex-M FreeRTOS port specific configuration Configuration items specific to this demo are contained in ~\MAPSK22_SC\Libraries\RTOS\config\K22F51212\iar. The constants defined in this file can be edited to suit your application. In particular configTICK_RATE_HZ This sets the frequency of the RTOS tick interrupt. The supplied value of 1000Hz is useful for testing the RTOS kernel functionality but is faster than most applications require. Lowering this value will improve efficiency. configKERNEL_INTERRUPT_PRIORITY and configMAX_SYSCALL_INTERRUPT_PRIORITY See the RTOS kernel configuration documentation for full information on these configuration constants. configLIBRARY_LOWEST_INTERRUPT_PRIORITY and configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY These are equivalents to configKERNEL_INTERRUPT_PRIORITY and configMAX_SYSCALL_INTERRUPT_PRIORITY, but presented in a form suitable for passing into the Freescale NVIC_SetPriority() library function. The NVIC_SetPriority() function expects priorities to be in the range of 0 to 15 - 0 being the highest priority and 15 being the lowest priority.
View full article
The attached zip file contains software that accompanies the document UART Emulation Using the FTM or TPM.  It contains two sample applications:  one that uses the TPM, and one that uses the FTM. The TPM example targets the FRDM-KL26Z development board and is written in baremetal code.  The FTM example targets the TWR-K22F120M and FRDM-K22F and is written using the Kinetis SDK 1.0 release.  Installation instructions are contained within the zip package. Unzip the package to an empty folder and then copy the appropriate folders to the the appropriate locations on your PC per the instructions located in the zip file. 
View full article
The SysTick is a part of the Cortex-M0+ core and so is not chip specific - for details of the Cortex core you generally need to use ARM documents. For SysTick: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0179b/ar01s02s08.html By summary, the SysTick is configured through four registers: 1. SysTick Control and Status(CSR): basic control of SysTick e.g. enable, clock source, interrupt or poll COUNTFLAG: count-down flag, if down to 0, then this bit will be set to 1, otherwise, it will be 0. CLKSOURCE:  when using internal core clock, it will be 1. If using external clock, it will be 0. TICKINT: interrupt enabled when setting to 1. ENABLE: counter enabled when setting to 1. 2. SysTick Reload Value(RVR): value to load Current Value register when 0 is reached. 3. SysTick Current Value (CVR): the current value of the count down. 4.SysTick Calibration Value(CALIB): contain the number of ticks to generate a 10ms interval and other information, depending on the implementation. TENMS: tick value for 10 ms. To configure the SysTick you need to load the SysTick Reload Value register with the interval required between SysTick events. The timer interrupt or COUNTFLAG bit is activated on the transition from 1 to 0, therefore it activates every n+1 clock ticks. If a period of 100 is required 99 should be written to the SysTick Reload Value register. See attached code on how to generate microsecond delay.
View full article
在KE系列MCU中提供了多种寄存器用于实现GPIO的控制:    -PDOR寄存器,用于写入或读取IO的输出状态    -PSOR寄存器,用于置位IO口    -PCOR寄存器,用于清零IO口    -PTOR寄存器,用于翻转IO口    -PDIR寄存器,用于读取IO口的输入状态 当我们想要将PTA0置1时,有多种方法可以选择:    1. 直接操作寄存器,PDOR或PSOR都可以实现:          GPIOA->PDOR |= 0x0001;          GPIOA->PSOR |= 0x0001;          直接操作寄存器的效率更高,但可读性较差。    2. 使用官方的库函数操作       GPIO_PinSet(GPIOA, GPIO_PTA0);       库函数的可读性很好,但显得有些啰嗦,字符较多。 通过KE的BME来实现GPIO的操作能够很好的解决上面的问题,只用将附件中的头文件gpio_bitdef.h包含到工程里,再调用里边的宏定义就可以了。 对PTA0置位和清零可以使用下面的语句: POUTA0 = -1; POUTA0 = 0; 读取PTA0的输入状态则可以使用: tmp = PINA0; 上面的语句是不是看上去简洁了很多呢。 实际上上面GPIO的读写指令,是通过BME的BFI(位域插入)和BFX(位域提取)指令来实现的。 -其中ADDR是存储空间内的地址,我们最终操作的还是GPIO的寄存器,因此在两个指令中分别取GPIOA的PDOR寄存器地址和PDIR寄存器地址。 -bit则表示需要插入或提取位域的起始位置,由于这里是PTA0,PTA0位于寄存器的最低位,因此这里填入了0。 -width则表示需要插入或提取位域的宽度,我们只对单个管脚进行操作,也就是单个位进行操作,宽度自然就是1了。 需要注意的是,BFI(位域插入)指令在插入时,是将对应位插入到目的地址。因此,如果直接为POUTxx赋值为1的话,有可能出现错误。 POUTA0 = 0x01;//正确 POUTA1 = 0x02;//正确 POUTA2 = 0x04;//正确 POUTA1 = 0x01;//错误 为了避免这种情况,我们可以在IO口需要置位时,直接将POUTxx赋值为-1,即0xFFFF FFFF,这样保证了每一位的值都为1。 #define BME_BFI(ADDR,bit,width)        (*(volatile uint32_t *)((((uint32_t)ADDR&0xFFFF))   \                                   | (5 <<28)  \                                   | ((bit)<<23) | ((width-1))<<19)) #define BME_BFX(ADDR,bit,width)        (*(volatile uint32_t *)(((uint32_t)ADDR&0xFFFF)    \                                   | (5 <<28)  \                                   | ((bit)<<23) | ((width-1))<<19))  #define POUTA0 BME_BFI(&GPIOA->PDOR,0,1) #define PINA0 BME_BFX(&GPIOA->PDIR,0,1) ‍‍‍‍‍‍‍‍‍‍
View full article
http://dorkbotpdx.org/blog/paul/teensy_audio_library_gets_spdif_support Digital optical audio output from kinetis based teensy 3.1
View full article
FINALISTAS Después de un profundo análisis de todos los proyectos, nuestros jueces realizaron la difícil selección de los finalistas del Kinetis L MCU Challenge México entre los que el público elegirá al ganador; gracias a la excelente respuesta decidimos nombrar 16 finalistas.  Ellos son: Project Name Contestan Name Description Video Sistema de monitoreo de la contaminación acústica #MonitoreoAcustico Lucio Canche Diseño de una placa para monitoreo de niveles de ruido utilizando un sensor de sonido. Permite el estudio detallado de los patrones de propagación del sonido. Movimiento de un carro controlado #CarroPelotasAntiestres Emilio Jiménez Auto de juguete controlado por medio de pulsaciones realizadas con 2 pelotas anti-estrés, el presionar una pelota hará que el vehículo avance hacia adelante y la otra hará que gire sobre su propio eje. Viking lever #VikingLever Ma. Fernanda Gutierrez Consiste en un sistema de una palanca con contrapeso; tendrá en la punta una pelota con una led que indicará cuando el usuario tiene que golpearla. Controlador para el suministro de agua de una vivienda #ControladorAgua Rogelio Rosales El objetivo es el ahorro de agua. En un tinaco se colocan 2 sensores, uno a nivel alto y el otro a nivel bajo de agua. Dependiendo del nivel del agua los sensores mandan la señal a la bomba para que se encienda o apague. Rehab glove #RehabGlove Alexis Castañón Guante que posee sensores de flexión en las articulaciones de los dedos y de fuerza en las yemas, con el fin de enviar instrucciones a algún aparato, mientras el usuario realiza ejercicios como cerrar el puño o tocar las yemas de los dedos con el pulgar. Tablet braile para invidentes #TabletBraille Andres Gafford Tableta para leer ebooks braile con botones para cambiar de página, apagar y encender, que sean fáciles de percatar por un invidente; así como botones interactivos que desplieguen opciones del menú. Tapete interactivo para discapacitados #TapeteInteractivo Angel Campoy Este tapete interactivo, contribuye al desarrollo motriz. El teclado cuenta con cuatro botones, los cuales tienen un led que se enciende indicando al paciente que debe presionar el boton. Si activo el boton indicado,se enciende un LED verde o rojo si se equivocó. Neck remote control wheel chair #NeckControl Francisco Javier Pérez Corona Silla de ruedas controlada moviendo el cuello a la izquierda o derecha, presionando un botón con la cabeza, que a su vez haga avanzar o girar. Control de sensores infrarrojos para silla de ruedas #SensoresSilla Jesús Lizárraga Silla de ruedas diseñado para personas con parálisis cerebral. El usuario debe colocar las dos manos al ifgual que los codos por encima de los espacios indicados, los sensores se activarán haciendo que la silla avance o gire hacia el lado en que la persona posicionó la mano. N-drid uleta #NdridRuleta Jorge Rodriguez Rodriguez Juego de ruleta de leds de 4 colores, el usuario acumulará puntos cada vez que logre presionar el botón del color en donde parará la ruleta. KMA #KMA Luis Castellanos Prototipo para silla de ruedas que será controlada con un dispositivo de fácil manejo,  comunicado a la silla por bluethooth. Sensilla #Sensilla Miguel Rogel Silla móvil manipulada por sensores y con esto lograr desplazarse de una manera más accesible a sus capacidades. Pest control using Freescale #PestControl Pablo Yerena Este proyecto consiste en el control de plagas de manera ecológica, con la implementación de un aparato electrónico que emite frecuencias ultrasónicas evitando que animales e insectos invadan espacios físicos. Tren de colores musical #TrenColores Ricardo Villaseñor Juguete donde se utiliza un sensor óptico para la lectura de pequeños cubos de colores, donde cada color es una nota musical. Al colocar el lector sobre el cubo de color se emitirá la nota correspondiente. Morse deaf-mute communication system #MorseDeafMute Roberto Vite Ruiz Dispositivo de escritura basado en el código morse. Se muestra un código morse para cada letra del alfabeto permitiendo a una persona sorda o muda darse a entender de manera escrita.       Casco acelerómetro #CascoAcelerometro José Ramón Rodriguez Dispositivo  para silla de ruedas que  permite al paciente transportarse autónomamente mediante una especie de casco que detecte la dirección deseada, además de que sea una manera recreativa de trasladarse Podrás participar calificando cada proyecto a través de redes sociales y la herramienta RankTab; la votación se abrirá el día del evento a partir de las 9:00am, espera las instrucciones a través de la Comunidad Freescale,  Facebook y durante el evento. A todos los finalistas los esperamos el 07 de Diciembre a las 8:00hrs en el Centro de Congresos del Tecnológico de Monterrey Campus Guadalajara, donde se develará el misterio y conoceremos al ganador del viaje al Freescale Technology Forum (FTF) en Dallas, Texas del 08 al 11 de Abril del 2014. Para solicitar mayor información, favor de enviar un correo a cristina.garcia@mclgx.comA
View full article
Hi Team :      We are working on KSDK project recently . I would like to share an experience to migrate a project to a new device that is not listed in KSDK . I hope that helpful . Best regards, David
View full article
I have included the files needed to mass erase the flash of the MCU and re-program another binary.   The procedure is shown in the folder " FRDM-KW31_FAT_added_2019" Summarizing you... 1) update the debugger with bootloader mode (press reset and plug in usb cable) drag and drop .sda file on MSD bootloader. 2) unplug and re-plug USB. program the flashloader_loader_mkv31f512.bin by dragging and dropping the binary on to the virtual mass storage device FRDM-KV31 which appear when you plug the USB cable from the FRDM-KV31 to the PC.  3) Open a CMD prompt window and navigate to the folder the files were unzipped to. 4) Determine the COM port by using the device manager 5) from the CMD prompt run the batch file      Erase_KMS_program_bubble.bat COMX
View full article
1. Freedom开发板: 飞思卡尔Freedom开发平台是一套低成本的用于性能评估和软件开发的工具,自带板载调试器,用户可以直接通过自己的PC机快速搭建开发环境并进行测试和评估芯片简单的外设资源。一般来说,同一个系列功能互相兼容的芯片会推出一款Freedom开发板来评估,具体分类如下: Freedom开发板 可以覆盖的芯片型号 开发板代码包 FRDM-KL02Z Kinetis KL02 MCUs KL02_SC FRDM-KL03Z Kinetis KL03 MCUs Kinetis SDK for KL03 FRDM-KL05Z Kinetis KL04 and Kinetis KL05 MCUs KL05_SC FRDM-KL25Z Kinetis KL14, Kinetis KL15, Kinetis KL24 and Kinetis KL25 MCUs KL25_SC FRDM-KL26Z Kinetis KL16 and Kinetis KL26 MCUs KL26_SC FRDM-KL43Z Kinetis KL17, Kinetis KL27, Kinetis KL33 and Kinetis KL43 MCUs FRDM-KL43_SC FRDM-KL46Z Kinetis KL36 and Kinetis KL46 MCUs KL46_SC FRDM-KE02Z Kinetis KE02_20M MCUs KEXX_DRIVERS_V1.2.1_DEVD FRDM-KE02Z40M Kinetis KE02_40M MCUs KEXX_DRIVERS_V1.2.1_DEVD FRDM-KE04Z Kinetis KE04 MCUs KEXX_DRIVERS_V1.2.1_DEVD FRDM-KE06Z Kinetis KE06 MCUs KEXX_DRIVERS_V1.2.1_DEVD 2. TWR开发板: 飞思卡尔塔式系统开发板为可扩展性比较强的评估板,板载资源比较丰富且通过构建塔式系统可以灵活的添加和裁剪外设资源,用户可以通过与相应外设塔式板结合使用进行更高级和复杂的功能测试或验证。 Tower开发板 可以覆盖的芯片型号 Header 3 TWR-KL25Z48M Kinetis KL14, Kinetis KL15, Kinetis KL24 and Kinetis KL25 MCUs KL25_SC TWR-KL43Z48M Kinetis KL17, Kinetis KL27, Kinetis KL33 and Kinetis KL43 MCUs TWR-KL43Z48_SC TWR-KL46Z48M Kinetis KL16, Kinetis KL26, Kinetis KL36 and Kinetis KL46 MCUs KL46_SC TWR-KM34Z50M Kinetis KM3x MCUs KMSWDRV TWR-KV10Z32 Kinetis KV1x TWR-KV10Z32_SC 3. 第三方开发板 (1) MAPS四色板套件 (2) YL-KL26Z 开发板
View full article
Hi,   Attached USB Mass Storage Device Host Bootloader code is ported for KL25 / KL26.   Reference: AN4368 USB Mass Storage Device Host Bootloader   Thanks & Regards, Swaminathan.R
View full article
Customer requirement and making it happen This hands-on test is coming with the true customer requirement. Customer designs the battery powered device with SLCD display and lowest power consumption is the key requirement. Customer considers the KL43 and wonder the power consumption data about RTC & SLCD modules. So there with below requirements about the test: Run the RTC and SLCD in the lowest possible power mode Display time at SLCD with [00:00] and update every minute via RTC interrupt               One button shall turn on/off the SLCD display Measure the KL43 power consumption data KDS IDE with KSDK V2.0 software According to above requirement, which low power mode should be selected? RTC and SLCD modules should work at this low power mode. From the KL43 reference manual table 7-2 [Module operation in low power modes] with below info:      5. In VLLS0 the only clocking option is from RTC_CLKIN.      7. End of Frame wakeup not supported in LLS and VLLSx. RTC and SLCD modules could work at VLLS1 low power mode with Async operation. Using VLLS1 low power mode, the RTC and SLCD module clock could select OSC32KCLK with below clocking figure: KL43 wake up from VLLS1 low power mode following wake up reset and the software will check the system reset status register to check what kind of reset happens and print related info. LLWU module is used as VLLS1 lower power mode wake up module with two wake up source, one is RTC Alarm interrupt, the other one is PTC3 (SW3). The Reset pin (SW2) also could wake up the VLLS1 low power mode. Test environment introduction Hardware platform using FRDM-KL43Z board with below feature: MKL43Z256VLLZ4 MCU (48 MHz, 256 KB flash memory, 32 KB RAM, 16 KB ROM Dual role USB interface with mini-B USB connector OpenSDA Four-digit segment LCD module Capacitive touch slider Ambient light sensor MMA8451Q accelerometer MAG3110 magnetometer 2 user push buttons Battery-ready, power-measurement access points Arduino R3 compatibility Software platform bases on KSDK V2.0 for FRDM-KL43Z board, which could be downloaded from kex.nxp.com. Attached demo software default path is: C:\Freescale\SDK_2.0_FRDM-KL43Z\boards\frdmkl43z Test software code introduction Below is the software flow chart: Test result SLCD ON with power consumption 2.0uA SLCD OFF with power consumption 1.2uA
View full article