Showing posts with label embedded. Show all posts
Showing posts with label embedded. Show all posts

LogiFind MSP430 LCD KIT-C - Part 2

Continue with our discussion with this development kit. In part 1, we've discussed on accessing the device through MSPDebug but with limited success. This post will continue on investigating different drivers used by MSPDebug in trying to identify and use it. The investigation will focus on the `tilib` driver.

$ mspdebug tilib
MSPDebug version 0.22 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2013 Daniel Beer
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

tilib: can't find libmsp430.so: libmsp430.so: cannot open shared object file: No such file or directory

Google results indicates that we need to download the driver file, `libmsp430.so` from the TI own MSP Debug Stack itself. See the screenshot below to get the right file.



Once you've downloaded and extracted the MSP Debug Stack package, looks for the right driver file that match your system, either it's 32-bit or 64-bit. Use the command below to identify that.
$ uname -m
x86_64

Since we're running on 64-bit system, we will need to copy the driver file, `libmsp430_64.so` to its path so `mspdebug` program can detect and use it. Based on the description in SLAU56b,
libmsp430_64.so: This file is the dynamic library for Linux 64 bit and contains the device control functions. This file is normally located in the same directory as your application’s executable file, or in your computer system’s default library search path. This file is used during run-time.
Alternatively, you can compile the `tilib` library on your own.

The next step is to identify where is the default library search path. This is where the `ldd` program will help us.
$ ldd $(which mspdebug)
linux-vdso.so.1 =>  (0x00007ffdc6c98000)
libusb-0.1.so.4 => /lib/x86_64-linux-gnu/libusb-0.1.so.4 (0x00007f9817461000)
libreadline.so.7 => /lib/x86_64-linux-gnu/libreadline.so.7 (0x00007f9817217000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9816ff9000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9816df5000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9816a2e000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f9816803000)
/lib64/ld-linux-x86-64.so.2 (0x0000556b71a1a000)

Once we've identified the library search path, copy the dynamic library file and rename it as `libmsp430.so`.
$ sudo cp libmsp430_64.so /lib/x86_64-linux-gnu/libmsp430.so

Rerun MSPDebug program using the `tilib` library and there is no more missing dynamic library error.
$ mspdebug tilib
MSPDebug version 0.22 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2013 Daniel Beer
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

MSP430_GetNumberOfUsbIfs
No unused FET found.

Again but explicitly the device name. We can see the device and chip ID. Unfortunately, I can't understand why it can't detect the chip as MSP430F413?
$ mspdebug tilib -d /dev/ttyUSB0
MSPDebug version 0.22 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2013 Daniel Beer
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

MSP430_Initialize: /dev/ttyUSB0
Firmware version is 0
MSP430_VCC: 3000 mV
MSP430_OpenDevice
MSP430_GetFoundDevice
Device:  (id = 0x0000)
0 breakpoints available
MSP430_EEM_Init
Chip ID data: 04 00 55
......

Nevertheless, we're getting somewhere. More investigation in coming post.

LogiFind MSP430 LCD KIT-C - Part 1

As I was looking into available development kit of MSP430, I've made another curiousity purchase of another kit. This time is LogiFind's MSP430 LCD KIT-C, another tiny MSP430 kit using MSP430F413. Device is shown below (screenshot from local reseller, Partsories). As the device is powered through USB Type B connector (typically used by printer or camera), I've to purchase another USB Type A to Type B connector. Driver and documentation is located at LogiFind site.


Power up the device through my lappy seems straightforward, and the LCD immediately displays the current time and three red LED lights (TEST1, TEST2, and PWR) were turned on. The TEST1 and TEST2 LED lights were blinking continuously.

