ElectronicDesign 9329 0814Labbench促销

Running Ada 2012 On The Cortex-M4

2014年7月8日
AdaCore的最新开源ADA 2012系统是基于ARM的Cortex-M4 MicroController,该系统在Stmicroelectronics的STM32 F4 Discovery板上运行。

>> Website Resources
。。>> Library: TechXchange
。。。。>> TechXchange: Embedded Software
.. .. .. .. .. >>主题:Ada和Spark

我喜欢认为我编写了好的代码,并且自从他们成立以来,我已经使用了C ++。我承认将多个不需要的错误纳入C应用程序中,这些c应用程序有时是乏味的诊断会议后被淘汰的。几乎所有新的微控制器都发布了与之相关的免费C/C ++编译器工具链。

Unfortunately, C is very unforgiving, and C++ is only a little better. But they are the mainstay for embedded programmers these days. That’s one reason why I have been waiting forAdaCore’sdelivery of its Ada 2012 toolchain for Arm’s Cortex-M platform. It is a free download atlibre.adacore.com

Cortex-M是几乎所有采用ARM架构的主要微控制器供应商使用的主要低端,32位微控制器。供应商喜欢Green Hills软件,Atego, 和Adacorehave supported the Cortex platform in the past but with earlier Ada standards. Ada 2012 includes a range of new features including contracts(看 ”ADA 2012:合同的喜悦” on electronicdesign.com)

Download this article in .PDF format
此文件类型在适用时包括高分辨率图形和原理图。

卷起我的袖子

I had already tried out a version of AdaCore’s GNAT Programming Studio (GPS). It generated applications that would run on Linux on the BeagleBone based on the Texas Instruments Cortex-A8 platform(看 ”武装ADA” on electronicdesign.com)。新的工具链靶向裸金属,这是许多应用所需的。

Figure 1. AdaCore's latest Ada 2012 tool suite works with platforms like STMicroelectronics STM32F4 Discovery board that has a Cortex-M4 core.

由于已经安装了GPS,因此设置很容易。将STM32板的ST-Link调试接口设置(see the figure)actually took more time. It was then a matter of running through the flashing LED demo. I included a snippet of code from a flashing LED program to highlight some of the advantages of using Ada 2012(see the listing)

with LEDs; use LEDs; with Button; use Button; with Ada.Real_Time; use Ada.Real_Time; package body Driver is type Index is mod 4; Pattern : constant array (Index) of User_LED := (Orange, Red, Blue, Green); task body Controller is Period : constant Time_Span := Milliseconds (75); -- arbitrary Next_Start : Time := Clock; Next_LED : Index := 0; begin loop Off (Pattern (Next_LED)); Next_LED := Next_LED + (if Button.Current_Direction = Counterclockwise then -1 else 1); On (Pattern (Next_LED)); Next_Start := Next_Start + Period; delay until Next_Start; end loop; end Controller; end Driver;

即使您没有使用ADA,也应该能够了解正在发生的事情。特别是,任务主体定义突出了内置的多任务支持。另请注意,使用“模块化”(无符号)数据类型用于限制图案数组的地址的索引。与C不同,无需检查Next_led的结果。此外,如果/随后/其他条件表达ADA而不是C/C ++?:组合,我更喜欢更详细的内容。我已经在APL中进行了编程,其单线很整洁,但通常是难以理解的。C和C ++代码也可以得到这种方式。

Ada has a number of benefits compared to C and C++(看 ”Ada Offers Advantages Over C And C++” on electronicdesign.com).但是它也有缺点,例如可用性。对于Arm Cortex微控制器,这不再是问题。开发人员可以利用从仿制药到多任务处理的所有ADA 2012功能。

I would encourage anyone wanting to write bulletproof code for embedded applications to check out the AdaCore/STM32 combination. It is inexpensive and very functional. The ST-Link support also allows it to work with platforms like the STM32F401 Nucleo(看 ”Extensible Prototyping Board Built For STM32 MCUs” on electronicdesign.com)。I tried it on my Nucleo as well.

爆发的虫子(看 ”What Heartbleed Should Teach Embedded Programmers” on electronicdesign.com)is just one of many reminders of how one range check error can wreak havoc. C does not do it, but Ada does check—and not just on array access, by default. Ada will not eliminate all bugs from your code, but it does make it a lot harder to create them.

>> Website Resources
。。>> Library: TechXchange
。。。。>> TechXchange: Embedded Software
.. .. .. .. .. >>主题:Ada和Spark

From Our Partners

Common LED Functions and LED Driver Design Considerations

Common LED Functions and LED Driver Design Considerations. Kenneth Du Product Marketing Engineer Power Switches, Interface & Lighting Texas Instrument…

Driving the Green Revolution in Transportation

Karl-Heinz Steinmetz Sector General Manager Automotive Powertrain Texas Instruments. Technology advancements further electrify cars, enable new effici…

How to De-embed Interconnect Elements in Both Frequency and Time Domains

ON-DEMAND WEBINAR. Join Teledyne LeCroy as we describe and demonstrate best practices for de-embedding test fixtures, cables, and probes from serial d…

您的技术商是什么?

Take a bite size look on the tech landscape of AI - where we have been, where we are, and where we are going. Then explore more with our partner Micr…

USB Type-C® & USB Power Delivery

我们为USB PD功能提供的广泛产品USB Type-C®设备和PD控制器提供了设计和IMPS所需的灵活性和集成。

Enclosure Materials Available for Rough Environments

问题解决方案外壳材料可用于粗糙环境。金属外壳通常不是高度艰难环境的正确产品…

表达您的意见!

This site requires you to register or login to post a comment.
尚未添加评论。想开始对话吗?

From Our Partners

Common LED Functions and LED Driver Design Considerations

Common LED Functions and LED Driver Design Considerations. Kenneth Du Product Marketing Engineer Power Switches, Interface & Lighting Texas Instrument…

Driving the Green Revolution in Transportation

Karl-Heinz Steinmetz Sector General Manager Automotive Powertrain Texas Instruments. Technology advancements further electrify cars, enable new effici…

How to De-embed Interconnect Elements in Both Frequency and Time Domains

ON-DEMAND WEBINAR. Join Teledyne LeCroy as we describe and demonstrate best practices for de-embedding test fixtures, cables, and probes from serial d…

您的技术商是什么?

Take a bite size look on the tech landscape of AI - where we have been, where we are, and where we are going. Then explore more with our partner Micr…

USB Type-C® & USB Power Delivery

我们为USB PD功能提供的广泛产品USB Type-C®设备和PD控制器提供了设计和IMPS所需的灵活性和集成。
能源管理

Solar Storms and Their Potential to Create Electronic Chaos

2021年12月17日
Solar events have destroyed grids, set wires on fire, downed satellites. Are we ready for the next big one?
alt.embedded

电子设计和调度的复杂性

2021年12月17日
Editor Bill Wong comments on the challenges faced by electronic developers these days.
Baidu