
A fragmented ecosystem
Embedded developers have an ongoing struggle to keep the pace by upgrading compilers and debugging tools, while ensuring the processing hardware going into their systems are right-sized for the application. Conventional embedded development tends to force engineers to stick with an established, often vendor-specific, ecosystem where shifting to a different IDE comes with its own costly learning curves. MCU companies and other manufacturers with a foothold in embedded processing are beginning to release solutions that embrace third-party development environments to appeal to the larger market while also maintaining their place with established customers.
Microchip’s moves to ease hardware-software codesign
Microchip’s recent release of their AI coding assistant and unified compiler is this company’s signal that they are set to follow this theme of lowering development barriers. The AI coding assistant enables their established MPLAB platform to function within the eminently popular Visual Studio (VS) framework while the unified compiler license combines the MPLAB C compilers: XC8, XC16, XC-DSC, and XC32.
In a conversation with Rodger Richey, the VP of development systems and academic programs, EDN was able to see how a developer would use the AI coding assistant within the VS IDE.
AI coding assistant in VS
There are essentially three main pieces to this tool:
- A microchip chatbot for product questions such as coding-specific questions
- An autocomplete function that predicts with inline code suggestions
- Direct access to technical data in vectorized datasheets allowing users to search for information such as block diagrams without leaving the coding environment
“We have actually been using this internally within Microchip for the last nine months and, depending upon the user, we’ve seen anywhere between a 20 to 40% productivity enhancement,” said Richey, offering a live demo of the VS tool.
Creating project and searching datasheet
As shown in Figure 1, he began by asking the assistant about the features of the new PIC32CM JH family of MCUs where the assistant replied with details such as core, memory, and peripheral features as well as part numbers. At this point, the tool downloads the vectorized datasheet so that it is searchable within the AI coding assistant, “I’m going to put the part number in and select the compiler, now what’s happened in the background is the coding assistant has downloaded the vector datasheet.”
Figure 1 The VS AI coding assistant tool showing the details of the PIC32CM JH family of MCUs.
Code generation
As shown in Figure 2, Richey begins by asking the assistant to generate code to initialize the UART and ADC, sample once per second, and write to the UART an array of 32. At this point, the tool returns the code and interrupt routines that Richey arbitrarily places within the source code file.
Figure 2 Code generation to initialize the UART and ADC within the PIC32CM JH MCU.
Checking code for errors
The source code is then copied and pasted into the chatbot to check for errors and a number of issues are found (Figure 3). “I inserted the code in the middle of an existing function and what it does is creates a corrected version of the code,” Richey then places the corrected code into the existing file.
Figure 3 Error is copied and pasted into the chatbot and a request to check for errors is placed whereby the coding assistant returns a number of errors found within the code.
Autocomplete
At this point, the autocomplete function is highlighted. First, code is created that adds two numbers together (Figure 4). As Richey accepts autocomplete inline suggestions, the tool begins predicting the next steps in the code: creating a function to average the numbers within the array. Figure 4 shows some of these inline code suggestions. Comments can also be added with relative ease by simply asking the assistant to comment the code where the user’s job is limited to rejecting/accepting the comment suggestions. “We want to keep the developers in the flow of writing code. Anything you do is a distraction, even if you have to leave the development environment or even write comments.”
Figure 4 Autocomplete functions create inline comment/code suggestions that the user can accept or reject.
Exploring the datasheet within the IDE
Richey brings up a block diagram of the analog comparator within the development environment by prompting the tool with “show me the block diagram of the analog comparator,” as shown in Figure 5. “If I want to look at what the registers are for, it’ll show me all of the registers and the bits within them.”
Figure 5 Block diagrams for the analog comparators can be viewed within the IDE with a hyperlink that takes the user to the datasheet.
At this point, Richey has the tool write code to initialize the comparator which he can then, once more, place arbitrarily within the source code, and check for errors. “Now I’ve got a project open that’s got a lot of directories, and each one of these directories has a lot of files,” Richey goes on to show the “@Codebase” prompt checking for a function to initialize the SERCOM0 module, a UART-to-serial port that is on the PIC32CM JH (Figure 6). At this point, the tool pulls out the relevant piece of code so that the user can drop it into any other file. “I can do an @file where I can go search for a particular file, @folder to bring up all the folders within the project.”
Figure 6 Checking the codebase for a function to initialize the SERCOM0 module, a UART-to-serial port that is on the PIC32CM JH.
Unified compiler
The MPLAB XC unified compiler licenses just released today are another initiative by the company to simplify the process of working with Microchip’s hardware and software. “Typically, you’ll have a free compiler and an optimizing compiler that you have to pay for. The difference with the optimizing compilers is that they have implemented core- or product-specific optimizations where you’ll typically see ~35% smaller code for a vendor supply compiler relative to, say a GCC [GNU Compiler Collection],” says Richey. The marginal gains can be the factor that pushes engineers into a higher memory, more expensive, device where the cost of a compiler would likely pale in comparison to the per unit savings on a mass-manufactured product.
“A vendor today will typically supply core specific compilers, so there might be an ARM core, a MIPS core, or a supplier-specific core. As a client this can be difficult to manage. You have to ask yourself how many compilers you need.” And, as the needs for the project change, so do the mix of compilers used potentially creating more overhead for the client since payments for compilers are generally issued on an annual basis. For more stringent industries like industrial and automotive, the clients might stay on a fixed version of a tool for decades, where they must pay for that same version every year.
“Microchip supports a lot of automotive, medical, industrial, and aerospace and defense clients, and they’re typically fixed on one version, because to upgrade the compiler version forces them to go back through an approval loop and it’s very costly for them, creating a purchasing nightmare.” Microchip is attempting to sidestep these issues with the unified compiler where a single, perpetual license grants access to the MPLAB XC8, XC16, XC-DSC and XC32 C compilers. There is however a voluntary 12-month maintenance fee that is 20% the cost of the compiler.
Richey finished by highlighting Microchip’s initiatives for easing the development process for embedded engineers using Microchip hardware/software, “Whether it’s IR, Keil, SEGGER, VS, or the Eclipse IDE, we realize that not everyone that’s developing for Microchip is using Microchip tools. So we want to meet the developer and the ecosystem of their choice. We don’t want to force them into our ecosystem.”
Aalyia Shaukat, associate editor at EDN, has worked in the design publishing industry for six years. She holds a Bachelor’s degree in electrical engineering from Rochester Institute of Technology, and has published works in major EE journals as well as trade publications.
Related Content
- Analog Devices’ approach to heterogeneous debug
- Elevating embedded systems with I3C
- 8 pillars of embedded software
- Optimizing motor control for energy efficiency
The post Easing the development burden for embedded systems appeared first on EDN.