When we use microcontrollers in our circuits we need to program and debug them in circuits after soldering. Hence, In circuit programming is much useful in such cases. Here I'm going to program my MSP430G2211 microcontroller in a circuit. The programmer I'm going to use is the MSP430 Launchpad. You can get all of them from TI including FedEX shipping.I got them for $4.30 couple of years ago and it was a great deal. This MSP430 value line microcontrollers can be programmed using Spy-Bi wire JTAG interface.
You have to connect SBWTCK(TEST) and SBWTDIO(RST') connections between Launchpad and microcontroller. You may also give power to the device from Launchpad too.
Here is the pinout for my MSP430G2211 from its datasheet.
You may connect the device and Launchpad like this.Use some jumper wires and connect them to the given connector headers on the launchpad.
Now you can use Code Composer Studio or any other software to write code and program/debug it to the microcontroller as they are on the Launchpad itself. I coded a simple LED blink application at P1.0 (pin2) and tested on above circuit which was a success.
Sunday, April 21, 2013
Friday, April 19, 2013
Relays are awesome small devices which could be used to control other devices. The plus point of relays is,they can be used to drive a different voltage level device with complete isolation. In here, I'm going to show you how to build a simple relay drive board for your parallel port interfacing or microntroller interfacing. Basically we are using a simple NPN transistor as a switch to drive a relay. The diode is used to protect the transistor from back e.m.f. generated by the relay coil at transient points (relay on/off). You can use 6V or 12V or any other relay as you wish. The transistor used here is 2SD400 (Ic=1A,Pc=0.75W) which costs around Rs.10 ($0.08). You can use any other general purpose NPN transistor as you wish.
The schematic for a channel:
You can build any number of channels as you wish. Here is a 4 channel board build as above.
You can connect this board to parallel port's D0 to D7 (pin 2 to 9) which belongs to the DATA register of the port. A simple program could be coded to turn on/off the relays connected to the parallel port. Even you can connect this board to a microcontroller and do the same. (Image source:Wikipedia)
Monday, April 15, 2013
There are many CPU architectures in current embedded devices. MIPS is also a popular architecture for embedded systems. Here I'm going to play with a MIPS based AR7240 SoC as my development environment which has a MIPS 24Kc CPU . I'm using a TPLINK-WR740N router as my development board as I don't have any other MIPS development boards. It runs OpenWRT Linux for MIPS (this is not the stock version,I have installed it). So I won't be going to much lower level and I will play at the Linux level like using Linux on Rarspberry PI.
- Atheros AR7240@400MHz RAM:32MB Flash:4MB
- LED * 5
- Push buttons * 2
AR7240 has following interfaces:
- LAN * 5
- WiFi * 1
- GPIO (LEDs & Push buttons are already connected)
For testing I just wanted to blink a LED which is connected to the GPIO0 using a shell script.
I found the GPIO mappings from the OpenWRT wiki. The LEDs are already controlled by a module by default and I had to unload it using "rmmod leds_gpio" command. If you are new to Linux, here you can find about Linux kernal modules. I found a great tutorial on controlling GPIOs in any Linux system and I coded a simple shell script to blink the LED connected to GPIO0 in 1 second intervals. Raspberry PI wiki also has a good tutorial on this.
echo 0 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio0/direction
while [ 0 != 1 ]
echo 1 > /sys/class/gpio/gpio0/value
echo 0 > /sys/class/gpio/gpio0/value
I logged into the router with "ssh 10.0.0.1 -l root" and made a shell script called blinky.sh with above code using echo command (echo "the above code" > blinky.sh). You can create the blinky.sh file on PC and upload it to router using a SFTP client too. Then I made it executable with "chmod +x blinky.sh". Finally I run the script using "./blinky.sh" and it was a success.
(In below photo, the error is because I already unloaded the leds_gpio module)
Sunday, April 14, 2013
After Googling a bit about the TI Stellaris Launchpad, I found out that it can be used as a 10Mhz 8 Channel Logic analyzer with some small free softwares. The plugin's home page can be found here and please refer it for the further information about the functions.
You have to download following for this,
First of all you have to unpack the both files for two folders. Then copy "ols.profile-SLLogicLogger.cfg" file from the plugin to "ols-0.9.6.1\plugins" folder.
Then we have to flash the code into the launch pad. You can flash "sllogiclogger.bin" in the plugin to the launchpad using TI LM Flasher. If you are a linux user, you can refer to my previous post on flashing Stellaris Launchpad on linux.
Now you can run "ols-0.9.6.1\run.bat" to run the logic analyzer. If you are using Linux, you can run it using "ols-0.9.6.1\run.sh" .
In Logic Sniffer, got to Capture->Begin capture and set the configuration as below. Please note that you have to select COM port (here COM47) according to your Stellaris Virtual port on device manager.
Here I'm testing 3.3V Logic '1' on PB0 pin of the launchpad which is the Channel 0 in the logic analyzer. The results was as on the picture and it was a success. So now you can have your own logic analyzer with TI Stellaris Launchpad.
TI Stellaris LaunchPad has a quite neat ARM Cortex-M4F based microcontroller and built in ICDI debugging interface. It is a great tool for learning ARM architecture for a small price as $12.99 including FedEX shipping. Now this is upgraded to a better board called TI Tiva C launchpad which has a similar microcontroller. You can see an unboxing video of this launchpad from my friend's site.
Here I'm telling you my experience with this launchpad in GNU/Linux. I'm using Fedora based Fuduntu Linux 2013.1 64bit for this. It is a quite fast and simple linux distribution and it is worth while to try.
First of all I checked about the device drivers availability for this. I'm using Linux kernel 3.5.8 and it got auto detected without any manual driver installation. Here you can see the output of "lsusb" command.
According to that I downloaded the LM4FLASH software source and compiled it. Please note that you need to have LIBUSB-DEV dependency to compile this. You can install it by " yum install libusb* " command. In a debian based distro like ubuntu,you may use apt-get instead of yum package manager. Following commands can be used for the whole process according to that post.
git clone https://github.com/utzig/lm4tools.git cd lm4tools/lm4flash/ make sudo cp lm4flash /usr/bin/
After that I programmed the "qs-rgb" example from StellarisWare (now TivaWare) to test it.
You can get the TivaWare software library for TI Tiva C series microcontrollers from here.
The flashing was a success and the colour changing of RGB led on the launchpad was working (as for qs-rgb example),