Site Loader
Rock Street, San Francisco

Objective: Experiment 1 was to help introduce CCS Code Composer Studio and get more familiarized with the user interface and some basic concepts of programming the MSP430FG4618. We are also learning how to program in both assembly and the C language.Apparatus List: The following materials were used to complete this experiment:A computer capable of running the Code Composer StudioMSP430FG4618 experimenter boardMSP430 USB-Debug interface (MSP-FET430UIF)Procedure and/or Design Methodology: To perform Experiment 1 you must execute Code Composer Studio. Then open a new project and follow the steps in the Lab manual to create a new project for C language. You then have to copy the codes from the manual that were written by the author already and workout the bugs so they will work. The desired output of the first two programs are to alternate the green and yellow lights on the board, first through C language then through assembly language. These LED’s can be selected specifically through port 2 bit 1 for yellow and bit 2 for green. Once that is done you have to alternate them by identifying them as an output and then use “i” to increment and alternate the order and duration of the lights to flash. To do the same in assembly you have to make another similar delay loop because you need more than the allowed 16 bits to slow the program enough of the alternating flash.  Setting as an output and turning on in assembly can be done in one step (bis.b #0x04,) and turning on and off can be completed by the XOR instruction (xor.b #0x04,). The next step is to assign switch 1 and 2 (Port 1 bit 0 and 1) to turn on the Green and Yellow LED, respectively. First, SW1 and SW2 must be set as inputs, using P1DIR |= 0x00; for C language and bis.b #0x00, for assembly language will set both as inputs in one instruction. An infinite loop must be created which continuously checks for the condition of SW1 pressed, SW2 pressed, or BOTH pressed. If none of these conditions are met the loop will continue running with both LEDs off. For C language, use “for loops” and “jumps” for assembly language.Design Specification Plan: The design of the alternating blinking lights program (written in both C-language and assembly language) as well as the LEDs to switch program (also written in both languages) was created, following guidelines, in order to meet the requirements of the laboratory experiment. In the first program, written in C-language, the first step was to set the LEDs as outputs, in order to be able to turn them on. An infinite loop was used in order to ensure the blinking lights continued for as long as the program is running. A for loop which decrements a set value a set amount of times in order to meet the requirement of a one second flash of one LED before switching to the next. The value 50000 was chosen after running the program at different values until the flash was near one second. A more precise value can be calculated by dividing 8MHz (the speed of the processor) by the amount of instructions and the time required for each. An XOR instruction was used to alternate the LEDs. For the first program, written in assembly language, the first step was also to set the LEDs to outputs. The loops used, in order to delay the flash to show for one second before alternating, were created using jump instructions. Since the processor can only hold 16-bits, two loops were needed in order to create a long enough delay. An XOR instruction was also used in alternating the LEDs. The second program, written in C-language, first set the LEDs to outputs and the switches to inputs. It can be thought that the pressing of a switch is an input.  Next, an infinite for-loop with a series of if-statements was used to continuously check for inputs, which would correspond to the associated output. The if-statements would allow for the light or lights to turn on as soon as the switch was pressed and until it is released. Finally, the last program, written in assembly language, met requirements through the use of an infinite loop containing several jump (or branch) instructions that when met, would jump out of the loop and perform the required output, them when released would jump back into the infinite loop.Test Plan: To test the results of our programs we just debug and run the programs and then test the results for alternating green and yellow LED’s on the board and the corresponding LED’s to light up with the correct inputs on the board.

Post Author: admin

x

Hi!
I'm Velma!

Would you like to get a custom essay? How about receiving a customized one?

Check it out