文档结构  
可译网翻译有奖活动正在进行中,查看详情 现在前往 注册?
原作者:未知    来源:mcuoneclipse.com [英文]
城府很深    计算机    2016-09-11    0评/199阅
翻译进度:64%   参与翻译: 安得鲁 (7)

为了完成一个大学研究项目,我需要一款带有大容量RAM和Flash的高速微控制器。我向NXP订购了一款 TWR-KV58F220M 开发板,昨天刚刚收到。它的特别之处是搭载了这几款新的 ARM Cortex-M7F 处理器:

TWR-KV58F220M Box

TWR-KV58F220M 盒装

The Tower board box 包含了USB连接线和快速使用指南,所以可以开箱即用。开发板上搭载的KV58F1M0VLQ22 具有这些相当令人印象深刻的特性:

PKV58F1M0VLQ22

PKV58F1M0VLQ22

  • ARM Cortex-M7F 最高运行频率 240 MHz
  • 单精度硬件浮点单元 (FPU)
  • 1 MByte FLASH
  • 128 KByte of SRAM (也有 256 kByte的版本)
第 1 段(可获 1.34 积分)

💡芯片上的标注是KV58f1M0VLQ22, 表示最高运行频率为 220MHz. 文档和软件中用的是24的版本 (意思是 240 MHz), 而tower board上标注的是 KV58F220M. 所以我猜是不是存在220 MHz 和240 MHz的两个版本 ?

这款微控制器看起来非常适用于电机控制应用, 但是其性能和特性让它在其他高性能应用中也存在很高的吸引力。和另一款 NXP廉价开发板 FRDM boards比起来Tower board的售价非常高:US$ 159.00.

板载4个用户可用按键,4颗单色LED, 一个电位器<potentiometer>和一个磁场/加速计<magnetometer/accelerometer>。 也搭载了板载调试器(OpenSDA V2.1)。

第 2 段(可获 1.41 积分)

调试

板载 OpenSDA调试电路(V2.1) , 类似于FRDM-K22F, 所以我可以在上面使用P&E或 Segger 调试固件(我不用 OpenSDA). 所以无需使用外置的调试器。

当然只要我愿意,我也可以使用外置的调试器,比如Segger J-Link 或者 P&E Multilink.

P&E 支持M7处理器,在KDS V3.2.0版本中

P&E and Cortex-M7

P&E and Cortex-M7

如果我想用外置的 P&E Multilink or Segger J-Link来调试这块板子,必须 *移除* J19 and J20这两处跳线:

Jumpers J19 and J20 on TWR-KV58F220M

在TWR-KV58F220M开发板上的跳线,J19 and J20

在移除跳线之后, P&E Multilink Universal工作得很正常:

第 3 段(可获 1.49 积分)

Debugging TWR-KV58F220M with P&E Multilink Universal

使用P&E Multilink Universal来调试TWR-KV58F220M

同样地,用Segger J-Link来调试也一切顺利:

Debugging M7 with Segger J-Link

用 Segger J-Link来调试M7

除了用板载OpenSDA调试器外,通过移除跳线,  我也可以用外置调试器来调试这块板子。

运行在M7上的FreeRTOS

目标应用需要运行在FreeRTOS上, 所以第一步是在板子上运行FreeRTOS来闪烁一个指示灯<running a blinky >。因为这是我第一次用 ARM Cortex-M7F CPU来做这项任务,我觉得免不了要做一些调节和改动, 不过这些很简单。

McuOnEclipse Processor Expert component里有一个选项来支持Cortex-M7/M7F:

第 4 段(可获 1.3 积分)

ARM Cortex M7 Selection in FreeRTOS

ARM Cortex M7 Selection in FreeRTOS

通过这项设置,FreeRTOS 就被配置成支持在ARM Cortex-M7 or M7F上运行。我必须调节 RTOS移植版的一些选项,不过大部分都可以复用M4的代码来移植到M7(F) ,所以这项工作非常简单。

在 FreeRTOSConfig.h 的一行中,设置了内核类型:

#define configCPU_FAMILY  configCPU_FAMILY_ARM_M7F

Kinetis Design Studio和 Kinetis SDK

我使用 NXP Kinetis Design Studio V3.2.0来开发这块板子。因为KV58 是一个新器件, 对KV58的支持需要手动添加到IDE中。 通常的方式是编译针对它的SDK,参考http://kex.nxp.com/ (参照“First NXP Kinetis SDK Release: SDK V2.0 with Online On-Demand Package Builder“):

第 5 段(可获 1.64 积分)

Kinetis SDK for TWR-KV58F220M

Kinetis SDK for TWR-KV58F220M

如上图所示, 只有 SDK 1.3版本是受到支持的(截至今天还不支持SDK 2.0 )不太走运,不过这让我找到了 Processor Expert 对它的支持。<but the same time I get Processor Expert support for it.>

因为有一个针对SDK V1.3可用的版本,在https://kex.nxp.com.

SDK V1.3 for KV58

SDK V1.3 for KV58

我安装了这个包,然后将 Eclipse升级添加到 KDS中 (menu Help > Install New Software, 然后定位到升级内容安装的目录 (我把它安装在 C:\nxp\KSDK\SDK_1.3_MKV58F1M0xxx24\tools\eclipse_update)),之后我就能在Eclipse中创建针对它的项目:

