MSP430 LaunchPad Tutorial - Part 4 - UART Transmission

Today we are going to learn how to communicate using UART with the Launchpad. For this purpose I will replace the default microcontroller that comes with the board with the MSP430G2553. It is the most powerful device in the MSP430 Value Line and it comes with an integrated hardware UART module, along with 16 Kb of Flash memory, 512 bytes of SRAM and an 8-channel, 10 bit ADC.

UART communication can be useful when dealing with sensors: as a basic example, we could...

In this new episode of our journey into MSP430 I will explain the basics of Analog to Digital Conversion on the MSP430G2231.We will write a program that will read an ADC channel and will toggle some leds based on the result of the conversion.

We start as usual with the inclusion of the header file for the MSP430G2231, the leds stuff and with the definition of a variable that will store the result of the conversion. We also declare a function that will initialize the ADC...

MSP430 Launchpad Tutorial - Part 2 - Interrupts and timers

What is an "interrupt"? It is a signal that informs our MCU that a certain event has happened, causing the interruption of the normal flow of the main program and the execution of an "interrupt routine", that handles the event and takes a specified action.

Interrupts are essential to avoid wasting the processor's valuable time in polling loops, waiting for external events (in fact they are used in Real-Time Operating Systems,

An Introduction to Embedded Development

This blog is a series to provide an introduction to embedded development for the aspiring embedded developer. No prior embedded development experience will be assumed, but you should have a reasonable understanding of the C language and knowledge of basic electronics. It will focus on the TI MSP430, but present topics in a generic way that can be easily translated to other processors. Welcome!

Hello, and welcome to my blog! This blog will be somewhat different from most...

MSP430 Launchpad Tutorial - Part 1 - Basics

So, let's see how to start a new project in Code Composer Studio. This IDE is derived from Eclipse, so if you used it before you shouldn't have much problems.

We'll write a simple program that will...

Endianness and Serial Communication

May 20, 2013

Endianness is a consideration that is easily overlooked in the design of embedded systems. I myself am amply guilty of this oversight. It’s something you don’t ever have to worry about if you’re only working with a single processor or two processors that have the same endianness.  You can even avoid it if you have two processors that have different endianness but never transmit data between themselves that consists of more than one byte.  It’s easy to lull...

C Programming Techniques: Function Call Inlining

Introduction

Abstraction is a key to manage software systems as they increase in size and complexity. As shown in a previous post, abstraction requires a developper to clearly define a software interface for both data and functions, and eventually hide the underlying implementation.When using the C language, the interface is often exposed in a header '.h' file, while the implementation is put in one or more  corresponding '.c' files.

First, separating an interface from its...

Debugging with Heartbeat LEDs

April 1, 2013

In this article I’ll discuss one of the most basic debugging tools in an embedded system: the heartbeat LED.  Picture this: you’re developing your first program for a new microcontroller. You’ve written the code, configured the programmer, downloaded the HEX file and now... what Your program is running - isn’t it?

Truth is that it’s hard to tell with most embedded software.  Compared to desktop or even server applications embedded software tend not to have very many...

Layout recomendations and tips for best performance against EMC

January 4, 2013

When making the layout of the circuit diagram, it is interesting to perform a preliminary analysis of several issues in order to minimize problems arising from electromagnetic compatibility.The analysis consists in:

Identify / Analyze components: This section will analyze the integrated components, as well as any recommendations it may have the manufacturer. We must also analyze the encapsulation possibilities which have the component.

LCD Control with an MCU

Controlling a liquid crystal display (LCD) to indicate a few ASCII characters should not be a big challenge as a project. That’s exactly what I thought when I decided to include a 2 line by 16 character display in my current project. My initial thought was. “How difficult could it be with all the resources on the internet and my embedded development expertise primarily in telecoms?” Let me tell you it is not as straightforward as I thought it would be and therefore I...

Introduction to Microcontrollers - Button Matrix & Auto Repeating

November 12, 2013

Too Many Buttons, Not Enough Inputs