Checking the device info from the USB port in GNU/Linux shows that USB was detected as serial port or USB to serial interface bridge.
$ lsusb
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Even more details on the USB device.
$ sudo lsusb -D /dev/bus/usb/001/003
Device: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Device Descriptor:
bLength                18
bDescriptorType         1
bcdUSB               1.10
bDeviceClass            0 (Defined at Interface level)
bDeviceSubClass         0
bDeviceProtocol         0
bMaxPacketSize0        64
idVendor           0x067b Prolific Technology, Inc.
idProduct          0x2303 PL2303 Serial Port
bcdDevice            3.00
iManufacturer           1 Prolific Technology Inc.
iProduct                2 USB-Serial Controller
iSerial                 0
bNumConfigurations      1
Configuration Descriptor:
bLength                 9
bDescriptorType         2
wTotalLength           39
bNumInterfaces          1
bConfigurationValue     1
iConfiguration          0
bmAttributes         0x80
(Bus Powered)
MaxPower              100mA
Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        0
bAlternateSetting       0
bNumEndpoints           3
bInterfaceClass       255 Vendor Specific Class
bInterfaceSubClass      0
bInterfaceProtocol      0
iInterface              0
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x81  EP 1 IN
bmAttributes            3
Transfer Type            Interrupt
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x000a  1x 10 bytes
bInterval               1
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x02  EP 2 OUT
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0040  1x 64 bytes
bInterval               0
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x83  EP 3 IN
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0040  1x 64 bytes
bInterval               0
Device Status:     0x0000
(Bus Powered)

Next, is to check the connectivity through MSPDebug.
$ mspdebug --usb-list
Devices on bus 002:
    002:002 8087:0024
    002:001 1d6b:0002
Devices on bus 001:
    001:003 067b:2303
    001:002 8087:0024
    001:001 1d6b:0002

It seems I need to find a way to connect to it either through TI, FET, or Olimex FET driver.
$ mspdebug --fet-list | grep "Devices\|MSP430F413"
Devices supported by FET driver:
    MSP430F1611        MSP430F413         MSP430F6435
Devices supported by Olimex FET driver:
    MSP430F4132              MSP430F6730
    MSP430F5333              Preliminary_MSP430F413

More to connecting through MSPDebug in coming post.

This Week I Learned - 2017 Week 17

Last week post or the whole series.

What happen to software developers who are still coding in their 40, 50, and 60?  What will happen in the next 22 years will be an interesting and unknown territory for older programmer to explore. There is always the case of how to do keep improving or how can we be a better programmerKaizen. Continuous improvement through through learning with understanding and stay healthy, both physically and mentally.

Complacency is your worse enemy when come to learning. We take it easy, do not dare to explore out of our comfort zone and afraid to look stupid. We know if we're heading this path, we will stuck forever, basically doing the same thing every year. Hence the developer with ten years experience but doing the same thing every year. Yet, we're afraid to start. Keep waiting for the right moment, the right motivation, and so no.

The older I get, the more I realized that motivation is fleeting and only discipline is reliable. Motivation is based on feeling where discipline is based on your habit. Best to cultivate good habits rather than waiting for the right feeling to come. Nothing but one step at a time.

#1 RIP Robert Pirsig. (via HN) Yes, he is the author of the cult book, Zen and the Art of of Motorcycle Maintenance. Interesting write-up on him during his day at spent in Banaras Hindu University (Varanasi, India).

#2 Good write-up on being a serious code reviewer. Only professional developer will take their code review session seriously as both parties, the reviewer and the code will learn something out of the session. The main obstacle is always how to handle it in a objective manner. Sometimes developer forget that you are (as a person) not your code. It's always a tricky situation.

#3 Sometimes, certain websites could change your life. No surprise some sites from are Ask Metafilter. All these reminds me of the web of the '90 and the time spent on aimlessly browsing through each pages. This is before RSS was even a thing yet.

#4 How many ways to execute your script parallelly? Three. Using wait, xargs, and GNU Parallel. The last one is the most comprehensive, featureful, and still being maintained.