KV58F in Eclipse Wizard

在 Eclipse 向导中的KV58F 

第 6 段(可获 1.45 积分)

💡 注意在文档中的几处240 MHz 的字样。TWR-KV58F220M 上最高可配置的频率是 220 MHz (这就是型号里的220的含义)。 不知道有办法运行在240 MHz吗?

新创建的空项目在我添加cmsis_gcc.h到SDK目录结构中后工作一切正常,

cmsis_gcc.h

cmsis_gcc.h

FreeRTOS和Kinetis SDK v1.3

我没有使用包含在SDK V1.3中的 FreeRTOS,因为版本有点老 (V8.2.0 而不是最新的V9.0.0, 参考 “FreeRTOS V9.0.0 with Static Memory Allocation“) 而且 SDK V1.3中的V8.2.0 是配置给M4的,而不是给M7的。

第 7 段(可获 1.59 积分)

Instead, I used the approach discussed in “Tutorial: Using Processor Expert and FreeRTOS with Kinetis SDK V1.2” and used the McuOnEclipse FreeRTOS:

FreeRTOS with Kinetis SDK V1.3

FreeRTOS with Kinetis SDK V1.3

The default fsl_os_abstraction is set to BareMetal with disabled timer:

fsl_os_abtracation

fsl_os_abtracation

FreeRTOS is configured to use the Kinetis SDK:

FreeRTOS with Kinetis SDK

FreeRTOS with Kinetis SDK

The Kinetis SDK component is configured to use the V1.3:

SDK V1.3

SDK V1.3

LEDs

As a side effort, I have now enabled the SDK_BitIO component to work with the SDK V1.3 too :-):

LED component

LED component

For the SDK V1.2 it is necessary to give the pin a name, while this is not needed for the SDK V2.0:

第 8 段(可获 1.54 积分)

Pin Symbol Name

Pin Symbol Name

Blinky Tasks

That makes a simple demo with to blinky tasks really simple:

static void blinky_task2(void *param) {
  (void)param;
  for(;;) {
    GPIO_DRV_TogglePinOutput(LED_RED);
    vTaskDelay(100/portTICK_RATE_MS);
    GPIO_DRV_TogglePinOutput(LED_RED);

    GPIO_DRV_TogglePinOutput(LED_GREEN);
    vTaskDelay(100/portTICK_RATE_MS);
    GPIO_DRV_TogglePinOutput(LED_GREEN);
  } /* for */
}

static void blinky_task1(void *param) {
  (void)param;
  for(;;) {
    GPIO_DRV_TogglePinOutput(LED_ORANGE);
    vTaskDelay(50/portTICK_RATE_MS);
    GPIO_DRV_TogglePinOutput(LED_ORANGE);

    GPIO_DRV_TogglePinOutput(LED_BLUE);
    vTaskDelay(50/portTICK_RATE_MS);
    GPIO_DRV_TogglePinOutput(LED_BLUE);
  } /* for */
}

/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */
  if (xTaskCreate(
      blinky_task1,  /* task function */
      "Blinky1", /* task name for kernel awareness */
      configMINIMAL_STACK_SIZE, /* task stack size */
      (void*)NULL, /* optional task startup argument */
      tskIDLE_PRIORITY,  /* initial priority */
      NULL /* task handle */
    ) != pdPASS) {
    for(;;){} /* error! probably out of memory */
  }
  if (xTaskCreate(
      blinky_task2,  /* task function */
      "Blinky2", /* task name for kernel awareness */
      configMINIMAL_STACK_SIZE, /* task stack size */
      (void*)NULL, /* optional task startup argument */
      tskIDLE_PRIORITY,  /* initial priority */
      NULL /* task handle */
    ) != pdPASS) {
    for(;;){} /* error! probably out of memory */
  }
  /* For example: for(;;) { } */

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
第 9 段(可获 0.2 积分)

And here is the blinky running on the board:

Blinky on TWR-KV58F220M

Blinky on TWR-KV58F220M

FreeRTOS Kernel Awareness

FreeRTOS thread awareness with the Segger firmware (see “Adding FreeRTOS Thread Awareness to GDB and Eclipse“) is working too:

Segger FreeRTOS Thread Awareness

Segger FreeRTOS Thread Awareness

Segger SystemView

I got Segger SystemView working with RTT. The only thing was that the V2.38 was not able to detect the RTT block automatically, so I specified the address of the _SEGGER_RTT symbol in the application manually in the connection settings:

SysView RTT Control Block Detection

SysView RTT Control Block Detection

With this, the SystemView is working like a charm :-):

第 10 段(可获 1.24 积分)

Segger SystemView on Cortex-M7

Segger SystemView on Cortex-M7

Summary

It was easy to get FreeRTOS running on that new NXP ARM Cortex-M7F. It is a powerful CPU, I only wish there would be an affordable FRDM board for it. For an evaluation the board provides all the things I need, plus direct access to the CPU pins on the board. Further benchmarks will show if that microcontroller can be used in that project, we will see. But it is a good start to have the software up and running within hours including FreeRTOS.

I have put the project discussed on GitHub.

The updated Processor Expert components to support Cortex-M7 will be available in the next release, probably in a next post.

Happy Cortexing🙂

第 11 段(可获 1.49 积分)

文章评论