Assigning one GPIO input to each button can use up a lot of GPIO pins.  Numeric input requires at least 10 buttons, plus however many additional control or function buttons.  This can quickly get expensive, GPIO pin-wise, and also connector-wise if the keypad is off the uC PCB as it often would be.  A very common response to this expense is to wire buttons (keys, etc) in a matrix.  By connecting our buttons in an...

VHDL tutorial - combining clocked and sequential logic

March 3, 2008

In an earlier article on VHDL programming ("VHDL tutorial" and "VHDL tutorial - part 2 - Testbench", I described a design for providing a programmable clock divider for a ADC sequencer. In this example, I showed how to generate a clock signal (ADCClk), that was to be programmable over a series of fixed rates (20MHz, 10MHz, 4MHz, 2MHz, 1MHz and 400KHz), given a master clock rate of 40MHz. A reader of that article had written to ask if it was possible to extend the design to...

Energia - program a TI MSP430 using Arduino sketches

November 5, 20131 comment

I started tinkering with microcontroller a couple of years ago with an Arduino Uno.  I had a little experience with C, so programming in the Arduino environment has been relatively easy and straightforward for me.  My code is not necessarily elegant or efficient, but I can usually figure out how to make an Arduino do what I want it to do eventually.  A lot of credit to the Arduino userbase, as it is very easy to figure most things out with a quick Google...

Favorite Tools: C++11 std::array

February 26, 2017

Many embedded software and firmware projects must be developed to high standards of reliability. To meet these reliability requirements, firmware project teams will consider many design tradeoffs. For example, an engineering team may avoid or outright ban the use of dynamic memory allocation, a feature typically accessed via the C library call "malloc" or the C++ allocator "new". When authoring software under such...

Real-time clocks: Does anybody really know what time it is?

We recently started writing software to make use of a real-time clock IC, and found to our chagrin that the chip was missing a rather useful function, namely elapsed time in seconds since the standard epoch (January 1, 1970, midnight UTC).Let me back up a second.A real-time clock/calendar (RTC) is a micropower chip that has an oscillator on it that keeps counting time, independent of main system power. Usually this is done with a lithium battery that can power the RTC for years, so that even...

Cortex-M Exception Handling (Part 1)

This article describes how Cortex-M processors handle interrupts and, more generally, exceptions, a concept that plays a central role in the design and implementation of most embedded systems. The main reason of discussing this topic in detail is that, in the past few years, the degree of sophistication (and complexity) of microcontrollers in handling interrupts steadily increased, bringing them on a par with general-purpose processors.

How to make a heap profiler

May 23, 2014

We'll see how to make a heap profiler. Example code for this post makes up heapprof, a working 250-line heap profiler for programs using malloc/free.

It works out of the box on Linux (tested on "real" programs like gdb and python). The main point though is being easy to port and modify to suit your needs. The code, build and test scripts are at github.

Why roll your own heap profiler?

• It's easy! And fun, if you're that sort of person. What, not reasons enough? OK, how...

October 16, 2013
Arduino Robotics

Beginner robotics is a series of article chronicling my first autonomous robot build, Clusterbot.  This build is meant to be affordable, relatively easy and instructive.  The total cost of the build is around $50. 1. Arduino robotics - motor control2. Arduino robotics - chassis, locomotion and power3. Arduino robotics - wiring, coding and a test run4. Introduction to Microcontrollers - More Timers and Displays October 15, 20131 comment Building Your World Around Timers By now you have seen four different ways to use timers in your programs. Next we will look at some ways to produce the effect of multiple parallel streams of work in your program with the help of timers. This effect is only an appearance, not a reality, since a single microcontroller (one core) can only run a single thread of code. However, since microcontrollers are so fast in relation to a great many of the tasks to... Arduino robotics #3 - wiring, coding and a test run October 17, 2013 Arduino Robotics Arduino robotics is a series of article chronicling my first autonomous robot build, Clusterbot. This build is meant to be affordable, relatively easy and instructive. The total cost of the build is around$50.

1. Arduino robotics - motor control2. Arduino robotics - chassis, locomotion and power3. Arduino robotics - wiring, coding and a test run4.