Martin Cowen (39)

The Case of the Field Problem

Picking up someone else's design to get it into production is a common enough situation and yet there are always interesting problems to be solved. These can get particularly challenging if that previous engineer has left the company and was the only one who really knew how the product worked. In this case, not only was it a new product, it was the first product of a new range using a new processor and new communications protocol, which we were going to develop into many more variants. So it was inevitable that there would be some bugs found by the first customers. Of course the product worked fine on the bench - it was when multiple products were wired together in the field that the bug showed up. Although as a product manufacturer we specified how the field wiring was to be done, it is never that simple. Wiring is done by third parties who don't know the product design and system requirements, so what looks equivalent to them isn't necessarily acceptable in the complete system. We should have been able to provide sufficient guidance about the wiring requirements to guarantee acceptable performance, but this requires either a lot of…

Continue reading...

Getting to ping on STM32H743 with LWIP

Given that the promise of STM32CubeIDE is that adding functionality should be as easy as clicking in checkboxes, you'd think it would be easy to set up Ethernet on one of STM's own Nucleo boards which is designed for it, and to get it responding to ping on your internal network at a fixed IP address within minutes. If so, you've been misled by the way that simpler interfaces such as UART, SPI, I2C, and GPIO are easily configured with STM32CubeIDE/CubeMX, especially if you don't need to have them working through DMA. Because of the high speed nature of Ethernet, it is essential to use DMA and to get the caching set up right, and until you do, it doesn't work at all. Unlike UART, SPI, I2C or CAN, you can't just start with the simpler case of transmit-only to see if your physical layer is working and the baud rate setting from the clock tree is right because Ethernet essentially requires receive and transmit to work before you'll see anything at the IP layer. If your lowest level test is ping, it's not going to work until your PC can get responses to it's ARP requests. Over the last…

Continue reading...

Design of a processor and board independent driver layer

Reusability is an idea often touted in software, and embedded projects are no exception. In fact, the reasons for needing re-usability or ease of porting are often more pertinent to embedded projects even though the initial use-case doesn't call for them, and speed to market is usually business-critical. Why would the processor (or microcontroller) change after it has been designed-in? After all, the hardware designer has to make lots of decisions which are tied to that specific processor in that specific package, so it would be a lot of work for them to change it. Timescales for embedded projects often require the code to be in progress whilst the hardware is being finalised, PCB laid out and prototypes produced. If we can't start the driver layers until the prototypes are available, then it becomes risky to work on the aspects of the application which depend on the lower layers, even with a well abstracted design. During the pandemic, we saw chip shortages affecting many industries because of large orders by the big players, and large order cancellations which messed up everybody's lead-times. STM32s in particular were impossible to obtain unless you were part of the automotive industry. We found that…

Continue reading...

How to harness the power of generated code in STM32CubeIDE with your custom code

Code generation from ioc STM32CubeIDE is a powerful piece of software, including code generation from a GUI formerly known as CubeMX, a code editing environment and a full debugger. The code generation feature should not be dismissed as a beginner level gimmick because it can be used within a professional environment, saving a huge effort compared to doing that work yourself, when you know how to keep it under control. If you're not aware of how to keep the code generator under control, you could lose code, be unable to get your code where you need it in the files, and feel restricted by it's imposed code structure. The CubeMX part of STM32CubeIDE can be used as a standalone application or integrated into the IDE and uses the [project name].ioc file to store the configuration of the peripherals, drivers and middleware in a text file which can then be displayed in an interactive GUI. One ioc file is used for the project, even for multicore processors, which are configured using two columns of checkboxes. When working with the files generated by CubeMX, it is easy to be so overwhelmed by all the boilerplate lines that you just ignore them and…

Continue reading...

Why I won't do defence work

Quite a large proportion of embedded firmware jobs are in the defence industry. I won't be a part of that and here's why. There's a practical problem and a moral problem. The practical problem is not knowing who the products will be used by, when, and for what purpose. As usual, the BBC comedy show Yes Minister has more truths in it than official statements and procedures. Jim Hacker - "So there's no real control over who the arms go to in the end?" Sir Humphrey Appleby - "Oh indeed there is - the dealer has to provide and end-user certificate which is a signature acceptable to Her Majesty's government that the ultimate customer is in fact an approved user." Jim Hacker - "Is that that a real guarantee? I mean would you be surprised for instance if a British aircraft carrier turned up in the Central African Republic?" Sir Humphrey Appleby - "Well I for one Minister would be very surprised - it's a thousand miles inland" Jim Hacker - "Yes, you know what I mean. What about smaller weapons?" Sir Humphrey Appleby - "Well it's virtually impossible, there's stringent security, rigorous inspection procedures, meticulous scrutiny..." Jim Hacker -…

Continue reading...