Connecting buttons to MSP430

In this new tutorial, we will see the easiest way to connect a push-button to the MSP430. I will be using msp430 Launchpad for the purpose of the tutorial, however, you can use a bread-board to externally interface the push-button Before I begin, I want to tell you the advantage of Msp430 over other sets of microcontrollers available in the market.  As you might have seen, msp430 is a pretty cheap microcontroller from the Texas family, and has a 16-bit wide data bus for processing the data but has very few number of pins. Only 2 ports of 8 pins each are available for interfacing and that two without support for an external crystal. If you want to connect an external crystal, you lose two more pins and that reduces the total number of pins available for interfacing to just 14.  But this is just the other side of the coin, the other being its application in low-power projects. Consider a situation where you need to log a data out of a sensor and send it to a local station…

Continue reading

Blinking the LED with MSP430

This is the second tutorial on MSP430, and it will feature code on blinking the led’s and hence will tell you how to configure the ports as input and output and make the port low and high when it’s declared as output. For those having an MSP430 launchpad, it has two onboard led’s connected via two jumpers to pins p1.0 and p1.6. Our task for today is to blink these led’s alternatively or toggle them. To start with an open code composer studio, go to FILE->NEW->CCS PROJECT. After doing this, you will get a window mentioned below Enter your project name, select family as MSP430, and now the variant is msp430g2253. Remember, this is a critical step. To check your option, refer to your chip on the Launchpad. It has a mention of the variant. For all the tutorials, I will be using msp430g2553 as the chip, so kindly change accordingly. In the bottom box, select Empty project (with main.c)  and click Finish.

Continue reading

Getting Started With The Msp430

This tutorial is an introductory tutorial on getting started with the MSP430 series of controllers by Texas Instruments. There are millions and trillions of ways to start using microcontrollers. Hobbyist or people who find hard to code typically prefers Arduino as their coding environment, while engineers might prefer using AVR/PIC. The MSP430 microcontroller is a highly versatile platform that supports many applications. With its ability to consume ultra-low power, it enables the designing engineer to meet the goals of many projects. It has, of course, its limitations. It is inclined mostly towards low energy and less intensive applications that operate with batteries, so processing capabilities and memory, among other things, are limited. However, it’s still called a mixed-signal processor and is capable of doing some sort of speech processing. Before starting with some exposure to hardware and software part, I assume that you all have some sort of programming knowledge in embedded c. Even if you know java or c++, you will still be able to adapt to the tutorials easily as the logic will remain the same; only the…

Continue reading

Using Volatile keyword in embedded code

Volatile is probably the least documented keyword in most tutorials and books. This is the primary cause of most misuses and bugs related to it. If you already are programming microcontrollers, you probably know that volatile is always used on global variables that are accessed from interrupt service routines. Otherwise, code won’t work. After few requests, I decided to drop few lines about volatile keywords. This keyword is commonly used to tag memory type. We hear “volatile memory” and “non-volatile memory” when discussing computer hardware. As a quick reminder – “non-volatile memory” is a type of memory that stores its contents even when power is off. Such type of memory is EEPROM, Flash, and FRAM. This is easy from a hardware perspective. But what volatile keyword means in C or C++ code? This is an indicator (called qualifier) to the compiler that tells that this variable may be changed during program flow even if it doesn’t look like it be. This means that compiler must treat this value seriously and keep optimizer away from it.

Continue reading

Interfacing GPS Module with AVR

GPS modem is a device which receives signals from satellites and provides information about latitude, longitude, altitude, time, etc. The GPS navigator is more famous on mobiles to track the road maps. The GPS modem has an antenna which receives the satellite signals and transfers them to the modem. The modem, in turn, converts the data into useful information and sends the output in serial RS232 logic-level format. The information about latitude, longitude, etc., is transmitted continuously and accompanied by an identifier string. The connection of GPS modem with AVR microcontrollers shown in the circuit diagram. The ground pin of max 232 and serial o/p of the GPS modem is made standard. Pin 2 of MAX232 is connected to pin 3 of GPS modem, and pin 3 of max 232 is connected to pin 2 of the modem. This type of connection is called a serial cross cable.

Continue reading

Software Debouncing of buttons

Connecting a button as an input to a microcontroller is a relatively easy task, but there are some problems. The main problem is that switches bounce, i.e., when you press (or release) a button, it will often change level a couple of times before it settles at the new level. So if you, for example, connect the switch to a pin with an external interrupt enabled, you will get several interrupts when you press the button once. This behavior usually is not wanted. Even if the buttons didn’t bounce (with filtering hardware, for example), we still want to capture the event of a pushed button and take some action once for every button press, so we need to keep track of the state of the switch as well. One technique used in this tutorial to handle this is to check (poll) the button(s) periodically and only decide that a button is pressed if it has been in the pressed state for a couple of subsequent polls.

Continue reading