WeatherSense. EEL4924 Final Design Report. Justin Mills. April 23 rd, 2013

Size: px
Start display at page:

Download "WeatherSense. EEL4924 Final Design Report. Justin Mills. April 23 rd, 2013"

Transcription

1 WeatherSense EEL4924 Justin Mills April 23 rd, 2013

2 Table of Contents Introduction/Project Summary Project Features/Objectives Analysis of Competitive Products Concept/Technology Selection Project Architecture Hardware/Software Used Design Procedure Used User Manual Gantt Chart Appendix A Code Used for Weather Station Appendix B Code Used for Music Generator

3 List of Figures/Tables Figure 1 Basic Block Diagram Figure 2 Block Diagram, Weather Station Figure 3 Block Diagram, Music Generator Figure 4 Weather Station Code Flowchart Figure 5 Music Generator Code Flowchart Figure 6 Gantt Chart Table 1 List of Weather Sensors

4 Introduction/Project Summary This project integrates different weather sensors into a random music generator. The music generator will have a base mode, and the weather sensors will each alter the base mode in some distinct way. Hopefully a user with a good ear will be able to figure out what the weather is by picking out the effects being used. WeatherSense will send data from weather sensors wirelessly to a processing unit, which will then translate the data into music and play to a speaker. Some of the technical challenges for this project include performing different sound modulations, creating a random music generator, and obtaining/providing reliable weather data. The purpose of this project is to make weather data interesting. The main value of the WeatherSense is entertainment, and if the music generator is successful this project could supply a constant source of sound for a user with sedatephobia. Hopefully when completed, the user will be able to determine what the weather is by listening to the sound being played. Project Features/Objectives WeatherSense breaks down into two main functional components. As seen in the basic block diagram below, the weather station and the music generator will be their own systems and will communicate wirelessly. Figure 1 The first subsystem of WeatherSense is the weather station. The weather station will contain sensors to detect the following effects: - - Temperature Atmospheric Pressure 4

5 Wind Speed Wind Direction Rainfall Light Along with these sensors, the weather station will utilize an on/off switch, and a three state frequency switch. The frequency switch will determine how often the weather station takes measurements and transmits data. As the weather station is intended for outdoor use, it will be powered by a battery/solar panel combination. During limited light the battery will power the weather station, and when the solar panel is producing it will power the system and charge the battery. If the battery runs too low, the weather station will alert the music generator, which will alert the user with an LED indicator. The weather station will communicate with the music generator using xbee wireless modules. The xbee modules have a range of about 300 feet, and the weather station will include a demo mode to make sure the weather station and music generator can communicate with each other. The music generator will supply a constant stream of tones that possess a musical quality. Musical quality will be achieved by picking tones with consonance, and by repeating themes a few times before restarting the process. The music generator needs to have enough structure to sound good, while being random enough to remain interesting. The sensors on the weather station will provide part of this randomization. The data from these sensors will alter the output of the music generator in the following ways: Temperature range (60s, 70s) will decide how many times a tone is repeated before being dropped. For example, when the temperature is in the 60s a tone will be played 6 times before going silent. Light will decide the mode of the music. Dark readings will result in minor tones being picked; light readings will result in major tones being picked. Wind speed will rapidly increase the speed of the theme, by dividing when the tone starts, ends, and the length of the theme by 2. The goal is to give the impression of increasing tempo with increasing wind speed. Wind direction will control how long a tone is played before it fades out. Rainfall will cause tone echoes. Light rainfall will cause a slight echo, while heavy rainfall will add more of an echo. Atmospheric pressure will control the length of a theme. Falling pressure will play a 14 second theme, and rising pressure will play an 18 second theme The music generator will be located around the user (who hopefully spends time around a wall outlet), so it will get its power from the wall. 5

6 Analysis of Competitive Products A comprehensive Internet search turned up weather stations and music generators, but no combination of the two. The weather stations are all very similar; as the goal for each is the same, provide standard weather data. However many different types of music generators exist. For this project I will attempt to create my own, as I could not find any readily available code that could be used as a basis for my project. Concept/Technology Selection Coming into this semester I wanted to do a project that involved weather data/building a weather station in some way. My initial pitch was to have a database the weather station was accessing and be able to ping that database with an , however this plan was deemed too boring. After a suggestion by Mr. Eric Liebner the database was dropped and the music generator was added, and my project concept was selected. Project Architecture The project architecture for WeatherSense can be split into two modules, one being the weather station and the other the music generator. These main blocks are connected using two xbee wireless transceivers. The figure shown below is a block diagram for the weather station. 6

7 Figure 2 The main objective for the weather station was integrating the various sensors to a microprocessor. Each sensor requires up to two GPIO ports on a microprocessor, so the processor needed to have the appropriate number and type of ports. Of the different sensors used, detailed in the Hardware/Software section below, some were analog signals that needed processing, others were plain digital, and one used serial communication. The weather station functioned by obtaining readings from these sensors during a timed interrupt, and sending the data out using the xbee module. The power supply for the weather station will need a recharge circuit, as it will be battery/solar powered. The power supply will function by using what s available. If there is no light, the battery pack will be used. If the sun is out, the solar panel will charge the battery pack and power the system. The figure shown below is the block diagram for the music generator. 7

8 Figure 3 The main objective with the hardware for the music generator was to receive the weather data, process it, and send it out to a speaker and LED bank. First, the processor obtains the weather data by reading the receive buffer on the xbee module. Next the processor updates the LED display to reflect the values read, and decides what tones to play. These tones are output to a DAC, which then runs the analog signal through a low pass filter and a speaker amplifier before being output to a speaker. Different voltages are needed for the different components on this board, but they will all be derived from a 24V wall wart. Hardware/Software Used This section, similar to the previous, is divided between the weather station and music generator modules. The main hardware used for the weather station consisted of the weather sensors, the processor, and the power supply. Below is a table detailing the weather effect, the sensor used, and how it interfaced to a processor. 8

9 Weather Effect Sensor Used Interface Wind Speed Sparkfun Magnetic Reed Switch Wind Direction Sparkfun Analog value Rain Sparkfun Magnetic Reed Switch Temperature Bosch BMP085 I2C Atmospheric Pressure Bosch BMP085 I2C Light Level SEN Photoresistor Analog value Table 1 These sensors were integrated to a TI MSP430F2272 processor, which has on chip ADC and UART modules. The code for the processor followed the block diagram shown in the figure below. Figure 4 As seen in the above block diagram, after initialization the processor idles in a low power mode waiting for interrupts, reducing the strain on the battery pack. This mode disables all clocks and on chip modules except the auxiliary clock, which is used to keep track of the timer interrupt. The length of the timer interrupt is set during initialization, when the ADC on the chip reads the state switch. The switch allows the user to choose the length of time between data transmissions, either 14 or 28 seconds, or puts the weather station in demo mode. In demo mode the 9

10 weather station sends a temperature value incrementing by 10, and a random pressure value, while the other sensors continue normal functionality. The main interrupt for this system is the timer interrupt, which compiles a fresh set of sensor readings and transmits them using the xbee module. The processor communicates with the xbee using its UART module, and a baud rate. The other interrupts service the digital inputs to the processor. Rain and wind speed increment counters, and the low battery interrupt sets a variable which is then sent to the music generator to alert the user. The processor and all of the sensors were able to run on 3.3V, simplifying some of the power supply design. As the current draw for the system was not high, I was able to use an LM317T voltage regulator to get 3.3V out of a 5.5V battery pack / 24V solar panel combo. As stated earlier, the solar panel charges the batteries and powers the system when on, while the battery pack takes over at night. This setup requires a charging circuit, which regulates the current flowing to the battery from the solar panel. The batteries used were NiMH, and they were charged using MOSFET switches for voltage detection. While the weather station design and implementation went smoothly, the music generator had hardware issues. The initial plan to use a fast TI DSP were scrapped after numerous attempts to integrate the processor to a custom board resulted in the processor permanently locking itself. In order to get some form of music by the end of the semester a backup plan was implemented, using a TI MSP430F2274. The music generator consisted of four main hardware components. The xbee transceiver fed the processor (MSP430F2274) weather data at the processors request. The processor then uses 8 of its GPIOs to control a DAC (TLC7225CDW) and the rest go to blue LED indicator lights. The output of the DAC is sent to a speaker amplifier (LM386), before being sent to the speaker. A basic block diagram for the music generator code is shown in the figure below. 10

11 Figure 5 The code for the music generator underwent many revisions, as the MSP430 was pushed to its limits. Initially the plan was to calculate the music samples spontaneously, however when the much faster DSP was abandoned a new strategy was taken. Instead of calculating music samples, the code would use the weather data to select hard coded samples of sine tones, which were stored in a header file in the array tones[14][8][61]. The music generator could select from 14 different tones, each one containing 8 variations that diminished in amplitude as an attempt at a fading effect. Each variation contained up to 61 samples of a single sine wave period. The MSP used has 32KB of flash, and running this program takes up 27KB. To improve the performance of the MSP a 16MHz external oscillator was used for the main system clock, which is the maximum the device allows. In a final attempt at optimization, once the code was completed the rate at which the music samples were played was lowered until it interfered with sample selection, which occurred around 7000Hz. The power needs for the music generator were supplied using a 24V wall wart. From this 24V source voltages of 15V, 10V, and 3.3V were regulated using LM317T 11

12 regulators. The processor required 3.3V, while the amplifier used 10V supply and the DAC used 15V as a supply and 10V as a reference. Design Procedure The design procedure for this project started with parts research and ordering, and then quickly moved into testing different weather sensors with the MSP430. Once the sensors were all working on the breadboard a PCB was designed using the class provided Altium software. At this point the weather station was put on hold and attention was turned to the music generator. A PCB was designed in Altium for the TI DSP TMS320F28335, which is the 150MHz processor used in EEL4744, and sent to Advanced Circuits to be milled. Once the board was in I figured I d be coding in no time, but this was not the case. The first chip on the board blew, even after extensive testing for shorts. The next chip locked itself, according to the JTAG programmer. After extensive internet research and calls to TI, I determined that the TMS320 has a security module that can sometimes malfunction and reset its password, which bricks the device. From here I reviewed all circuitry essential to programming the chip. Finding no problems, I assumed the problem was the chip itself, and asked for a new one. This new chip promptly locked itself during my second attempt at programming it. At this point the problem was most likely with the board I designed, however I was quickly running out of time to troubleshoot the problem. After three failed attempts at getting the DSP board up and running I moved to a new plan, as it had become April all of a sudden. This plan involved rapidly creating a PCB that used an MSP430 as the center of the music generator, and figuring out ways to increase its performance. First, the MSP was set to its maximum clock speed of 16MHz. Next the coding plan was altered to remove calculations, therefore reducing the instruction count and speeding up the processing. While waiting for the board to be milled I was able to integrate the xbee modules to two processors, therefore ensuring I would be able to transmit data wirelessly. Also during this downtime the recharging circuit was designed in Altium and submitted for milling. After the boards had been milled they were populated with their respective components, and I began finalizing the rough code that was developed earlier in the semester. Once the weather station and music generator were both functioning as separate components they were combined, and three to four days were spent debugging. 12

13 User Manual Using the WeatherSense is very simple. To turn on the weather station first select the mode you want it to be in (14 second tx, 28 second tx, demo) and then flip the power switch. The mode cannot be changed when the device is on as it s set during initialization, so if you want to change modes turn it off, change the mode, and turn it back on. The music generator is even easier to use. It has one knob that controls on/off and volume. If on, the music generator will play tones and update the LED panel continuously, even if the weather station is not on. In the event that the weather station battery goes low, an LED indicator will illuminate on the music generator main panel. Gantt Chart The Gantt chart used as a guide for this semester is shown below. No major deviations were made, and all tasks were accomplished. Project WeatherSense Spring 2013 Schedule Problem determined Research Layout Project/Order Parts PCB-Weather Station Software-Base music gen. Hardware-Assemble WS PCB-Music Generator Software-Modulations Hardware-Assemble MG Troubleshoot/Testing Presentation Figure 6 13