#5 How Technology is Hijacking Your Mind. The prevalent tactics on manipulating our surfing behaviour. Throw in some dark patterns, we're basically somehow influenced to a certain agenda and direction. Given the ubiquitous Web and the Internet, how do we anticipate this manipulation? For a start, digital detox is a good start but still, this is not a long term solution, especially for those working in technology sector.

#6 Real-time Programming. (PDF) A course in learning about programming embedded real-time system.

#7 Is Perl still a good choice for web development? Yes and no. If you're not inheriting legacy Perl project, switch to something else more modern. If you're stuck with CGI, move to CGI alternatives like Mojolicious, Dancer2, Catalyst, or PSGI.

#8 Virtualization in GNU/Linux. Good introduction of different virtualization technologies available that we can use.

#9 The web is not desktop applications. Well said. Well said.

MSP430 LaunchPad - Introduction to Low-powered Microcontrollers Development Board

Two months ago, I was working on an assignment which involved writing code for a simulator where the targeted machine was a microcontroller (also known as MCU or SoC). There were numerous issues with the project. One of such issue is using Interrupt Service Routine (ISR) to display the LED light at a specific interval and duration. There are numerious ways to solve this (I only found this after the submission), but we didn't managed to get it done right during that time. Furthermore, the main goal of the assignment was to let everyone experience a software engineering process through different team roles. Hence, correctness is not the priority here. Nevertheless, these unresolved issues piqued my interest on embedded programming and C/C++ programming languages. Also, my own self-exploration exposed me to different microcontroller kits available in the Maker community.

When come to microcontroller kits, Arduino Uno is the preferred choice right now due to its popularity, which again, is due to its beginner friendliness. But these comments by david-given (a), IgorPartola, wyager, Declanomous, david-given (b), and sotojuan at HN convinced me that TI MSP430 LaunchPad would be a better choice. Cheap (I've made a mistake purchasing the wrong LaunchPad kit, more on this later) enough and low-powered microcontroller for anyone to learn embedded programming and study hardware.

The next step is to purchase the microcontroller kits. Now, which MSP43X LaunchPad development kits? I bought the original LaunchPad kit, MSP-EXP430G2 for roughly MYR 50+ inclusive of tax from Element14. Make sure you add comment to the order form that the purchase is for personal use. Otherwise the sales person will have to reconfirm with you again. If you still remember I said I made a mistake picking the wrong kit. If I were to choose again, I will pick MSP-430FR4133 instead although it's more expensive. Two good reasons. First, the development board have an embedded Liquid Crystal Display (LCD). You don't have to buy an additional LCD display and going through the hassle of connecting it through the breadboard. Second, the MSP-EXP430G2 is not supported by GNU/Linux version of Code Composer Studio, the default Integrated Development Environment. These are not critical issues but just merely minor inconveniences. Videos below will show more details on the differences between two development boards.





The item arrived within 3 working days in a black box. The list of items inside the box is clearly explained by video below.


The full list of items are:
  • 1pc Quick Start Guide (slac432a)
  • 1pc MSP-EXP430G2 LaunchPad development board
  • 1pc MSP430G2553 microcontroller (with temperature measure demo app)
  • 1pc MSP430G2452 microcontroller
  • 1pc Mini-USB cable
  • 1pc 32kHz external crystal (I've no idea what this for even I've read slaa322c)
  • 2pc 10-pin PCB Connector (2 male/2 female)
  • 2pc LaunchPad sticker
One mildly interesting thing is the MSP430 part numbers. For example, the breakdown of the part number of microcontroller MSP430G2553 are:
  • MSP430 = CPU
  • MSP = Mixed Signal Processor
  • 430 = 430 MCU platform
  • G = Flash (value line) memory type
  • 2 = Generation 2 series where speed is up to 16 Mhz
  • 5 = Model within the generation
  • 5 = Memory configuration (RAM: 0.5K, ROM: 8K)
  • 3 = Variant of the devices
In the coming post, we will go through on setting the development environment in Ubuntu 16.10. Stay tuned.