Assembly Language Programming

From Class Wiki
Jump to: navigation, search

TI MSP430 Links


There are various toolchains (build tools) for the MSP430. TI provides the Code Composer Studio (both desktop, and browser based) toolchain. At this point, the desktop version is much more powerful than the browser based version, and you need it for this class. There are also some other toolchains that cost something, but I prefer Code Composer Studio.

Code Composer Studio

  • CCS will work with Linux and Windows, and now a beta is available for OS X.
    • To install CCSV6.1 on Ubuntu 15.04, you need to

before running the installer. There is some more information for Linux installs here. I also found out that installing Grace from the App Center makes the App Center blank thereafter, unless you reinstall CCSV6.1.

MSP430 Assembly using the TI Assembler
MSP430 TI C Compiler
  • MSP430 Optimizing C/C++ Compiler (See Section 6.5 and following for how to mix C/C++ and Assembly. It is really best to read the entire chapter though, as it is all pertinent to mixing C and Assembly. It will also help you if you want to program in C, as it tells how the C compiler uses the memory, the stack, the registers, etc., and once you understand the processor as you learn to do when you learn its assembly language, it is very interesting to see how that all works in C.)
    • Here is how to use printf() statements with Code Composer Studio.
    • TI C Examples Workspace This is a CCS workspace with all the C examples from TI for the MSP430F5529. It is useful to work around a bug in MSPWare that broke the feature that you could use in the Examples to create an instance of an example in your workspace. You can import projects from this workspace into your regular one, so you don't have to switch workspaces to see the examples. You can read the descriptions for these examples in the Examples feature of Code Composer Studio. You just can't import them into your workspace until TI fixes the bug. When they do, this will no longer be useful. Soon I hope!
IAR Tools

IAR also makes a toolchain. It is not free, but you will sometimes find code that was developed for it, and it is slightly different from that developed for Code Composer Studio using either the TI or GCC compilers/assemblers.

GCC Compiler

You may use the GCC compiler from within Code Composer Studio. It is not limited in the size of the code that it can compile. There are some differences between it and the TI compiler. I find that the TI compiler usually works more easily, with TI examples especially.

To make your program using interrupt service routines compile with either the TI or the GCC compiler, you need some #ifdef's like this:

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#error Compiler not supported!

Note that you need to substitute the appropriate ISR vectors in your code.

C Language References

Translating Embedded Code Between Assembly and C

When reading C code to understand what you wish to do in Assembly, or vice versa, it is handy to understand some common statements you see in C. Listed below are the most commonly seen ones.

 P1DIR |= #BIT0;  //is the same as bis.b #BIT0, &P1DIR
 P1DIR &= ~#BIT0;  //is the same as bic.b #BIT0, &P1DIR
 P1DIR ^= #BIT0;   //is the same as xor.b #BIT0, &P1DIR

MSP430F5529 Specific Data

Launchpad Evaluation Board Data


Code Examples from Class

Slides and Videos 2015 and 2016

These slides were modified from Mark Clement's work at BYU. The slides are the major categories, and the videos explaining the slides are the sub-categories.

Quiz Answers

Materials for the MSP430 Family from Other Courses

Project Related Links and Notes

2015 Robot and 2016 Car Information

  • Building Tips
  • L9110 H Bridge Data Sheet
  • Bluetooth UART HC-05 and HC-06
    • HC Bluetooth Manual
    • The bluetooth module for 2016 is a little different:
      • It uses the BK3231 IC and it's data sheet is available from the FCC here.
      • It is the SPP-C module described on this page.Bluetooth Carrier.jpg
      • Solder five pins on one side and three on the other to get your bluetooth module onto your carrier board.
      • These are the AT commands which if you use them to configure your bluetooth have to be issued from the wired side (not from the phone). You can use them to change the name with "AT+NAME<Name you want to use instead of BT-04A>" where I found for me sending a line feed after this was needed. The name you want to call you bluetooth device is just typed after the AT+NAME, like AT+NAMERob if I want to call it Rob. I should note that I had some difficulty with this. I don't seem to know how to terminate the name, but this may get you started. It is not handy to have your bluetooth device named the same thing as everyone elses when you are in the same room trying to pair with it.
      • The baud rate to start with on these boards is 9600, 8N1. You need to send carriage return and line-feed both to get a response from the board. Remember that TX on one side is connected to RX on the other. The module identifies itself as BT04-A, and the PIN is 1234 over bluetooth.
  • Blueberry Android Bluetooth Remote Control App
  • HY301-07A Photo Interrupter Datasheet From the datasheet, we will choose a forward current on the LED to be 5 mA because we don't want to waste batteries, and that is the lowest the data sheet shows it working. That leads us to a forward voltage across the diode of 1.3 volts. If we run things on 3.3 volts that gives us a voltage drop of 3.3-1.3=2.0 volts. Ohms law says a resistor of R=V/I=2volts/5mA = 400 ohms. We will pick 390 ohms since it is an available 5% value. For the phototransistor, we see that the current for the forward diode current we picked should be about 0.2 mA. If we want the output to drop to 0.5 volts with the LED on, that leaves 3.3 volts - 0.5 volts = 2.8 volts across the collector resistor, so using Ohm's Law again, we need a collector resistor of 2.8 volts/0.2mA = 14 Kohms, so we will pick 15 Kohms because it is a standard value. The 15 Kohm resistors are optional as you can use the built in ones on the MSP430 controlled by PREN.
  • I count 20 holes, on the encoder wheels. This gives 20 periods per revolution. The wheel diameter is about 0.066 meters, so the radius is 0.033 meters. This gives about 0.21 meters per revolution. It seems a pretty fast speed is about 1 meter per second, which means that we have about 5 revolutions per second, or 100 cycles per second, or about 0.01 seconds per period at high speed.
  • Applying Feedback makes the robot easier to control. This web page gives a somewhat helpful primer on that process.

CC3100 SimpleLink Wi-Fi Family

2014 Robot Information

  • HSR-1425CR Continuous Rotation Servo Datasheet
  • Schematics These are rather crude schematics of the robot circuit board. There are two cuts and jumps that are not reflected, at least on the last one. The effect is to change the photo transistors from a common emitter to a common collector configuration. You can see the change scratched in just below the word Fairchild on the hand drawn schematic. Basically the resistor and photo transistor are reversed in order. I believe both photo transistors are swapped to common collector configuration.

Logic Analyzer Information

These logic analyzers are clones of the original Saleae analyzer. They have software compatible with this analyzer, but they don't like you to use it.

Logic Analyzer.png

Digital Logic Links

ARM7 Links

Raspberry Pi

Depending on the version, your pi may use ARM6 or ARM7. There is actually quite a lot of good assembly language information for programming the raspberry pi.

Other Miscellaneous Interesting Reading