14 Appendix A Code Used for Weather Station #include "msp430x22x2.h" #include <msp430.h> #include "REALCODE.h" #define superdelay //worked reasonably well at volatile char Light = 3; //default, full light volatile char WndDir = 5; // default position North volatile int Temp = 0; //default volatile long int Pressure2 = 0; //default volatile char Pressure = 1; //default volatile char Demo = 0; //default, not in demo state volatile char LoBatt = 0; //default, battery not low volatile int Spd = 0; volatile int Rain = 0; volatile char demo_temps[] = {0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, 0x85, 0x95; volatile int index = 0; int main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer 14

15 initializep2(); initializep3(); initializep1flags(); // todo- > other p3 pins // todo- > see header initializeuart(); delay_cycles(1000); int* ptr; int analog[] = {0,0,0; ptr = &analog[0]; getadcdata(ptr, WndDir); Temp = analog[0]; //using temp for other purpose if (Temp == 18751) //value from defines in REALCODE.h Demo = 1; initializetimera(temp); Temp = 21; bis_sr_register(lpm3_bits + GIE); // Enter LPM3 w/interrupts // Timer A0 interrupt service routine #pragma vector=timera0_vector interrupt void Timer_A (void) { 15

16 P2OUT = 0x10; //p2.4 toggle long int Pressure1; int* ptr; int analog[] = {0,0,0; // analog[0]=freqswitch, a[1]=wnddir, a[2]=light ptr = &analog[0]; getadcdata(ptr, WndDir); WndDir = analog[1]; Light = analog[2]; unsigned int ut = 0, up = 0; ut = getrawdata(ut, 0x2E); if (Demo == 1){ Temp = demo_temps[index]; index++; if(index == 9) index = 0; else { Temp = calctemp(ut); up = getrawdata(up, 0x34); 16

