<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Programming on Carmine Noviello</title><link>https://www.carminenoviello.com/categories/programming/</link><description>Recent content in Programming on Carmine Noviello</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Tue, 09 Feb 2016 17:36:16 +0000</lastBuildDate><atom:link href="https://www.carminenoviello.com/categories/programming/index.xml" rel="self" type="application/rss+xml"/><item><title>How to precisely measure microseconds with STM32</title><link>https://www.carminenoviello.com/2015/09/04/precisely-measure-microseconds-stm32/</link><pubDate>Fri, 04 Sep 2015 09:41:12 +0000</pubDate><guid>https://www.carminenoviello.com/2015/09/04/precisely-measure-microseconds-stm32/</guid><description>&lt;p&gt;I received this apparently simply question from a reader of this blog: how can I delay a fistful of microseconds in STM32? That is, how to measure microseconds precisely in STM32?&lt;/p&gt;&#10;&lt;p&gt;The answer is: there are several ways to do this, but some methods are more accurate and other ones are more versatile among different MCUs and clock configuration.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s consider one member of the STM32F4 family: STM32F401RE, the MCU that equips the STM32Nucleo-F401RE board. This micro is able to run up to 84Mhz using internal RC clock. This means that ever 1µs, the clock cycles 84 times. So, we need a way to count 84 clock cycles to assert that 1µs is elapsed (I&amp;rsquo;m assuming that you can tolerate the internal RC clock 1% accuracy).&lt;/p&gt;</description></item><item><title>Adding ethernet connectivity to a STM32-Nucleo</title><link>https://www.carminenoviello.com/2015/08/28/adding-ethernet-connectivity-stm32-nucleo/</link><pubDate>Fri, 28 Aug 2015 05:23:37 +0000</pubDate><guid>https://www.carminenoviello.com/2015/08/28/adding-ethernet-connectivity-stm32-nucleo/</guid><description>&lt;p&gt;One drawback of the Nucleo ecosystem is the lack of a version with ethernet connectivity or a dedicated shield officially supported by ST. There are 90 different STM32 MCUs available that provide an Ethernet MAC interface (this means that only an external ethernet transceiver - also called &lt;em&gt;phyter&lt;/em&gt; - and few other things are required to bring your MCU to the IoT world). STM32Cube (the HAL officially supported by ST) also provides support for &lt;a href="http://savannah.nongnu.org/projects/lwip/"&gt;lwIP&lt;/a&gt; stack. But, all the current Nucleo boards are designed with a MCU without an Ethernet interface (I think that the main reason is that only two STM32 MCUs with Ethernet MAC are available in LQFP-64 package and the Nucleo boards are designed to be pin-to-pin compatible between its releases - L0, F1, etc). This means that without a dedicated expansion shield it is impossible to add network connectivity to our Nucleo. And this is a sin considering what that MCU can do.&lt;/p&gt;</description></item><item><title>Getting started with STM32F746G-DISCO</title><link>https://www.carminenoviello.com/2015/07/13/started-stm32f746g-disco/</link><pubDate>Mon, 13 Jul 2015 05:06:56 +0000</pubDate><guid>https://www.carminenoviello.com/2015/07/13/started-stm32f746g-disco/</guid><description>&lt;p&gt;ST Microelectronics recently expanded its portfolio of STM32 microcontrollers with the new STM32F7 family. These are the new best-in-class MCUs from ST, with a Cortex-M7 core able to run up to 216Mhz (future releases will run up to 400Mhz with 2000 CoreMark index), with an internal flash up to 1Mb and 360Kb of RAM. STM32F7 is also able to run from external flash memory without performance penalty, thanks to a L1 cache (this is probably the most interesting aspect of these MCUs). STM32F7 are targeted for High-end embedded applications, especially to multimedia ones, and I think that it&amp;rsquo;s far from low-budget applications and hobbyist uses. At the time of writing, these MCUs are quite pricy, ranging from 12€ to 20€/pcs for low-volume orders. This is definitely a really high price, especially if you consider that &lt;a href="https://www.olimex.com/Products/Components/IC/A20/"&gt;you can find around&lt;/a&gt; Cortex-A7 MCUs for less than 10€. But I think that the price will be dramatically reduced in the future.&lt;/p&gt;</description></item><item><title>Running FreeRTOS on a STM32Nucleo using a free GCC/Eclipse toolchain</title><link>https://www.carminenoviello.com/2015/06/22/running-freertos-stm32nucleo-free-gcceclipse-toolchain/</link><pubDate>Mon, 22 Jun 2015 05:50:14 +0000</pubDate><guid>https://www.carminenoviello.com/2015/06/22/running-freertos-stm32nucleo-free-gcceclipse-toolchain/</guid><description>&lt;p&gt;Using a micro like the STM32F4, able to run up to 160Mhz, with 512Kb of flash and about 100k of RAM, without using an operating system is a nonsense. Although it&amp;rsquo;s perfectly possible to use some forms of cooperative scheduling to execute firmware activities, basically this not convenient especially when dealing with low level events related to hardware (eg. interrupt handling) and aspects related to synchronization. As long as your firmware starts to grow, you&amp;rsquo;ll need constructs to synchronize firmware activities, like queues or semaphores. Moreover, especially when dealing with low-power devices, a busy spin (while(some condition);) it&amp;rsquo;s not the best solution if you have to fight with mAh.&lt;/p&gt;</description></item><item><title>Conditional breakpoint while debugging STM32</title><link>https://www.carminenoviello.com/2015/06/09/conditional-breakpoint-debugging-stm32/</link><pubDate>Tue, 09 Jun 2015 16:34:33 +0000</pubDate><guid>https://www.carminenoviello.com/2015/06/09/conditional-breakpoint-debugging-stm32/</guid><description>&lt;p&gt;It&amp;rsquo;s a really common situation when working with hardware (especially while debugging asynchronous events): to stop execution while debugging only if a given event occurs. This is also called conditional breakpoint.&lt;/p&gt;&#10;&lt;p&gt;If you are working with the STM32 family and the CMSIS ARM package for Cortex-M processors, and your toolchain is GCC-based with GDB as debugger, you can place in your code this instruction:&lt;/p&gt;&#10;&lt;div class="code-block"&gt;&#10; &lt;button class="code-block__copy" type="button" data-copy-code data-copied-label="Copied"&gt;Copy&lt;/button&gt;&#10; &lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-c" data-lang="c"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#include&lt;/span&gt; &lt;span style="color:#75715e"&gt;&amp;#34;cortexm/ExceptionHandlers.h&amp;#34;&lt;/span&gt;&lt;span style="color:#75715e"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;(condition) {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;__DEBUG_BKPT&lt;/span&gt;();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;GDB will automatically stop when the event occurs at that line.&lt;/p&gt;</description></item></channel></rss>