Author Archives: Shawon Shahryiar

ATXMega Primer

The XMega series is a powerful addition to the existing arsenal of Atmel’s AVR-core micros. As much as I have personally studied about it so far and felt, the XMega series incorporates many features of conventional 32-bit ARM micros like alternate I/O pin mapping functionalities, sophisticated clock options and data buses, multiple communication platforms that have several uses, variety of capture-PWM options, 12-bit ADCs and DACs, DMA controller, USB hardware, etc. with the good old AVR core. Thus you get one hell of an 8/16 bit MCU that can fulfil your wildest micro desires. In terms of unit cost, resources and user flexibilities this family of micro can beat any present day micro in most of the scenarios. Unlike other manufacturers who design chips as to fit specific applications, there’s no limit for XMega series. It is one controller with unlimited possibilities that can fit into any application. Indeed it is a true Atmel slogan now:

My microcontroller can beat the hell out of your microcontroller.”

There are several things that are should be known. XMega is still a relatively new breed of micro. There’s literally nothing similar to it in the market no matter which manufacturer you can name. As I said Atmel added literally everything that can be imagined. Initial XMega devices had several hardware flaws and were unstable. They had problems related to power and operational stability. However these shortcomings are no longer there as they were. Atmel dramatically improved this new line of devices and are yet doing a lot of R&D on it. The older successful AVR Mega series micros are not as same as XMegas and so what can be applied to Mega AVR can’t be applied for the XMegas. There are significant differences both in terms of hardware and software but still there are similarities.
Read more

STM32 Programming Tips and Tricks

I remember that once in the beginning I said that I don’t want to buy a programmer/debugger hardware for learning a new MCU like the STM32 and also STM32s already come with built-in bootloader to facilitate programming via USART just like Arduino. Still the second is true. Well what about the first? To my own surprise I actually acquired a number of STM32-related stuffs since the time I started playing and exploring them. I actually bought both ST-Link 1 and 2 programmer-debuggers and several STM32 boards from Waveshare Electronics (http://www.wvshare.com). I believe learning new stuffs is more valuable than anything else.

ST-Link Programmer/Debugger

ST-Link 1 (AKA ST-Link) and ST-Link v2 are both basically the same programmer/debugger hardware with some minor exceptions. ST-Link 2 has 5V tolerance for JTAG interface, it has a bicolour status LED and it also has a separate programming interface for STM8 micros unlike ST-Link 1. There is also an ISOL version of ST-Link2 that galvanically isolates it from its target using optoelectronics.

stlinkgreycablewhite

ST-LINKV2_3

Read more

XMega I/O Ports

Any microcontroller must have I/O pins for taking inputs and providing outputs. The ATXMega32A4U just like any other micro has 34 programmable I/O pins divided unevenly amongst six IO ports. Most I/O ports are 8 bit wide. XMega I/Os have digital, analog and special purpose functions. Some I/O pins have more than one use. A quick view of the XMega I/O pins reveals the purpose of these pins.

XMega Interior

Read more

STM32 Internals

STM32 micros as we know are high-end micros and this high-end tag is not only due to its memory, speed and hardware richness. An advanced micro like this also needs advanced internal supporting hardware. Most of us know about watchdog timers from previous experiences with common 8 bit MCUs like AVR and PIC. However when it comes to STM32 the idea of watchdog circuitry is elaborated. The options available for clock are also enhanced in the STM32 micros. In this post, we will see some of these supporting internal hardware. We will examine the use and operation of two different watchdog timers – Independent Watchdog (IWDG) and Window Watchdog (WWDG), and the clock options usually found in common STM32 micros.

Clock Options

In a robust microcontroller like the STM32 there are several options for clock. At first the whole stuff may look a bit complex. Indeed it is complicated but not too difficult to understand. The simplified block diagram below shows the common clock arrangement inside a STM32F103 series MCU.

Clock Internal

STM32F103 Internal Clock Arrangement (Source: The Insiders Guide to the STM32 ARM based Microcontroller from HITEX, http://www.hitex.com/fileadmin/pdf/insiders-guides/stm32/isg-stm32-v18d-scr.pdf)

Read more

STM32 External Interrupt

In my earlier post on STM32 GPIOs I showed how to flash a LED with variable delay times. That example was based on polling method where the code continuously monitored the logic state of a GPIO input pin attached to a push button to determine the delay amount. Obviously that won’t be an efficient technique when a program will be of a considerable size and complexity. This is simply so because the CPU will have to check the GPIO’s logic state every time the super-loop (while (1) loop in the main function) repeats and the push button will also not be responsive during the software delay function calls. Thus the overall performance is poor and not real-time. To get rid of these issues, we’ll need to use external interrupts – a vital feature in every common microcontroller.

STM32F1xx series are ARM Cortex M3 based MCUs. The Cortex M3 based MCUs have a sophisticated and yet easy to use interrupt system called the Nested Vectored Interrupt Controller (NVIC). It ensures low latency and high performance. There are several features of the NVIC and these are handled by the compiler. Our job is simply to enjoy the lightning fast interrupt responses owing to the NVIC. In many MCUs’ interrupt system, interrupt priority can be set and Reset has the highest interrupt priority over anything else. The same things go for STM32s too. However at present I’m not going to go that deep as that’s not needed for now. In some upcoming post may be I’ll discuss the NVIC in details. As per STM32’s reference manuals for more information on exceptions and NVIC programming read Chapter 5 Exceptions and Chapter 8 Nested Vectored Interrupt Controller of the ARM Cortex-M3 Technical Reference Manual. There are other interrupts that are related to RTC, timer, etc. We won’t also look into them in this post. We will learn about them when we learn about the related hardware with them.

EXTI internal

Read more

« Older Entries Recent Entries »