17 Pressure2 = calcpress(up, ut); if (Demo == 1){ if(pressure2 > Pressure1) Pressure = 1; //pressure rising else if (Pressure2 < Pressure1) Pressure = 0; //pressure falling else Pressure = Pressure; else{ if((pressure2 >> 6) > (Pressure1 >> 6)) Pressure = 1; //pressure rising else if ((Pressure2 >> 6) < (Pressure1 >> 6)) Pressure = 0; //pressure falling else Pressure = Pressure; Pressure1 = Pressure2; if(spd >= 53) Spd = 2; else if((spd > 0) && (Spd < 53)) Spd = 1; 17

18 else Spd = 0; if(rain >= 18) Rain = 2; else if((rain > 0) && (Rain < 18)) Rain = 1; else Rain = 0; //send data over xbee xbeesend(spd, 0xF1); // delay_cycles(superdelay); // xbeesend(spd, 0xF1); // delay_cycles(superdelay); xbeesend(light, 0xF2); // delay_cycles(superdelay); // xbeesend(light, 0xF2); // delay_cycles(superdelay); xbeesend(wnddir, 0xF3); // delay_cycles(superdelay); // xbeesend(wnddir, 0xF3); // delay_cycles(superdelay); 18

19 xbeesend(rain, 0xF4); // delay_cycles(superdelay); // xbeesend(rain, 0xF4); // delay_cycles(superdelay); xbeesend(temp, 0xF5); // delay_cycles(superdelay); // xbeesend(temp, 0xF5); // delay_cycles(superdelay); xbeesend(pressure, 0xF6); // delay_cycles(superdelay); // xbeesend(pressure, 0xF6); // delay_cycles(superdelay); Rain = 0; Spd = 0; if (LoBatt == 1){ P2OUT = 0x20;// P2.5 togle xbeesend(0xff, 0xFF); P2OUT &= 0xEF; 19

20 // Port 1 interrupt service routine #pragma vector=port1_vector interrupt void Port_1(void) { if(p1ifg & (1 << 1)){ //check P1.1 flag Spd = Spd + 1; //increment WndSpd counter P1IFG &= ~0x02; //P1.1 IFG cleared else if(p1ifg & (1 << 2)){ //check P1.2 flag Rain = Rain + 1; P1IFG &= ~0x04; //P1.2 IFG cleared else if(p1ifg & (1 << 0)){ //check P1.0 flog LoBatt = 1; P1IFG &= ~0x01; //P1.0 IFG cleared else P1IFG = 0; #ifndef REALCODE_H_ 20

21 #define REALCODE_H_ #define SEC_5 #define SEC_ //12 seconds //24 seconds #define SEC_DEMO //make sure to change if statement in main code to correspond #define DELAY 1200 //declarations void xbeesend(int, int); void initializeuart(void); void getadcdata(int*, int); void send8(int, int, int, int, int, int); int read8(int, int, int, int, int, int, int, int); unsigned int getrawdata(unsigned int, int); int calctemp(unsigned int); long int calcpress(unsigned int, unsigned int); void initializep3(void); void initializeadc10(void); void initializep1flags(void); void initializetimera(int); void initializep2(void); 21

22 //functions void xbeesend(int data, int code) { UCA0TXBUF = code; delay_cycles(delay); UCA0TXBUF = code; delay_cycles(delay); UCA0TXBUF = data; delay_cycles(delay); UCA0TXBUF = data; delay_cycles(delay); void initializeuart(void) { UCA0CTL1 = UCSWRST; //set ucswrst UCA0CTL0 = 0x00; UCA0CTL1 = UCSSEL_2; //pick SMCLK UCA0BR0 = 7; //baud rate 9600 UCA0BR1 = 0x00; UCA0MCTL = 0x0F; //still baud stuff 22

23 UCA0CTL1 &= ~UCSWRST; return; void getadcdata(int* ptr, int WndDir) { ADC10CTL1 = INCH_3 + CONSEQ_1; // A3/A2/A1/A0, single sequence ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE; ADC10DTC1 = 0x04; ADC10AE0 = 0x0F; // 4 conversions // P2.3,2,1,0 ADC10 option select int i, dir; for (i = 0;i < 4;i++) { ADC10CTL0 &= ~ENC; while (ADC10CTL1 & BUSY); ADC10SA = 0x200; // Wait if ADC10 core is active // Data buffer start ADC10CTL0 = ENC + ADC10SC; // Sampling and conversion start int* data = 0; for (i = 0; i < (0x200/2); i++) data++; 23

24 i = *data; //P2.3 data++; data++; if (i >= 850) *(ptr+2) = 1; if ((i < 850) && (i > 650)) *(ptr+2) = 2; if (i <= 650) *(ptr+2) = 3; i = *data; //P2.1 data++; if ((i > 243) && (i < 305)) dir = 1; else if ((i > 596) && (i < 669)) dir = 2; else if ((i > 913) && (i < 976)) dir = 3; else if ((i > 856) && (i < 913)) dir = 4; else if ((i > 760) && (i < 830)) dir = 5; else if ((i > 439) && (i < 503)) 24

25 dir = 6; else if ((i > 62) && (i < 126)) dir = 7; else if ((i > 157) && (i < 220)) dir = 8; else dir = WndDir; *(ptr+1) = dir; i = *data; //P2.0 if ((i < 850) && (i > 300)) *(ptr) = SEC_DEMO; if (i >= 850) *(ptr) = SEC_5; if (i <= 300) *(ptr) = SEC_10; return; void send8(int data, int i, int datahi, int datalo, int clkhi, int clklo) { for (i = 7; i >= 0; i- - ){ 25

26 if(data & (1 << i)) P3OUT = datahi;//data high (3.2 hi) else P3OUT &= datalo;//data lo (3.2 lo) delay_cycles(1500); P3OUT = clkhi; //clock hi (3.3 hi) delay_cycles(3000); P3OUT &= clklo; //clock lo (data logged) delay_cycles(1500); P3DIR &= datalo; //set 3.2 to input for ack bit delay_cycles(1500); P3OUT = clkhi; //clock hi delay_cycles(3000); P3OUT &= clklo; //clock lo delay_cycles(1500); P3DIR = datahi; //return 3.2 to output return; int read8(int data, int i, int pin, int ack, int datahi, int datalo, int clkhi, int clklo) { P3DIR &= datalo; //set 3.2 to input to rx data 26

27 for (i = 7; i >= 0; i- - ){ delay_cycles(1500); P3OUT = clkhi; //clock hi delay_cycles(1500); if (P3IN & (1 << pin)) data = (1 << i); else data &= ~(1 << i); delay_cycles(1500); P3OUT &= clklo; //clock lo delay_cycles(1500); P3DIR = datahi; //return 3.2 to output if(ack == 0) P3OUT &= datalo; //set 3.2 low for ack if(ack == 1) P3OUT = datahi; //set 3.2 hi for not_ack delay_cycles(1500); P3OUT = clkhi; //clock hi delay_cycles(3000); P3OUT &= clklo; //clock lo delay_cycles(1500); return data; 27

28 unsigned int getrawdata(unsigned int u, int measstart) { int datamsb = 0; int datalsb = 0; int addrwrite = 0xEE, addrread = 0xEF, controlreg = 0xF4, reg1 = 0xF6; //start measurement delay_cycles(5000); P3OUT &= 0xFB; //set data low (3.2 low) delay_cycles(1500); P3OUT &= 0xF7; //clock low (3.3 low) **start condition delay_cycles(1500); send8(addrwrite, 7, 0x04, 0xFB, 0x08, 0xF7); send8(controlreg, 7, 0x04, 0xFB, 0x08, 0xF7); send8(measstart, 7, 0x04, 0xFB, 0x08, 0xF7); delay_cycles(1500); P3OUT = 0x08; //clock hi delay_cycles(1500); P3OUT = 0x04; //data hi **stop condition delay_cycles(100000); //measurement delay(probably too much) 28

29 //reads value back for temp or pressure delay_cycles(5000); P3OUT &= 0xFB; //set data low (3.2 low) delay_cycles(1500); P3OUT &= 0xF7; //clock low (3.3 low) delay_cycles(1500); send8(addrwrite, 7, 0x04, 0xFB, 0x08, 0xF7); send8(reg1, 7, 0x04, 0xFB, 0x08, 0xF7); P3OUT = 0x04;//data high delay_cycles(1500); P3OUT = 0x08;//clock high delay_cycles(5000); P3OUT &= 0xFB; //set data low (3.2 low) delay_cycles(1500); P3OUT &= 0xF7; //clock low (3.3 low) delay_cycles(1500); send8(addrread, 7, 0x04, 0xFB, 0x08, 0xF7); datamsb = read8(datamsb, 7, 2, 0, 0x04, 0xFB, 0x08, 0xF7); datalsb = read8(datalsb, 7, 2, 1, 0x04, 0xFB, 0x08, 0xF7); P3OUT &= 0xFB; //set data low delay_cycles(1500); P3OUT = 0x08; //clock hi 29

30 delay_cycles(3000); P3OUT = 0x04; //data hi u = datamsb << 8; u += datalsb; return u; int calctemp(unsigned int ut) { //calculate actual temp from ut unsigned int ac5 = 24541; //constants unsigned int ac6 = 25337; int mc = ; int md = 2432; long int x1,x2,b5; int temp; x1 = (((long)ut - (long)ac6) * (long)ac5) >> 15; x2 = ((long)mc << 11)/(x1 + md); b5 = x1 + x2; temp = ((b5 + 8) >> 4); 30

31 temp = temp * 1.8; //celcius to f temp += 320; int formattedmsb, formattedlsb; formattedmsb = temp/100; formattedmsb = formattedmsb << 4; temp = temp/10; for(formattedlsb = 0; formattedlsb <= 10; formattedlsb++) { if((temp == 10) (temp == 20) (temp == 30) (temp == 40) (temp == 50) (temp == 60) (temp == 70) (temp == 80) (temp == 90)) break; temp- - ; if(formattedlsb == 10) formattedlsb = 5; formattedmsb = formattedmsb + formattedlsb; return formattedmsb; long int calcpress(unsigned int up, unsigned int ut) { //calculate actual pressure from up 31

32 //constants int ac1 = 7073, ac2 = , ac3 = , b1 = 5498, b2 = 61, mc = , md = 2432; unsigned int ac4 = 33648, ac5 = 24541, ac6 = 25337; //int pressure; long int x1, x2, x3, b3, b5, b6, p = 0; unsigned long int b4, b7; int OSS = 0; x1 = (((long)ut - (long)ac6) * (long)ac5) >> 15; x2 = ((long)mc << 11)/(x1 + md); b5 = x1 + x2; b6 = b5-4000; x1 = (b2 * ((b6 * b6) >> 12) >> 11); x2 = (ac2 * b6) >> 11; x3 = x1 + x2; b3 = (((((long)ac1) * 4 + x3) << OSS) + 2) >> 2; x1 = (ac3 * b6)>>13; x2 = (b1 * ((b6 * b6)>>12))>>16; 32

33 x3 = ((x1 + x2) + 2)>>2; b4 = (ac4 * (unsigned long)(x ))>>15; b7 = ((unsigned long)(up - b3) * (50000>>OSS)); if (b7 < 0x ) p = (b7<<1)/b4; else p = (b7/b4)<<1; x1 = (p>>8) * (p>>8); x1 = (x1 * 3038)>>16; x2 = ( * p)>>16; p += (x1 + x )>>4; return p; void initializep3(void) { P3SEL = 0x10; P3DIR = 0x1C; //set 3.4 output, 3.3 output, 3.2 output P3OUT = 0x1C; //set all pins high, default return; 33

34 void initializeadc10(void) { ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE; //ADC10ON, interrupt enabled ADC10AE0 = 0x0F; //P2.0- P2.3 enabled as analog input return; void initializep1flags(void) expand to init other interrupts // todo - > { P1IE = 0x07; // P1.0(LoBattery) P1.1(WndSpd) P1.2(Rain) interrupts enabled P1IES = 0x07; // Falling edge P1.0 P1.1 P1.2 P1IFG &= ~0x07; // P1.0/P1.1/P1.2 IFG cleared return; void initializetimera(int timer) { BCSCTL1 &= 0xBF; BCSCTL3 = LFXT1S_2; TACCTL0 = CCIE; //TACCR0 interrupt enabled TACCR0 = timer; //5s or 10s between firing 34

35 TACTL = TASSEL_1 + MC_1 + ID_3; //ACLK, upmode (restarts every TACCR0) return; void initializep2(void) { P2DIR = 0xB0; //set GPIOs for P2 (use all) P2OUT = 0xB0; //initially light the 2 LEDs for powerup, xbee out high delay_cycles(650000); P2OUT &= 0xCF; //lights back out return; // ADC10 interrupt service routine #pragma vector=adc10_vector interrupt void ADC10_ISR(void) { bic_sr_register_on_exit(cpuoff); // Clear CPUOFF bit from 0(SR) #endif /*REALCODE_H_*/ 35

36 Appendix B Code Used for Music Generator #include "msp430x22x2.h" #include "IMPORTANTSTUFF.h" #include "IMPORTANTDATA.h" #include "intrinsics.h" #define MAX_TONES 9 #define timer 400 //same as below #define fade0 600 //needs to be calibrated with timer and #fade samples #define fade //same as above #define theme //same as above (14s@70000) #define theme //same as above (20s@100000) #define delay 8000 //the space after loc that ensures no other never changes should change //tone will be placed too close, //currently equals stop, but typedef volatile struct { int index1;//specifies the tone played from the tones data int index2;//specifies which variation of tone is played int index3;//specifies the sample being played 36

37 int index4;//related to index1, its when index3 should reset int state;//0 means not playing, 1 means playing long int loc; playing long int stop; by WndSpd long int prestop; overloading DAC long int fade; //defines the point in the sample that the tone starts //defines point to stop playing tone //value set when initializing tone, varied //point where another tone could be played w/o //spot in theme to start playing the 1st fade buffer int repeat; //varies based on temp, defines how many times tone's played tone; int main(){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer //vars for timing & mechanics char select = 0x0F; char filled = 0; int SAMP1 = 0; int SAMP2 = 0; long int cnt = 0; //value to compare theme to int k = 0; //needs to be int 37

38 int st = 0; //vars for selecting new tones int l = 0; long int testloc = 0; long int testprestop = 0; long int teststop = 0; int spaceok = 1; // char dir = 0;//direction to attempt to pick a new tone from // char tries = 2; // int temp = 0; //vars affected by weather data/for modulations long int theme = 1;//it will be a very short first theme int Fade = fade1; //two options, set by WndDir, 0 is default char shifts = 0; //used for speedup mod tone song[max_tones];//stores all tones the theme can have for(k=0; k<max_tones; k++){//initializes important values so tone doesn't randomly play song[k].loc = theme1+1; song[k].state = 0; song[k].prestop = theme1+2; 38

39 song[k].repeat = 0; //get started init_stuff(); //initialize P4 for output, timer for samples while(1){//endless loop for generating tones //***************************************************UPDATING SETTINGS, not timed********** new data if(cnt == theme){//this is where you pause timer, add new tones, read TACCR0 = 0; //stop timer cnt = 0;//restart theme //read xbee, update values & LEDs xbee2led(); updateled(); // xbeetest(); //update theme length by WndSpd if(wndspds == 0){//locks theme length when its being altered if(pressures == 0) theme length theme = theme0; //pressure falling, shorter else 39

40 theme = theme1; //updating/disabling any tones that have run their course for(k=0; k<max_tones; k++){ if(song[k].repeat > 1)//mechanics song[k].repeat- - ; else{ range song[k].loc = theme1+1; //repeat=0, put it out of song[k].prestop = theme1+2; song[k].stop = theme1+3; song[k].state = 0; song[k].repeat = 0; l++; disable it range if(song[k].stop > theme){ //tone is playing out of range, song[k].loc = theme1+1; //repeat=0, put it out of song[k].prestop = theme1+2; song[k].stop = theme1+3; song[k].state = 0; song[k].repeat = 0; 40

41 if(l == 0) ;//there's no room in song[] for a new tone else{//there is room, add a tone l = 0;//reset for next time be checked testloc = getlocation();//returns start value that must testprestop = testloc + delay; teststop = testloc + (Fade*8); spaceok = 1; for(k=0; k<max_tones; k++){ song[k].prestop)) if((testloc >= song[k].loc)&&(testloc <= spaceok = 0; song[k].prestop)) if((testprestop >= song[k].loc)&&(testloc <= spaceok = 0; if((testloc < 0) (teststop >= theme)) spaceok = 0; if((spaceok == 1)&&(WndSpds == 0)){ //if entering this, testloc and testprestop are valid break to find correct entry spot for(k=0; k<max_tones; k++){//do for loop with 41

42 if(song[k].repeat == 0) break; //k now the correct index to use in song[] major minor decided here many repeats song[k].index1 = getfrequency(); //randomish, song[k].repeat = Temps; //temp decides how song[k].index2 = 0; song[k].index3 = 0; song[k].index4 = tonesindex[song[k].index1]; song[k].loc = testloc; song[k].state = 0; song[k].prestop = testprestop; song[k].fade = testloc; song[k].stop = testloc + (Fade*8); if(wndspds == 1){ song[k].loc = song[k].loc >> 1; song[k].prestop = song[k].prestop >> 1; song[k].stop = song[k].stop >> 1; song[k].fade = song[k].fade >> 1; if(wndspds == 2){ song[k].loc = song[k].loc >> 2; song[k].prestop = song[k].prestop >> 2; 42

43 //hopefully added a tone song[k].stop = song[k].stop >> 2; song[k].fade = song[k].fade >> 2; //do other modulations(ie speedup)//probably need to update fade before this point //Speedup Modulation, locks adding new tone, theme length change, Fade change //when WndSpds!= 0, to avoid confusion if(wndspds!= Prev_WndSpds){ //possible values, 0,1,2 if((wndspds == 1)&&(Prev_WndSpds == 0)){ //0- >1 shifts = 1;//shift right 1 (divide by 2) for(k=0;k<max_tones;k++){ song[k].loc = song[k].loc >> shifts; shifts; song[k].prestop = song[k].prestop >> song[k].stop = song[k].stop >> shifts; song[k].fade = song[k].fade >> shifts; Fade = Fade >> shifts; theme = theme >> shifts; 43

44 >2 else if((wndspds == 2)&&(Prev_WndSpds == 0)){ //0- shifts = 2;//shift right 2 (divide by 4) for(k=0;k<max_tones;k++){ song[k].loc = song[k].loc >> shifts; shifts; song[k].prestop = song[k].prestop >> song[k].stop = song[k].stop >> shifts; song[k].fade = song[k].fade >> shifts; Fade = Fade >> shifts; theme = theme >> shifts; >0 have problems? else if((wndspds == 0)&&(Prev_WndSpds == 1)){ //1- shifts = 1;//shift left 1 (multiply by 2) might for(k=0;k<max_tones;k++){ song[k].loc = song[k].loc << shifts; shifts; song[k].prestop = song[k].prestop << song[k].stop = song[k].stop << shifts; song[k].fade = song[k].fade << shifts; Fade = Fade << shifts; 44

45 >2 else if((wndspds == 2)&&(Prev_WndSpds == 1)){ //1- shifts = 1;//shift right 1 (div 2) for(k=0;k<max_tones;k++){ song[k].loc = song[k].loc >> shifts; shifts; song[k].prestop = song[k].prestop >> song[k].stop = song[k].stop >> shifts; song[k].fade = song[k].fade >> shifts; Fade = Fade >> shifts; theme = theme >> shifts; >0 else if((wndspds == 0)&&(Prev_WndSpds == 2)){ //2- shifts = 2;//shift left 2 (mult 4) for(k=0;k<max_tones;k++){ song[k].loc = song[k].loc << shifts; shifts; song[k].prestop = song[k].prestop << song[k].stop = song[k].stop << shifts; song[k].fade = song[k].fade << shifts; Fade = Fade << shifts; 45

46 >1 else if((wndspds == 1)&&(Prev_WndSpds == 2)){ //2- shifts = 1;//shift left 1 (mult 2) for(k=0;k<max_tones;k++){ song[k].loc = song[k].loc << shifts; shifts; song[k].prestop = song[k].prestop << song[k].stop = song[k].stop << shifts; song[k].fade = song[k].fade << shifts; Fade = Fade << shifts; theme = theme << shifts; Prev_WndSpds = WndSpds; shifts = 0; (jerk) //Fade modulation, disabled when WndSpd is altering things if(wndspds == 0){ if((wnddirs == 3) (WndDirs == 7)) Fade = fade1; else Fade = fade0; //update stop values for active tones 46

47 for(k=0;k<max_tones;k++){ if(song[k].stop <= theme)//filter to active tones song[k].stop = song[k].loc + (Fade*8); //Echo modulation, disabled when WndSpd is altering things if(wndspds == 0){ if(rains!= Prev_Rains){//echo time length to each for echo if((rains!= 0)&&(Prev_Rains == 0)){//add for(k=0;k<max_tones;k++){ if(song[k].repeat!= 0){ song[k].stop += (Fade*4); song[k].stop; song[k].prestop = else if((rains == 0)&&(Prev_Rains!= 1)){ for(k=0;k<max_tones;k++){ if(song[k].repeat!= 0){ song[k].stop - = (Fade*4); song[k].stop; song[k].prestop = 47

48 Prev_Rains = Rains; //test chirp, to indicate starting theme again // for(k=0; k<1000; k++){ // P4OUT = 0; // delay_cycles(1000); // P4OUT = 127; // delay_cycles(1000); // TACCR0 = timer; //start timer again TACCTL0 &= 0xFE; TAR = 0; //*******************************************Playback section******************************** else if((select == 0x0F) && (filled == 0)){//fill SAMP2 for(k=0; k<max_tones; k++){ if(song[k].loc == cnt){ 48

49 song[k].state = 1; song[k].fade += Fade; if(song[k].state == 1){//should be playing if(song[k].fade == cnt){ song[k].index2++; song[k].fade += Fade; if((rains == 1)&&(song[k].index2 == 7)){ song[k].index2 == 5; SAMP2 += tones[song[k].index1][song[k].index2][song[k].index3]; st = 1; song[k].index3++; if(song[k].index3 == song[k].index4) song[k].index3 = 0; if(song[k].stop == cnt){ song[k].state = 0; song[k].index2 = 0; 49

50 song[k].index3 = 0; song[k].fade = song[k].loc; if(st == 1){ st = 0; SAMP2 += 127; else SAMP2 = 127; filled = 1; else if((select == 0xF0) && (filled == 0)){//fill SAMP1 for(k=0; k<max_tones; k++){ if(song[k].loc == cnt){ song[k].state = 1; song[k].fade += Fade; if(song[k].state == 1){//should be playing if(song[k].fade == cnt){ song[k].index2++; song[k].fade += Fade; 50

51 if((rains == 1)&&(song[k].index2 == 7)){ song[k].index2 == 5; SAMP1 += tones[song[k].index1][song[k].index2][song[k].index3]; st = 1; song[k].index3++; if(song[k].index3 == song[k].index4) song[k].index3 = 0; if(song[k].stop == cnt){ song[k].state = 0; song[k].index2 = 0; song[k].index3 = 0; song[k].fade = song[k].loc; if(st == 1){ st = 0; SAMP1 += 127; 51

52 else filled = 1; SAMP1 = 127; //**************************************************TIMER stuff*************************** else{ if((1<<0)&tacctl0){ //interrupt flag was raised if(select == 0x0F){ else { P4OUT = SAMP1;//should be P4OUT SAMP1 = 0; P4OUT = SAMP2;//should be P4OUT SAMP2 = 0; select = ~select; filled = 0; cnt++; TACCTL0 &= 0xFE; TAR = 0; 52

53 #include "stdlib.h" #include "time.h" #ifndef IMPORTANTSTUFF_H_ #define IMPORTANTSTUFF_H_ volatile unsigned int i; //weather data volatile char readval; volatile char zeros; volatile char WndSpds; volatile char Prev_WndSpds; volatile char Pressures; volatile char Rains; volatile char Prev_Rains; volatile char Lights; volatile char WndDirs; volatile char Temps; volatile char LoBatts; 53

54 const long int seed[8] = {58300,0,11660,5900,40000,21000,30000,35000; volatile int seedindex = 0; volatile int freqindex = 0; //must change Index resets if changing length of these arrays (look for ***) const int alter[11] = {111,321,432,543,654,765,132,987,2000,5000,13; //function declarations int getfrequency(void); long int getlocation(void); void init_stuff(void); void updateled(void); void xbeeread(void); void xbeetest(void); void xbee2led(void); //functions int getfrequency(void){ int val; val = freqindex; freqindex += 3; 54

55 if(freqindex > 9) freqindex - = 10; if(lights!= 3){ return val; if(val == 2) val = 10; else if(val == 4) val = 11; else if(val == 7) val = 12; else if(val == 9) val = 13; long int getlocation(void){ long int val; val = seed[seedindex]; seedindex++; if(seedindex == 8) //*********** seedindex = 0; return val; 55

56 void init_stuff(void){ P4DIR = 0xFF; P4OUT = 127; //set GPIOs for P4 //considered '0' P3SEL = 0x20;//P3.5 configured to UCA0RXD P3DIR = 0xFF;//Configure the rest as outputs P3OUT = 0xFF;//specifically set P3.4 high, it controls the data flow, low true P1DIR = 0xFF; P2DIR = 0xFF; P1OUT = 0xFF; P2OUT = 0xFF; delay_cycles( ); P1OUT = 0; P2OUT = 0; P3OUT &= 0x10;//leave P3.4 high, it has a greater purpose BCSCTL1 = XTS; //HF mode selected BCSCTL3 = LFXT1S_2; //3-16Mhz crystal specified (differs from ex code) do { IFG1 &= ~OFIFG; //clear OSCFault flag 56

57 for (i = 0xFF; i > 0; i- - ); //time for flag to set while (IFG1 & OFIFG); //OSCFault flag still set? code) BCSCTL2 = 0xCE; //MCLK = LFXT1, SMCLK = LFXT1/8 (safe, differs from ex UCA0CTL1 = UCSWRST; //set ucswrst UCA0CTL0 = 0x00; UCA0CTL1 = UCSSEL_2; //pick SMCLK, 2MHz...i think UCA0BR0 = 0x0C; //baud rate 9600 UCA0BR1 = 0x00; UCA0MCTL = 0xF1; //still baud stuff UCA0CTL1 &= ~UCSWRST; //0xFE; //clear ucswrst, starts uart readval = 0; zeros = 0; WndSpds = 0; Prev_WndSpds = 0; Pressures = 0; Rains = 0; Prev_Rains = 0; Lights = 3; WndDirs = 4; 57

58 Temps = 3; LoBatts = 0; TACCTL0 = CCIE; //TACCR0 interrupt enabled TACCR0 = 400; //currently this value doesn't matter, the sample determination takes too long TACTL = TASSEL_2 + MC_1;//SMCLK(should be 2MHz), upmode (restarts every TACCR0) return; void updateled(void) { if(wndspds>0) P1OUT = 0x40;//P1.6 else if(wndspds==0) P1OUT &= 0xBF; if(pressures==1) P2OUT = 0x08;//P2.3 else if(pressures==0) P2OUT &= 0xF7; if(rains == 1){ 58

59 P2OUT = 0x10; //P2.4 P1OUT &= 0x7F; else if(rains == 2){ P2OUT = 0x10; P1OUT = 0x80;//P1.7 else if(rains == 0){ P2OUT &= 0xEF; P1OUT &= 0x7F; if(lights < 3) P2OUT = 0x20; //P2.5 else if(lights == 3) P2OUT &= 0xDF; if((wnddirs == 1) (WndDirs == 2) (WndDirs == 8)){ P1OUT = 0x10; //P1.4 P1OUT &= 0xD3; else if(wnddirs == 3){ P1OUT = 0x20; //P1.5 P1OUT &= 0xE3; else if((wnddirs == 4) (WndDirs == 5) (WndDirs == 6)){ P1OUT = 0x04; //P1.2 P1OUT &= 0xC7; 59

60 else if(wnddirs == 7){ P1OUT = 0x08; //P1.3 P1OUT &= 0xCB; if(lobatts == 0xFF) off P1OUT = 0x02; //P1.1 on, no turn of mechanism, must turn hardware //to reset if(temps < 1){ P3OUT &= 0x30; P2OUT &= 0xF8; else if(temps == 1){ P3OUT = 0x08; //P3.3 P3OUT &= 0x38; P2OUT &= 0xF8; else if(temps == 2){ P3OUT = 0x0C; //P3.3,P3.2 P3OUT &= 0x3C; P2OUT &= 0xF8; else if(temps == 3){ P3OUT = 0x0E; //P3.3,3.2,3.1 P3OUT &= 0x3E; 60

61 P2OUT &= 0xF8; else if(temps == 4){ P3OUT = 0x4E; //add 3.6 P3OUT &= 0x7E; P2OUT &= 0xF8; else if(temps == 5){ P3OUT = 0x4F; //add 3.0 P3OUT &= 0x7F; P2OUT &= 0xF8; else if(temps == 6){ P3OUT = 0xCF; //add 3.7 P2OUT &= 0xF8; else if(temps == 7){ P3OUT = 0xCF; P2OUT = 0x04; //add 2.2 P2OUT &= 0xFC; else if(temps == 8){ P3OUT = 0xCF; P2OUT = 0x06; //add 2.1 P2OUT &= 0xFE; else if(temps > 8){ P3OUT = 0xCF; P2OUT = 0x07; //add

62 return; void xbeeread(void){ zeros = 0; while(zeros < 2){ //this loop will break if 2 consecutive 0s are read delay_cycles(11500); P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); readval = UCA0RXBUF; delay_cycles(11500); if(readval == 0xF1){ //Wind Speed P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); WndSpds = UCA0RXBUF; zeros = 0; 62

63 else if(readval == 0xF6){ //Pressure P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); Pressures = UCA0RXBUF; zeros = 0; else if(readval == 0xF4){ //Rain P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); Rains = UCA0RXBUF; zeros = 0; else if(readval == 0xF2){ //Light P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); Lights = UCA0RXBUF; zeros = 0; 63

64 else if(readval == 0xF3){ //Wind Direction P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); WndDirs = UCA0RXBUF; zeros = 0; else if(readval == 0xFF){ //LoBatt P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); LoBatts = UCA0RXBUF; zeros = 0; else if(readval == 0xF5){ //Temperature P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); Temps = UCA0RXBUF; 64

65 return; Temps = Temps >> 4; zeros = 0; else if(readval == 0) zeros++; void xbeetest(void){ int xbeejunk[100]; int m; for(m=0;m<100;m++){ delay_cycles(11500); P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); xbeejunk[m] = UCA0RXBUF; return; 65

66 void xbee2led(void){ zeros = 0; while(zeros < 150){ //this loop will break if 2 consecutive 0s are read delay_cycles(11500); P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); readval = UCA0RXBUF; delay_cycles(11500); if(readval == 0xF1){ //Wind Speed P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); WndSpds = UCA0RXBUF; if(wndspds>0) P1OUT = 0x40;//P1.6 else if(wndspds==0) //zeros = 0; P1OUT &= 0xBF; 66

67 else if(readval == 0xF6){ //Pressure P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); Pressures = UCA0RXBUF; if(pressures==1) P2OUT = 0x08;//P2.3 else if(pressures==0) //zeros = 0; P2OUT &= 0xF7; else if(readval == 0xF4){ //Rain P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); Rains = UCA0RXBUF; if(rains == 1){ P2OUT = 0x10; //P2.4 P1OUT &= 0x7F; else if(rains == 2){ P2OUT = 0x10; 67

68 P1OUT = 0x80;//P1.7 else if(rains == 0){ //zeros = 0; P2OUT &= 0xEF; P1OUT &= 0x7F; else if(readval == 0xF2){ //Light P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); Lights = UCA0RXBUF; if(lights < 3) P2OUT = 0x20; //P2.5 else if(lights == 3) //zeros = 0; P2OUT &= 0xDF; else if(readval == 0xF3){ //Wind Direction P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); 68

69 WndDirs = UCA0RXBUF; if((wnddirs == 1) (WndDirs == 2) (WndDirs == 8)){ P1OUT = 0x10; //P1.4 P1OUT &= 0xD3; else if(wnddirs == 3){ P1OUT = 0x20; //P1.5 P1OUT &= 0xE3; else if((wnddirs == 4) (WndDirs == 5) (WndDirs == 6)){ P1OUT = 0x04; //P1.2 P1OUT &= 0xC7; else if(wnddirs == 7){ //zeros = 0; P1OUT = 0x08; //P1.3 P1OUT &= 0xCB; else if(readval == 0xFF){ //LoBatt P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); readval = UCA0RXBUF; if(readval == 0xFF) turn hardware off P1OUT = 0x02; //P1.1 on, no turn of mechanism, must 69

70 //zeros = 0; //to reset else if(readval == 0xF5){ //Temperature P3OUT &= 0xEF;//initiate data transfer delay_cycles(11500); P3OUT = 0x10;//back to high delay_cycles(11500); Temps = UCA0RXBUF; Temps = Temps >> 4; if(temps < 1){ P3OUT &= 0x30; P2OUT &= 0xF8; else if(temps == 1){ P3OUT = 0x08; //P3.3 P3OUT &= 0x38; P2OUT &= 0xF8; else if(temps == 2){ P3OUT = 0x0C; //P3.3,P3.2 P3OUT &= 0x3C; P2OUT &= 0xF8; else if(temps == 3){ P3OUT = 0x0E; //P3.3,3.2,3.1 P3OUT &= 0x3E; 70

71 P2OUT &= 0xF8; else if(temps == 4){ P3OUT = 0x4E; //add 3.6 P3OUT &= 0x7E; P2OUT &= 0xF8; else if(temps == 5){ P3OUT = 0x4F; //add 3.0 P3OUT &= 0x7F; P2OUT &= 0xF8; else if(temps == 6){ P3OUT = 0xCF; //add 3.7 P2OUT &= 0xF8; else if(temps == 7){ P3OUT = 0xCF; P2OUT = 0x04; //add 2.2 P2OUT &= 0xFC; else if(temps == 8){ P3OUT = 0xCF; P2OUT = 0x06; //add 2.1 P2OUT &= 0xFE; else if(temps > 8){ P3OUT = 0xCF; P2OUT = 0x07; //add

72 //zeros = 0; zeros++; return; #endif /*IMPORTANTSTUFF_H_*/ #ifndef IMPORTANTDATA_H_ #define IMPORTANTDATA_H_ const int tones[14][8][62] = { { //C Hz, y = 100*sin(2*pi* *t/16384), t = 0,1,2,Ö 7,59, 96,- 98, 16, {0,10,20,30,39,48,57,65,72,79,84,89,93,96,99,100,100,99,97,94,91,86,80,74,6 51,42,33,23,13,3,- 7,- 17,- 27,- 36,- 45,- 54,- 62,- 70,- 77,- 83,- 88,- 92, ,- 100,- 99,- 98,- 95,- 92,- 88,- 82,- 76,- 69,- 62,- 53,- 45,- 36,- 26,- 1,44, {0,9,17,26,34,41,49,56,62,68,73,77,81,83,85,86,86,85,84,81,78,74,69,64,58,5 72

73 82,- 85,- 86, 36,28,20,11,3,- 6,- 15,- 23,- 31,- 39,- 47,- 54,- 60,- 66,- 71,- 76,- 80,- - 86,- 86,- 84,- 82,- 79,- 76,- 71,- 66,- 60,- 53,- 46,- 39,- 31,- 22,- 14, 4,38, {0,7,15,22,29,36,42,48,53,58,62,66,69,71,73,74,74,73,72,70,67,63,59,55,49,4 71,- 72,- 74, 31,24,17,10,2,- 5,- 12,- 20,- 27,- 33,- 40,- 46,- 51,- 57,- 61,- 65,- 68,- - 74,- 73,- 72,- 70,- 68,- 65,- 61,- 56,- 51,- 46,- 39,- 33,- 26,- 19,- 12, 6,31, 60,- 60, {0,6,12,18,24,29,34,39,44,48,51,54,57,59,60,61,61,60,59,57,55,52,49,45,41,3 25,20,14,8,2,- 4,- 10,- 16,- 22,- 28,- 33,- 38,- 42,- 47,- 50,- 53,- 56,- 58,- - 61,- 60,- 60,- 58,- 56,- 53,- 50,- 46,- 42,- 37,- 33,- 27,- 22,- 16,- 10, 8,24, 47,- 48, {0,5,10,14,19,23,27,31,34,38,40,43,45,46,47,48,48,47,47,45,43,41,38,35,32,2 20,16,11,6,1,- 3,- 8,- 13,- 17,- 22,- 26,- 30,- 33,- 37,- 40,- 42,- 44,- 46,- - 48,- 48,- 47,- 46,- 44,- 42,- 39,- 36,- 33,- 30,- 26,- 21,- 17,- 12,- 8, 18, 35,- 35, {0,3,7,10,14,17,20,23,25,27,29,31,33,34,34,35,35,35,34,33,32,30,28,26,23,21, 15,11,8,5,1,- 2,- 6,- 9,- 13,- 16,- 19,- 22,- 24,- 27,- 29,- 31,- 32,- 33,- 34,- - 35,- 34,- 33,- 32,- 31,- 29,- 27,- 24,- 22,- 19,- 16,- 12,- 9,- 6,,9, {0,2,4,7,9,11,12,14,16,17,19,20,20,21,22,22,22,22,21,21,20,19,18,16,15,13,11 73

74 22,- 22, 7,5,3,1,- 2,- 4,- 6,- 8,- 10,- 12,- 14,- 15,- 17,- 18,- 19,- 20,- 21,- 22,- 22,- - 22,- 21,- 20,- 19,- 18,- 17,- 15,- 14,- 12,- 10,- 8,- 6,- 4, 4, {0,1,2,3,4,4,5,6,6,7,8,8,8,9,9,9,9,9,9,9,8,8,7,7,6,5,5,4,3,2,1,0,- 1,- 2,- 2,- 3,- - 5,- 6,- 6,- 7,- 7,- 8,- 8,- 9,- 9,- 9,- 9,- 9,- 9,- 9,- 8,- 8,- 7,- 7,- 6,- 6,- 5,- 4,- 3,- 2, - 1, { //D Hz, same formula as above {0,11,22,33,44,53,63,71,78,85,90,95,98,99,100,99,97,94,90,84,78,70,62,52,42,32, 21,10,- 1,- 12,- 23,- 34,- 45,- 54,- 63,- 72,- 79,- 85,- 91,- 95,- 98,- 100,- 100,- 99, - 97,- 94,- 89,- 84,- 77,- 69,- 61,- 51,- 41,- 31,- 20,- 9,0,0,0,0,0,0, {0,10,19,29,38,46,54,61,68,73,78,82,84,86,86,86,84,81,77,73,67,60,53,45,37,28, 18,9,- 1,- 11,- 20,- 30,- 38,- 47,- 55,- 62,- 68,- 74,- 78,- 82,- 84,- 86,- 86,- 86,- 84,- 81, - 77,- 72,- 66,- 60,- 52,- 44,- 36,- 27,- 17,- 8,0,0,0,0,0,0, {0,8,16,24,32,39,46,52,58,63,67,70,72,73,74,73,72,70,66,62,57,52,46,39,31,24, 16,7,- 1,- 9,- 17,- 25,- 33,- 40,- 47,- 53,- 58,- 63,- 67,- 70,- 72,- 74,- 74,- 73,- 72,- 69, - 66,- 62,- 57,- 51,- 45,- 38,- 31,- 23,- 15,- 7,0,0,0,0,0,0, {0,7,14,20,26,32,38,43,48,52,55,57,59,60,61,60,59,57,55,51,47,43,37,32,26,19, 13,6,- 1,- 8,- 14,- 21,- 27,- 33,- 39,- 44,- 48,- 52,- 55,- 58,- 59,- 61,- 61,- 60,- 59,- 57, - 54,- 51,- 47,- 42,- 37,- 31,- 25,- 19,- 12,- 5,0,0,0,0,0,0, {0,5,11,16,21,26,30,34,38,41,43,45,47,48,48,48,47,45,43,40,37,34,29,25,20,15, 10,5,- 1,- 6,- 11,- 16,- 21,- 26,- 30,- 34,- 38,- 41,- 43,- 45,- 47,- 48,- 48,- 47,- 46,- 45, 74

75 - 43,- 40,- 37,- 33,- 29,- 25,- 20,- 15,- 10,- 4,0,0,0,0,0,0, {0,4,8,12,15,19,22,25,27,30,32,33,34,35,35,35,34,33,31,29,27,24,22,18,15,11, 7,4,0,- 4,- 8,- 12,- 16,- 19,- 22,- 25,- 28,- 30,- 32,- 33,- 34,- 35,- 35,- 35,- 34,- 33, - 31,- 29,- 27,- 24,- 21,- 18,- 14,- 11,- 7,- 3,0,0,0,0,0,0, {0,2,5,7,10,12,14,16,17,19,20,21,21,22,22,22,21,21,20,19,17,15,14,12,9,7, 5,2,0,- 3,- 5,- 8,- 10,- 12,- 14,- 16,- 17,- 19,- 20,- 21,- 21,- 22,- 22,- 22,- 21,- 21, - 20,- 18,- 17,- 15,- 13,- 11,- 9,- 7,- 4,- 2,0,0,0,0,0,0, {0,1,2,3,4,5,6,6,7,8,8,9,9,9,9,9,9,8,8,8,7,6,6,5,4,3, 2,1,0,- 1,- 2,- 3,- 4,- 5,- 6,- 6,- 7,- 8,- 8,- 9,- 9,- 9,- 9,- 9,- 9,- 8, - 8,- 8,- 7,- 6,- 5,- 5,- 4,- 3,- 2,- 1,0,0,0,0,0,0, { //E Hz, same as above 2, {0,13,25,37,48,59,69,77,85,91,95,98,100,100,98,95,90,84,76,67,58,47,35,23,11,- - 14,- 27,- 39,- 50,- 61,- 70,- 79,- 86,- 92,- 96,- 99,- 100,- 100,- 98,- 94,- 89,- 83, - 75,- 66,- 56,- 45,- 34,- 21,- 9,0,0,0,0,0,0,0,0,0,0,0,0, {0,11,22,32,42,51,59,67,73,78,82,85,86,86,85,82,78,72,66,58,50,40,30,20,9,- 2, - 12,- 23,- 33,- 43,- 52,- 60,- 68,- 74,- 79,- 83,- 85,- 86,- 86,- 84,- 81,- 77,- 71,- 65, - 57,- 48,- 39,- 29,- 18,- 8,0,0,0,0,0,0,0,0,0,0,0,0, {0,9,18,27,36,44,51,57,63,67,70,73,74,74,72,70,66,62,56,50,43,35,26,17,8,- 1, - 11,- 20,- 29,- 37,- 45,- 52,- 58,- 63,- 68,- 71,- 73,- 74,- 74,- 72,- 70,- 66,- 61,- 55, - 49,- 41,- 33,- 25,- 16,- 7,0,0,0,0,0,0,0,0,0,0,0,0, 75

// Conditions for 9600/4=2400 Baud SW UART, SMCLK = 1MHz #define Bitime_5 0x05*4 // ~ 0.5 bit length + small adjustment #define Bitime 13*4//0x0D

// Conditions for 9600/4=2400 Baud SW UART, SMCLK = 1MHz #define Bitime_5 0x05*4 // ~ 0.5 bit length + small adjustment #define Bitime 13*4//0x0D /****************************************************************************** * * * 1. Device starts up in LPM3 + blinking LED to indicate device is alive * + Upon first button press, device transitions

More information

2.996/6.971 Biomedical Devices Design Laboratory Lecture 6: Microprocessors II

2.996/6.971 Biomedical Devices Design Laboratory Lecture 6: Microprocessors II 2.996/6.971 Biomedical Devices Design Laboratory Lecture 6: Microprocessors II Instructor: Dr. Hong Ma Oct. 1, 2007 Structure of MSP430 Program 1. Declarations 2. main() 1. Watch-dog timer servicing 2.

More information

CPE 325: Embedded Systems Laboratory Laboratory #11 Tutorial Analog-to-Digital Converter and Digital-to-Analog Converter

CPE 325: Embedded Systems Laboratory Laboratory #11 Tutorial Analog-to-Digital Converter and Digital-to-Analog Converter CPE 325: Embedded Systems Laboratory Laboratory #11 Tutorial Analog-to-Digital Converter and Digital-to-Analog Converter Aleksandar Milenković Email: milenka@uah.edu Web: http://www.ece.uah.edu/~milenka

More information

Texas Instruments Mixed Signal Processor Tutorial Abstract

Texas Instruments Mixed Signal Processor Tutorial Abstract Texas Instruments Mixed Signal Processor Tutorial Abstract This tutorial goes through the process of writing a program that uses buttons to manipulate LEDs. One LED will be hard connected to the output

More information

Timers and Clocks CS4101 嵌入式系統概論. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

Timers and Clocks CS4101 嵌入式系統概論. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan CS4101 嵌入式系統概論 Timers and Clocks Prof. Chung-Ta King Department of Computer Science, Taiwan Materials from MSP430 Microcontroller Basics, John H. Davies, Newnes, 2008 Recall the Container Thermometer Container

More information

Name: Clint Furrer Project Number: TI003 Project Description: Safety Walking Lights. Description:

Name: Clint Furrer Project Number: TI003 Project Description: Safety Walking Lights. Description: Description: This project addresses the concern and problem of pedestrians walking with automotive traffic. I walk to and from a bus stop every morning and evening for work. There is usually low light

More information

Interfacing CMR3000-D01 to an MSP430 ultra low-power microcontroller

Interfacing CMR3000-D01 to an MSP430 ultra low-power microcontroller Interfacing CMR3000-D01 to an MSP430 ultra low-power microcontroller 1 INTRODUCTION The objective of this document is to show how to set up SPI/I2C communication between VTI Technologies CMR3000-D01 digital

More information

Lab 4: Interrupt. CS4101 Introduction to Embedded Systems. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

Lab 4: Interrupt. CS4101 Introduction to Embedded Systems. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan CS4101 Introduction to Embedded Systems Lab 4: Interrupt Prof. Chung-Ta King Department of Computer Science, Taiwan Introduction In this lab, we will learn interrupts of MSP430 Handling interrupts in MSP430

More information

Interrupts, Low Power Modes

Interrupts, Low Power Modes Interrupts, Low Power Modes Registers Status Register Interrupts (Chapter 6 in text) A computer has 2 basic ways to react to inputs: 1) polling: The processor regularly looks at the input and reacts as

More information

Lecture 5: MSP430 Interrupt

Lecture 5: MSP430 Interrupt ECE342 Intro. to Embedded Systems Lecture 5: MSP430 Interrupt Ying Tang Electrical and Computer Engineering Rowan University 1 How A Computer React to Inputs? Polling: the processor regularly looks at

More information

EEL 4924 Electrical Engineering Design (Senior Design) Team Baudiophile. Wireless Headphones

EEL 4924 Electrical Engineering Design (Senior Design) Team Baudiophile. Wireless Headphones EEL 4924 Electrical Engineering Design (Senior Design) Final Design Report 25 April 2012 Team Baudiophile Wireless Headphones Team Members: Name: Stephen Brewer Name: Eli Chen Project Abstract Our project

More information

Interfacing CMA3000-D01 to an MSP430 ultra low-power microcontroller

Interfacing CMA3000-D01 to an MSP430 ultra low-power microcontroller Interfacing CMA3000-D01 to an MSP430 ultra low-power microcontroller 1 INTRODUCTION The objective of this document is to show how to set up SPI/I2C communication between VTI Technologies CMA3000-D01 digital

More information

ECE PRACTICE EXAM #2 Clocks, Timers, and Digital I/O

ECE PRACTICE EXAM #2 Clocks, Timers, and Digital I/O ECE2049 -- PRACTICE EXAM #2 Clocks, Timers, and Digital I/O Study HW3, Class Notes, Davies Ch 2.6, 5.8, 8, 9.2-3, 9.7, MSP43F5529 User's Guide Ch 5, 17, 28 Work all problems with your note sheet first

More information

Using peripherals on the MSP430 (if time)

Using peripherals on the MSP430 (if time) Today's Plan: Announcements Review Activities 1&2 Programming in C Using peripherals on the MSP430 (if time) Activity 3 Announcements: Midterm coming on Feb 9. Will need to write simple programs in C and/or

More information

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #11: More Clocks and Timers

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #11: More Clocks and Timers ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #11: More Clocks and Timers Reading for Today: Davie's Ch 8.3-8.4, 8.9-8.10, User's Guide Ch. 17 Reading for Next Class: User's

More information

CPE/EE 323 Introduction to Embedded Computer Systems Homework V

CPE/EE 323 Introduction to Embedded Computer Systems Homework V CPE/EE 323 Introduction to Embedded Computer Systems Homework V 1(15) 2(15) 3(25) 4(25) 5(20) Total Problem #1 (15 points) Power, Low power systems A sensor platform features a microcontroller, a sensor,

More information

Lab 1: I/O, timers, interrupts on the ez430-rf2500

Lab 1: I/O, timers, interrupts on the ez430-rf2500 Lab 1: I/O, timers, interrupts on the ez430-rf2500 UC Berkeley - EE 290Q Thomas Watteyne January 25, 2010 1 The ez430-rf2500 and its Components 1.1 Crash Course on the MSP430f2274 The heart of this platform

More information

CPE 323: MSP430 Timers

CPE 323: MSP430 Timers CPE 323: MSP430 Timers Aleksandar Milenkovic Electrical and Computer Engineering The University of Alabama in Huntsville milenka@ece.uah.edu http://www.ece.uah.edu/~milenka Outline Watchdog Timer TimerA

More information

Fall. Accelerometer RGB LED control Vishal Shah Rebel Sequeira Pratiksha Patil Pranali Dhuru Chris Blackden. George Mason University

Fall. Accelerometer RGB LED control Vishal Shah Rebel Sequeira Pratiksha Patil Pranali Dhuru Chris Blackden. George Mason University Fall 13 Accelerometer RGB LED control Vishal Shah Rebel Sequeira Pratiksha Patil Pranali Dhuru Chris Blackden George Mason University Introduction The ECE 511 course gave us the opportunity to team up

More information

ECE2049: Embedded Computing in Engineering Design A Term Fall 2017 Lecture #16: Interrupts and Event Driven Code

ECE2049: Embedded Computing in Engineering Design A Term Fall 2017 Lecture #16: Interrupts and Event Driven Code ECE2049: Embedded Computing in Engineering Design A Term Fall 2017 Lecture #16: Interrupts and Event Driven Code Reading for Today: Example code Reading for Next Class: Review all since exam 1 HW #4 (on

More information

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I. University of Texas at El Paso Electrical and Computer Engineering Department EE 3176 Laboratory for Microprocessors I Fall 2016 LAB 08 UART Communication Goals: Learn about UART Communication and the

More information

ECE 492 WINTER 2015 GROUP 2. Texas Instruments MSP430-FR Bit ADC Setup Guide

ECE 492 WINTER 2015 GROUP 2. Texas Instruments MSP430-FR Bit ADC Setup Guide APPLICATION NOTE MIKE PAPPAS ECE 492 WINTER 2015 GROUP 2 Texas Instruments MSP430-FR5969 12-Bit ADC Setup Guide March 2015 Table of Contents Preface... 3 Pin Assignments... 4 Configuring the ADC... 4 Sampling

More information

What is an Interrupt?

What is an Interrupt? MSP430 Interrupts What is an Interrupt? Reaction to something in I/O (human, comm link) Usually asynchronous to processor activities interrupt handler or interrupt service routine (ISR) invoked to take

More information

MSP430. More on MSP430

MSP430. More on MSP430 MSP430 More on MSP430 CodeComposer TI recently launched Code Composer Essentials v3. This IDE s latest version (version 3) supports all available MSP430 devices. The new features of CCE v3 include: - Free

More information

MSP430 Interrupts. Change value of internal variable (count) Read a data value (sensor, receive) Write a data value (actuator, send)

MSP430 Interrupts. Change value of internal variable (count) Read a data value (sensor, receive) Write a data value (actuator, send) MSP430 Interrupts What is an Interrupt? Reaction to something in I/O (human, comm link) Usually asynchronous to processor activities interrupt handler or interrupt service routine (ISR) invoked to take

More information

Copyright 2015 by Stephen A. Zajac & Gregory M. Wierzba. All rights reserved..spring 2015.

Copyright 2015 by Stephen A. Zajac & Gregory M. Wierzba. All rights reserved..spring 2015. Copyright 2015 by Stephen A. Zajac & Gregory M. Wierzba. All rights reserved..spring 2015. Copyright 2015 by Stephen A. Zajac & Gregory M. Wierzba. All rights reserved..spring 2015. Copyright 2015 by Stephen

More information

Lab 4 Interrupts ReadMeFirst

Lab 4 Interrupts ReadMeFirst Lab 4 Interrupts ReadMeFirst Lab Folder Content 1) ReadMeFirst 2) Interrupt Vector Table 3) Pin out Summary Objectives Understand how interrupts work Learn to program Interrupt Service Routines in C Language

More information

CPE 323 Introduction to Embedded Computer Systems: MSP430 System Architecture An Overview

CPE 323 Introduction to Embedded Computer Systems: MSP430 System Architecture An Overview CPE 323 Introduction to Embedded Computer Systems: MSP430 System Architecture An Overview Aleksandar Milenkovic Electrical and Computer Engineering The University of Alabama in Huntsville milenka@ece.uah.edu

More information

CONTENTS: Program 1 in C:

CONTENTS: Program 1 in C: CONTENTS: 1) Program 1 in C (Blink) 2) Program 2 in C (Interrupt ) 3) ADC example 4) Addressing Modes 5) Selected Assembly instructions 6) ADC10 register descriptions Program 1 in C: /* * PHYS319 Lab3

More information

CPE 325: Embedded Systems Laboratory Laboratory #7 Tutorial MSP430 Timers, Watchdog Timer, Timers A and B

CPE 325: Embedded Systems Laboratory Laboratory #7 Tutorial MSP430 Timers, Watchdog Timer, Timers A and B CPE 325: Embedded Systems Laboratory Laboratory #7 Tutorial MSP430 Timers, Watchdog Timer, Timers A and B Aleksandar Milenković Email: milenka@uah.edu Web: http://www.ece.uah.edu/~milenka Objective This

More information

IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -2 1 UNIT 2

IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -2 1 UNIT 2 IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -2 1 UNIT 2 1. Block diagram of MSP430x5xx series micro-controller --------------------- 1 2. CPU architecture of MSP430x5xx ------------------------------------------------

More information

CPE 323 Introduction to Embedded Computer Systems: ADC12 and DAC12. Instructor: Dr Aleksandar Milenkovic Lecture Notes

CPE 323 Introduction to Embedded Computer Systems: ADC12 and DAC12. Instructor: Dr Aleksandar Milenkovic Lecture Notes CPE 323 Introduction to Embedded Computer Systems: ADC12 and DAC12 Instructor: Dr Aleksandar Milenkovic Lecture Notes Outline MSP430: System Architecture ADC12 Module DAC12 Module CPE 323 2 ADC12 Introduction

More information

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I. University of Texas at El Paso Electrical and Computer Engineering Department EE 3176 Laboratory for Microprocessors I Fall 2016 LAB 04 Timer Interrupts Goals: Learn about Timer Interrupts. Learn how to

More information

C Language Programming through the ADC and the MSP430 (ESCAPE)

C Language Programming through the ADC and the MSP430 (ESCAPE) OpenStax-CNX module: m46087 1 C Language Programming through the ADC and the MSP430 (ESCAPE) Matthew Johnson Based on C Language Programming through the ADC and the MSP430 by Matthew Johnson This work

More information

Design Document. May Logging DC Wattmeter. Team Member: Advisor : Ailing Mei. Collin Christy. Andrew Kom. Client: Chongli Cai

Design Document. May Logging DC Wattmeter. Team Member: Advisor : Ailing Mei. Collin Christy. Andrew Kom. Client: Chongli Cai Design Document May13-06 Logging DC Wattmeter Team Member: Ailing Mei Andrew Kom Chongli Cai David Hoffman Advisor : Collin Christy Client: Garmin International Qiaoya Cui 0 Table of Contents EXECUTIVE

More information

Lecture test next week

Lecture test next week Lecture test next week Write a short program in Assembler doing. You will be given the print outs of all the assembler programs from the manual You can bring any notes you want Today: Announcements General

More information

ECE2049: Embedded Computing in Engineering Design C Term Spring 2019 Lecture #22: MSP430F5529 Operating Mode & the WDT

ECE2049: Embedded Computing in Engineering Design C Term Spring 2019 Lecture #22: MSP430F5529 Operating Mode & the WDT ECE2049: Embedded Computing in Engineering Design C Term Spring 2019 Lecture #22: MSP430F5529 Operating Mode & the WDT Reading for Today: User's Guide 1.4, Ch 16 Reading for Next Class: Review all since

More information

ECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class)

ECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class) ECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class) Your homework should be neat and professional looking. You will loose points if your HW is not properly

More information

MSP430F149 P3.4/UTXD0 P3.5/URXD0 P1.5 P1.6 P1.7 MSP430F149 P1.0 P5.4 P5.3 P5.2 P5.1. Figure B-1. BSL Replicator Block Diagram

MSP430F149 P3.4/UTXD0 P3.5/URXD0 P1.5 P1.6 P1.7 MSP430F149 P1.0 P5.4 P5.3 P5.2 P5.1. Figure B-1. BSL Replicator Block Diagram Appendix B Appendix B MSP430 BSL Replicator Author: Greg Morton, MSP430 Applications B.1 BSL Replicator Overview The BSL Replicator application, executing on a host MSP430F149 device, uses the BSL protocol

More information

ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives:

ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives: ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives: This lab will introduce basic embedded systems programming concepts by familiarizing the user with an embedded programming

More information

Interrupts CS4101 嵌入式系統概論. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

Interrupts CS4101 嵌入式系統概論. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan CS4101 嵌入式系統概論 Interrupts Prof. Chung-Ta King Department of Computer Science, Taiwan Materials from MSP430 Microcontroller Basics, John H. Davies, Newnes, 2008 Inside MSP430 (MSP430G2551) 1 Introduction

More information

Reading: Davies , 8.3-4, , MSP430x55xx User's Guide Ch. 5,17, MSP430F5529 Launchpad User's Guide

Reading: Davies , 8.3-4, , MSP430x55xx User's Guide Ch. 5,17, MSP430F5529 Launchpad User's Guide ECE2049 Homework #3 Clocks & Timers (Due Thursday 2/8/18 At the BEGINNING of class) Your homework should be neat and professional looking. You will loose points if your HW is not properly submitted (by

More information

Analog Peripherals. Introduction. Objectives

Analog Peripherals. Introduction. Objectives Analog Peripherals Introduction In this section we ll take a look at the MSP430 analog peripherals. It s not possible in this limited amount of time to give you a complete overview of the possible analog

More information

ECE 492 WINTER 2015 GROUP 2. Texas Instruments MSP430-FR Bit ADC Setup Guide

ECE 492 WINTER 2015 GROUP 2. Texas Instruments MSP430-FR Bit ADC Setup Guide APPLICATION NOTE MIKE PAPPAS ECE 492 WINTER 2015 GROUP 2 Texas Instruments MSP430-FR5969 12-Bit ADC Setup Guide March 2015 Table of Contents Preface... 3 Pin Assignments... 4 Configuring the ADC... 4 Sampling

More information

Hacettepe University

Hacettepe University MSP430 Teaching Materials Week 5 FUNDAMENTALS OF INTERFACING AND TIMERS for MSP430 Hacettepe University Elements in Basic MCU Interface Power Source Feeds CPU and peripherals Clock Oscillators System synchronization

More information

Timer Module Timer A. ReadMeFirst

Timer Module Timer A. ReadMeFirst Timer Module Timer A ReadMeFirst Lab Folder Content 1) ReadMeFirst 2) TimerModule Lecture material 3) PinOutSummary 4) InterruptsVectorTable 5) Source code for screencast Interrupt Review Overview A Timer

More information

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I. University of Texas at El Paso Electrical and Computer Engineering Department EE 3176 Laboratory for Microprocessors I Fall 2016 LAB 06 Analog to Digital Conversion Goals: Bonus: Pre Lab Questions: Display

More information

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab By the end of Class Pseudo-code for Lab 1-2 due as part of prelab Homework #5 on website due before next class Outline Introduce Lab 1-2 Counting Timers on C8051 Interrupts Laboratory Worksheet #05 Copy

More information

Hacettepe University

Hacettepe University MSP430 Teaching Materials Week 5 FUNDAMENTALS OF INTERFACING AND TIMERS for MSP430 Hacettepe University Elements in Basic MCU Interface Power Source Feeds CPU and peripherals Clock Oscillators System synchronization

More information

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang,

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang, Network Embedded Systems Sensor Networks Fall 2013 Hardware Marcus Chang, mchang@cs.jhu.edu 1 Embedded Systems Designed to do one or a few dedicated and/or specific functions Embedded as part of a complete

More information

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #15: More ADC Examples

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #15: More ADC Examples ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #15: More ADC Examples Reading for Today: TI example code Reading for Next Class: Users Guide 6.2, Davies Ch 6.6-6.9 HW #4 (on

More information

Wireless Sensor Networks (WSN)

Wireless Sensor Networks (WSN) Wireless Sensor Networks (WSN) Operating Systems M. Schölzel Operating System Tasks Traditional OS Controlling and protecting access to resources (memory, I/O, computing resources) managing their allocation

More information

@databasescaling Wednesday, 18 th April 2013

@databasescaling Wednesday, 18 th April 2013 andyjpb@ashurst.eu.org @databasescaling Wednesday, 18 th April 2013 OSHUG #24 1 / 56 Writing C For Constrained Systems a@jpb.li @databasescaling Wednesday, 18 th April 2013 OSHUG #24 2 / 56 Writing C For

More information

#include <stdio.h> // // Global CONSTANTS

#include <stdio.h> // // Global CONSTANTS Distance.c Author: Baylor Electromechanical Systems Operates on an external 18.432 MHz oscillator. Target: Cygnal Educational Development Board / C8051F020 Tool chain: KEIL C51 6.03 / KEIL EVAL C51 Utilizes

More information

Block diagram of processor (Harvard)

Block diagram of processor (Harvard) Block diagram of processor (Harvard) Register transfer view of Harvard architecture Separate busses for instruction memory and data memory Example: PIC 16 load path OP REG AC 16 16 store path rd wr data

More information

5xx Active & Low Power Mode Operation

5xx Active & Low Power Mode Operation 5xx Active & Low Power Mode Operation 38 Lab 2: ULP Operation Lab Goals Learn ULP Best Practices Learn & understand how to configure two key modules of the 5xx to achieve ultra-low power operation. Power

More information

Physics 319 Spring 2015: Introduction to the Programming and Use of Microprocessors

Physics 319 Spring 2015: Introduction to the Programming and Use of Microprocessors Physics 319 Spring 2015: Introduction to the Programming and Use of Microprocessors Sing Chow, Andrzej Kotlicki, Ryan Wicks, and Carl Michal December 2014 This lab is going to introduce you to the world

More information

Final Design Report. Project Title: Automatic Storm Shutters. Team Name: Make It Rain

Final Design Report. Project Title: Automatic Storm Shutters. Team Name: Make It Rain EEL 4924 Electrical Engineering Design (Senior Design) Final Design Report 4 August 2009 Project Title: Automatic Storm Shutters Team Name: Make It Rain Team Members: Name: Kyle Weber Name: Zachary Wernlund

More information

Final Report 26 April 2012

Final Report 26 April 2012 EEL 4924 Electrical Engineering Design (Senior Design) Final Report 26 April 2012 Project Title: Keyboard Jockey Team Members: Name: Jeffrey Kaufman Name: Jacob Meacham Project Abstract Our project is

More information

RF Networking With MSP430 & the ez430-rf2500 Session 2 Miguel Morales, MSP430 Applications 6/5/2008 1

RF Networking With MSP430 & the ez430-rf2500 Session 2 Miguel Morales, MSP430 Applications 6/5/2008 1 RF Networking With MSP430 & the ez430-rf2500 Session 2 Miguel Morales, MSP430 Applications 6/5/2008 1 Agenda Recap of Session 1 Hardware description Session 2 Lab Overview Lab 2.1 Tilt & Ambient Noise

More information

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #7: More Digital IO

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #7: More Digital IO ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #7: More Digital IO Reading for Today: Davies 7.5-7.9, Users Guide Ch 12 Reading for Next Class: Davies 7.5-7.9, Users Guide

More information

// and verify that there is a sine wave with frequency <FREQUENCY> and

// and verify that there is a sine wave with frequency <FREQUENCY> and F330DC_IDA0_SineWave.c Copyright 2006 Silicon Laboratories, Inc. http:www.silabs.com Program Description: This program outputs a sine wave using IDA0. IDA0's output is scheduled to update at a rate determined

More information

CPE 323: MSP430 Serial Communication

CPE 323: MSP430 Serial Communication CPE 323: MSP430 Serial Communication Aleksandar Milenkovic Electrical and Computer Engineering The University of Alabama in Huntsville milenka@ece.uah.edu http://www.ece.uah.edu/~milenka Outline Introduction

More information

Auto-Alignment Laser Mirrors First Semester Report Fall Semester 2013

Auto-Alignment Laser Mirrors First Semester Report Fall Semester 2013 Auto-Alignment Laser Mirrors First Semester Report Fall Semester 2013 -Full Report- by Michael M. Rader Prepared to partially fulfill requirements for ECE401 Department of Electrical and Computer Engineering

More information

Monitoring System for a Laundry System with ez430-rf2500 Development Kit

Monitoring System for a Laundry System with ez430-rf2500 Development Kit Monitoring System for a Laundry System with ez430-rf2500 Development Kit E90 Senior Design Project David Kwon Department of Engineering Advised by Professor Molter May 08, 2009 Abstract Monitoring system

More information

MintySynth Software Manual v. 4.2

MintySynth Software Manual v. 4.2 MintySynth Software Manual v. 4.2 mintysynth.com info@mintysynth.com Contents Introduction I. Demo Song and Live Mode a. Demo Song b. Tempo c. Swing d. Waveform e. Duration f. Envelope II. III. IV. Photocell

More information

Reading: Davies , 8.3-4, , MSP430x55xx User's Guide Ch. 5,17

Reading: Davies , 8.3-4, , MSP430x55xx User's Guide Ch. 5,17 ECE2049 Homework #3 Clocks & Timers (Due Tuesday 9/19/17 At the BEGINNING of class) Your homework should be neat and professional looking. You will loose points if your HW is not properly submitted (by

More information

임베디드시스템기초 (# ) #11. Serial Communications 한림대학교전자공학과이선우

임베디드시스템기초 (# ) #11. Serial Communications 한림대학교전자공학과이선우 임베디드시스템기초 (#514115 ) #11. Serial Communications 한림대학교전자공학과이선우 Contents General Serial communications Asynchronous serial communications (UART) 2 Parallel vs. Serial 패러럴 ( 병렬 ) 데이터통신 복수의신호선을이용 ( 대개 8/16/32bit)

More information

Embedded Systems. 3. Hardware Software Interface. Lothar Thiele. Computer Engineering and Networks Laboratory

Embedded Systems. 3. Hardware Software Interface. Lothar Thiele. Computer Engineering and Networks Laboratory Embedded Systems 3. Hardware Software Interface Lothar Thiele Computer Engineering and Networks Laboratory Do you Remember? 3 2 3 3 High Level Physical View 3 4 High Level Physical View 3 5 What you will

More information

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform. Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform www.sierraradio.net www.hamstack.com Topics Introduction Hardware options Software development HamStack project

More information

ECE 353 Lab 4. General MIDI Explorer. Professor Daniel Holcomb Fall 2015

ECE 353 Lab 4. General MIDI Explorer. Professor Daniel Holcomb Fall 2015 ECE 353 Lab 4 General MIDI Explorer Professor Daniel Holcomb Fall 2015 Where are we in Course Lab 0 Cache Simulator in C C programming, data structures Cache architecture and analysis Lab 1 Heat Flow Modeling

More information

8032 MCU + Soft Modules. c = rcvdata; // get the keyboard scan code

8032 MCU + Soft Modules. c = rcvdata; // get the keyboard scan code 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 { 0x25, 0x66 }, // "4" { 0x2E, 0x6D }, // "5" { 0x36, 0x7D }, // "6" { 0x3D, 0x07 }, // "7" { 0x3E, 0x7F }, // "8" { 0x46,

More information

Why embedded systems?

Why embedded systems? MSP430 Intro Why embedded systems? Big bang-for-the-buck by adding some intelligence to systems. Embedded Systems are ubiquitous. Embedded Systems more common as prices drop, and power decreases. Which

More information

Altimeter / Barometer Module SMD500 ultra low power, low voltage

Altimeter / Barometer Module SMD500 ultra low power, low voltage Altimeter / Barometer Module SMD500 ultra low power, low voltage 1. General Description The SMD500 marks a new generation of high precision digital pressure sensors for consumer applications. Its ultra

More information

Getting Started with the Texas Instruments ez430

Getting Started with the Texas Instruments ez430 1 of 6 03.01.2009 01:33 HOME Running Your Code>> Getting Started with the Texas Instruments ez430 Working with the Workbench Software Step 1: Each program needs an associated project. The project includes

More information

TBS Unify Pro / SmartAudio

TBS Unify Pro / SmartAudio TBS Unify Pro / SmartAudio 02.12..2017 Revision 08 SmartAudio uses single wire half duplex communication based on UART. In Idle mode both host and VTX define the SmartAudio pin as input. If the host want

More information

MTR-4. C8 Command to MODBUS Bridge User Manual F-1, No. 631, Chung Der Road, Sec 1, Taichung Taiwan.

MTR-4. C8 Command to MODBUS Bridge User Manual F-1, No. 631, Chung Der Road, Sec 1, Taichung Taiwan. MTR-4 C8 Command to MODBUS Bridge User Manual 404 19F-1, No. 631, Chung Der Road, Sec 1, Taichung Taiwan. TEL:886-4-2238-0698 FAX:886-4-2238-0891 Web Site:http://www.monicon.com.tw E-mail: sales@monicon.com.tw

More information

Designing for Ultra-Low Power with MSP430

Designing for Ultra-Low Power with MSP430 Designing for Ultra-Low Power with MSP430 Christian Hernitscheck MSP430 FAE Europe Texas Instruments 2006 Texas Instruments Inc, Slide 1 Agenda Introduction to Ultra-Low Power Looking for Ultra-Low Power

More information

Preliminary Design Report

Preliminary Design Report EEL 4924 Electrical Engineering Design (Senior Design) Preliminary Design Report 31 Jan 2012 Project Title: Keyboard Jockey Team Members: Name: Jeffrey Kaufman Name: Jacob Meacham Project Abstract Our

More information

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly.

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly. More on Programming the 9S12 in C Huang Sections 5.2 through 5.4 Introduction to the MC9S12 Hardware Subsystems Huang Sections 8.2-8.6 ECT_16B8C Block User Guide A summary of MC9S12 hardware subsystems

More information

Goal: We want to build an autonomous vehicle (robot)

Goal: We want to build an autonomous vehicle (robot) Goal: We want to build an autonomous vehicle (robot) This means it will have to think for itself, its going to need a brain Our robot s brain will be a tiny computer called a microcontroller Specifically

More information

Supporting Information for. Simultaneous Atomic-Level Visualization and High Precision

Supporting Information for. Simultaneous Atomic-Level Visualization and High Precision Electronic Supplementary Material (ESI) for RSC Advances. This journal is The Royal Society of Chemistry 2017 Supporting Information for Simultaneous Atomic-Level Visualization and High Precision Photocurrent

More information

UC Berkeley EE40/100 Lab Lab 6: Microcontroller Input/Output B. Boser, etc.

UC Berkeley EE40/100 Lab Lab 6: Microcontroller Input/Output B. Boser, etc. UCBerkeleyEE40/100Lab Lab6:MicrocontrollerInput/Output B.Boser,etc. NAME1: NAME2: SID: SID: Microcontrollersareverymuchslimmeddowncomputers.Nodisks,novirtualmemory,nooperatingsystem.Thinkofthem justlikeothercircuitcomponentswiththeaddedbenefitofbeingconfigurablewithaprogram.becauseofthis,

More information

2002 Mixed Signal Products SLAU056B

2002 Mixed Signal Products SLAU056B User s Guide 22 Mixed Signal Products SLAU56B IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements,

More information

Arduino Uno. Power & Interface. Arduino Part 1. Introductory Medical Device Prototyping. Digital I/O Pins. Reset Button. USB Interface.

Arduino Uno. Power & Interface. Arduino Part 1. Introductory Medical Device Prototyping. Digital I/O Pins. Reset Button. USB Interface. Introductory Medical Device Prototyping Arduino Part 1, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Arduino Uno Power & Interface Reset Button USB Interface

More information

EE445L Fall 2018 Final EID: Page 1 of 7

EE445L Fall 2018 Final EID: Page 1 of 7 EE445L Fall 2018 Final EID: Page 1 of 7 Jonathan W. Valvano First: Last: This is the closed book section. Calculator is allowed (no laptops, phones, devices with wireless communication). You must put your

More information

App Note Application Note: State-Driven Control of a dpasp using a Microchip PIC.

App Note Application Note: State-Driven Control of a dpasp using a Microchip PIC. Rev: 1.0.1 Date: 8 th July 2009 App Note - 207 Application Note: State-Driven Control of a dpasp using a Microchip PIC. This application note contains a total 3 files, if you have only this pdf text document,

More information

University of Florida EEL 3744 Spring 2018 Dr. Eric M. Schwartz. Good luck!

University of Florida EEL 3744 Spring 2018 Dr. Eric M. Schwartz. Good luck! Page 1/13 Exam 2 Relax! Go Gators! Good luck! First Name Instructions: Turn off all cell phones and other noise making devices and put away all electronics. Show all work on the front of the test papers.

More information

EE445L Fall 2014 Final Version A Page 1 of 7

EE445L Fall 2014 Final Version A Page 1 of 7 EE445L Fall 2014 Final Version A Page 1 of 7 Jonathan W. Valvano First: Last: This is the closed book section. You must put your answers in the boxes. When you are done, you turn in the closed-book part

More information

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #9: Exam Review w/ Solutions

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #9: Exam Review w/ Solutions ECE2049: Embedded Computing in Engineering Design A Term Fall 2018 Lecture #9: Exam Review w/ Solutions Reading for Today: Review all reading and notes, Davies Ch 1, 2, 4,7, MSP430 User's Guide Ch 6.1,

More information

Review Activity 1 CALL and RET commands in assembler

Review Activity 1 CALL and RET commands in assembler Today's Plan: Announcements Review Activity 1 CALL and RET commands in assembler Lecture test Programming in C continue Announcements: Projects: should be starting to think about. You will need to provide

More information

volatile int results[5]; // variables para la interrupcion del acelerometro //Funciones del acelerometro para mandar y recibir información

volatile int results[5]; // variables para la interrupcion del acelerometro //Funciones del acelerometro para mandar y recibir información Anexo A. Código de programación #include #include #include "lcdlib.h" // variables para guardar informacion de los canales analógicos volatile int results[5]; // variables para la interrupcion

More information

AFRecorder 4800R Serial Port Programming Interface Description For Software Version 9.5 (Last Revision )

AFRecorder 4800R Serial Port Programming Interface Description For Software Version 9.5 (Last Revision ) AFRecorder 4800R Serial Port Programming Interface Description For Software Version 9.5 (Last Revision 8-27-08) Changes from Version 9.2 1. The communication baud rate is raised to 9600. 2. Testing with

More information

Timer 32. Last updated 8/7/18

Timer 32. Last updated 8/7/18 Last updated 8/7/18 Basic Timer Function Delay Counter Load a value into a counter register The counter counts Down to zero (count down timer) Up from zero (count up timer) An action is triggered when

More information

MIDTERM#1. 2-(3pts) What is the difference between Von Neumann & Harvard processor architectures?

MIDTERM#1. 2-(3pts) What is the difference between Von Neumann & Harvard processor architectures? CSE421-Microprocessors & Microcontrollers-Spring 2013 (March 26, 2013) NAME: MIDTERM#1 1- (2pts) What does MSP stand for in MSP430? Why? Mixed Signal Processor. It contains both analog and digital circuitry.

More information

Embedded Technosolutions

Embedded Technosolutions MSP430 Tutorial Very Important Low Power Processor For Embedded Systems Applications Introduction Although there are many resources dedicated to teaching microcontrollers and the MSP430 in particular,

More information

Texas Instruments Microcontroller HOW-TO GUIDE Interfacing Keypad with MSP430F5529

Texas Instruments Microcontroller HOW-TO GUIDE Interfacing Keypad with MSP430F5529 Texas Instruments Microcontroller HOW-TO GUIDE Interfacing Keypad with MSP430F5529 Contents at a Glance PS PRIMER MSP430 kit... 3 Keypad... 4 Interfacing keypad... 4 Interfacing keypad with MSP430F5529...

More information

Application Report. 1 Hardware Description. John Fahrenbruch... MSP430 Applications

Application Report. 1 Hardware Description. John Fahrenbruch... MSP430 Applications Application Report SLAA309 June 2006 Low-Power Tilt Sensor Using the MSP430F2012 John Fahrenbruch... MSP430 Applications ABSTRACT The MSP430 family of low-power microcontrollers are ideal for low-power

More information

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #19: Using SPI The LCD Screen and DAC Reading for Today: User's Manual Ch 35, Davies 101.5, DAC datasheet Reading for Next Class:

More information

Introduction to the MC9S12 Hardware Subsystems

Introduction to the MC9S12 Hardware Subsystems Setting and clearing bits in C Using pointers in C o Program to count the number of negative numbers in an area of memory Introduction to the MC9S12 Hardware Subsystems o The MC9S12 timer subsystem Operators

More information