Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 10 – eZ430X +. BYU CS/ECEn 124Chapter 10 - eZ430X2 Topics to Cover… MSPF2274 eZ430X Development Board Peripherals Peripheral Devices Low Pass.

Similar presentations

Presentation on theme: "Chapter 10 – eZ430X +. BYU CS/ECEn 124Chapter 10 - eZ430X2 Topics to Cover… MSPF2274 eZ430X Development Board Peripherals Peripheral Devices Low Pass."— Presentation transcript:

1 Chapter 10 – eZ430X +

2 BYU CS/ECEn 124Chapter 10 - eZ430X2 Topics to Cover… MSPF2274 eZ430X Development Board Peripherals Peripheral Devices Low Pass Filter Headers Jumpers Simon Lab Coding Assembler

3 BYU CS/ECEn 124Chapter 10 - eZ430X3 Handheld Measurement Air Flow measurement Alcohol meter Barometer Data loggers Emission/Gas analyser Humidity measurement Temperature measurement Weight scales Medical Instruments Blood pressure meter Blood sugar meter Breath measurement EKG system Home environment Air conditioning Control unit Thermostat Boiler control Shutter control Irrigation system White goods (Washing machine,..) Misc Smart card reader Taxi meter Smart Batteries Utility Metering Gas Meter Water Meter Heat Volume Counter Heat Cost Allocation Electricity Meter Meter reading system (RF) Sports equipment Altimeter Bike computer Diving watches Security Glass break sensors Door control Smoke/fire/gas detectors MSP430 Typical Applications MSP430F2274

4 BYU CS/ECEn 124Chapter 10 - eZ430X4 MSP430 Roadmap MSP430F2274

5 BYU CS/ECEn 124Chapter 10 - eZ430X5 IMPORTANT!!! Beware of static electricity, don't touch the components directly. Never disconnect a target board from the USB programmer if still plugged into the computer or from the battery unit with jumper on. Otherwise you destroy the board! MSP430F2274

6 BYU CS/ECEn 124Chapter 10 - eZ430X6 MSP430F2274

7 BYU CS/ECEn 124Chapter 10 - eZ430X7 eZ430X Development Board Servos Thermistor Potentiometer LEDs Push Buttons Speaker Battery Power Configuration Stakes MSP430F2274 USB Programmer Ferrite RAM Accelerometer LCD eZ430X Development Board Transponder

8 BYU CS/ECEn 124Chapter 10 - eZ430X8 eZ430X Development Board

9 BYU CS/ECEn 124Chapter 10 - eZ430X9 Computrol Facilities eZ430X Development Board

10 BYU CS/ECEn 124Chapter 10 - eZ430X10 Printed Circuit Boards eZ430X Development Board

11 BYU CS/ECEn 124Chapter 10 - eZ430X11 Apply Solder Paste eZ430X Development Board

12 BYU CS/ECEn 124Chapter 10 - eZ430X12 Robots Place Parts eZ430X Development Board

13 BYU CS/ECEn 124Chapter 10 - eZ430X13 Discrete Parts Added eZ430X Development Board

14 BYU CS/ECEn 124Chapter 10 - eZ430X14 Flow Soldered eZ430X Development Board

15 BYU CS/ECEn 124Chapter 10 - eZ430X  Solder Bath eZ430X Development Board

16 BYU CS/ECEn 124Chapter 10 - eZ430X16 Final Inspection eZ430X Development Board

17 BYU CS/ECEn 124Chapter 10 - eZ430X17 Peripherals A/D Converter (ADC10) Operational Amps (OA0-3) (Not covered) Ports (P1-P4) Power Module Digitally Controlled Oscillator (DCO) Very Low Frequency Oscillator (VLO) Timers A/B USCI A/B USART – Universal Serial Asynchronous Rx/Tx SPI – Serial Peripheral Interface i2 c – Inter-Integrated Circuit Watchdog+ Peripherals

18 BYU CS/ECEn 124Chapter 10 - eZ430X18 ADC10 High-performance 10-bit analog-to-digital conversions More than 200k samples/sec Programmable sample & hold Initiation by software or Timer_A 8 external input channels Selectable voltage reference (1.5v or 2.5v) Internal storage Peripherals

19 BYU CS/ECEn 124Chapter 10 - eZ430X19 Digital I/O Independently programmable individual I/Os 4 ports (P1 – P4) Each has 8 I/O pins Each pin can be configured as input or output P1 and P2 pins can be configured to assert an interrupt request Input Register PxIN Output Register PxOUT Direction Register PxDIR Interrupt Flag Register PxIFG Interrupt Enable Register PxIE Interrupt Edge Select Register PxIES Function Select Register PxSEL Port1 Port2 Port3 Port4 yes no yesno yesno yes Peripherals

20 BYU CS/ECEn 124Chapter 10 - eZ430X20 Timer_A/B Timer_A/B are 16-bit timer/counters with three capture/compare registers Capture external signals Compare PWM mode SCCI latch for asynchronous communication Peripherals

21 BYU CS/ECEn 124Chapter 10 - eZ430X21 USART Serial Port The Universal Synchronous/Asynchronous Receive/Transmit peripheral interface supports two serial modes with one hardware module UART SPI (Synchronous Peripheral Interface) I 2 C (Inter-Integrated Circuit) Double-buffered Baud-rate generator Peripherals

22 BYU CS/ECEn 124Chapter 10 - eZ430X22 I2c – Inter-Integrated Circuit Inter-Integrated Circuit 2-wire serial interface (Serial data SDA, Serial clock SCL) master/slave (slaves have unique 7-bit address) kbit/sec (relatively slow) Master provides clock Start condition Slave acknowledgment Read SDA Write SDA SDA stable SDA may change Stop condition

23 BYU CS/ECEn 124Chapter 10 - eZ430X23 Watchdog Timer WDT module performs a controlled system restart after a software problem occurs Can serve as an interval timer (generates interrupts) WDT Control register is password protected Note: Powers-up active

24 BYU CS/ECEn 124Chapter 10 - eZ430X24 Peripheral Devices Switches (Push Buttons) LED’s (2 + 4) LCD (100 x 160 pixels) FRAM (8 kb) LCD Backlight Potentiometers (Left & Right) Thermistor (10k  ) Accelerometer (3-axis ADXL345) Sonar Transponder (Optional) Peripheral Devices

25 BYU CS/ECEn 124Chapter 10 - eZ430X25 Switches P2.0-3 Internal pull-ups Require debouncing Peripheral Devices

26 BYU CS/ECEn 124Chapter 10 - eZ430X26 LED’s P2.0-1, P3.3, P4.6 Use PWM for brightness 0 = OFF, 1 = ON Peripheral Devices

27 BYU CS/ECEn 124Chapter 10 - eZ430X27 LCD LCD x 160 pixels transflective display Transflective polarizers have both reflecting and transmitting properties and offer the most versatile viewing characteristics. They can be viewed in direct sunlight and when combined with a backlight in low light conditions. Peripheral Devices

28 BYU CS/ECEn 124Chapter 10 - eZ430X28 LCD LCD x 160 pixels display X (0-159)  Y (0-99)   Page 10  Page 9  Page 8  Page 7  Page 6  Page 5  Page 4  Page 3  Page 2  Page 1  Page 0  Page 12  Page 11  Page 13 Peripheral Devices

29 BYU CS/ECEn 124Chapter 10 - eZ430X29 LCD lcd.c Prototypes int lcd_init(void); void lcd_volume(int volume); void lcd_backlight(int backlight); int lcd_display(int mode); void lcd_clear(int value); void lcd_image(const unsigned char* image, int column, int page); void lcd_blank(int column, int page, int width, int height); void lcd_cursor(int column, int page); char lcd_putchar(char c); void lcd_printf(char* fmt,...); Peripheral Devices

30 BYU CS/ECEn 124Chapter 10 - eZ430X30 FRAM Ferroelectric Non- volatile RAM 8192 x 8 bits 45 year retention i 2 c serial bus Unlimited R/W cycles Peripheral Devices Page M(1920)M(1921)M(1922)M(1923)M(1924)M(2079) Page M(1760)M(1761)M(1762)M(1763)M(1764)M(1919) Page M(320)M(321)M(322)M(323)M(324)M(479) Page M(160)M(161)M(162)M(163)M(164)M(319) Page 0 77 M(0)M(1)M(2)M(3)M(4)M(159) X  Y 

31 BYU CS/ECEn 124Chapter 10 - eZ430X31 LCD/FRAM - Graphics graphics.c int lcd_FRAM_init(void); void lcd_circle(int x0, int y0, int r0); unsigned char lcd_point(unsigned int x, unsigned int y, int flag); int FRAM_init(int size, int data); unsigned char FRAM_read(unsigned int address); int FRAM_write(unsigned int address, unsigned char datum); int read_FRAM_point(unsigned int x, unsigned int y); int write_FRAM_point(unsigned int x, unsigned int y, int value); Peripheral Devices

32 BYU CS/ECEn 124Chapter 10 - eZ430X32 LCD Backlight P4.2 / TA2 (Jumper F) Use PWM for dimming Peripheral Devices // configure Timer_A: SMCLK, /1, up/down mode #define BACKLIGHT_FREQUENCY4 #define BL_INCREMENT1 TAR = 0;// reset TAR TACTL = TASSEL_2+ID_0+MC_1; TACCTL2 = OUTMOD_3;// output mode = set/reset TACCR0 = BACKLIGHT_FREQUENCY;// set frequency TACCR2 = 1;// set duty cycle P2SEL |= 0x10;// select TA2

33 BYU CS/ECEn 124Chapter 10 - eZ430X33 Potentiometers Use VREF+ (2.5v) internal reference and Vss (GND) Linear potentiometers return values ADC10 Channels: 12 = left potentiometer (P4.4, Jumper A1) 13 = right potentiometer (P4.3, Jumper G1) Peripheral Devices int ADC_read(int channel) { ADC10CTL0 = SREF0 + ADC10SHT_2 + ADC10ON + REFON + REF2_5V; P4DIR &= ~0x08;// P4.3 P4SEL |= 0x08;// A12 ADC10AE0 |= 0x00; ADC10AE1 = 0x10;// A12 ADC10 function and enable ADC10CTL1 = channel << 12; ADC10CTL0 |= ENC + ADC10SC;// sampling and conversion start while (!(ADC10CTL0 & ADC10IFG));// wait until conversion return ADC10MEM; } // end ADC_sample

34 BYU CS/ECEn 124Chapter 10 - eZ430X34 Thermistor 10k thermistor Non-linear resistance ADC10 Channels: 10 = internal temperature 15 = thermistor (Jumper C1) Peripheral Devices int ADC_read(int channel) { ADC10CTL0 = SREF0 + ADC10SHT_2 + ADC10ON + REFON + REF2_5V; P4DIR &= ~0x40;// A15 = P4.6 P4SEL |= 0x40; ADC10AE0 |= 0x00; ADC10AE1 = 0x80;// A15 ADC10 function and enable ADC10CTL1 = channel << 12; ADC10CTL0 |= ENC + ADC10SC;// sampling and conversion start while (!(ADC10CTL0 & ADC10IFG));// wait until conversion return ADC10MEM; } // end ADC_sample

35 BYU CS/ECEn 124Chapter 10 - eZ430X35 Accelerometer ADXL345 Accelerometer 3-axis acceleration,  2 g,  4 g,  8 g, or  16 g Dynamic acceleration (motion) Static acceleration (gravity) Polysilicon surface-micromachined structure Peripheral Devices

36 BYU CS/ECEn 124Chapter 10 - eZ430X36 Sonar Transponder MaxBotix EZ0/1 Sonar Transponder Sonar range from 6 to 254 inches (1 inch resolution) Analog/serial digital output Peripheral Devices

37 BYU CS/ECEn 124Chapter 10 - eZ430X37 Low Pass Filter Digital equivalent of an analog low pass RC filter Filters unsigned int lowpass_filter(unsigned int input, unsigned int* delay) { // Update filter with current sample. *delay += input - (*delay >> FILTER_SHIFT); // Scale output for unity gain. return *delay >> FILTER_SHIFT; }

38 BYU CS/ECEn 124Chapter 10 - eZ430X38 J1 Header Primary (L)PinSignalSecondary (R) 3P2.0 (ACLK/A0)SW_1 HSW_24P2.1 (SMCLK/A1)EZ0_TX DADXL345 INT1/25P2.2 (TA0/A2)SW_3 ESW_46P2.3 (TA1/A3)Servo #3 FLCD Backlight7P2.4 (TA2/A4)Servo #4 13P2.6LED_1 14P2.7LED_2 17P3.0 (UCB0STE/A5)LCD RST 18P3.1 (UCB0SDA)LCD SDA / ADXL345 SDA / FM24CL64 SDA 15P3.2 (UCB0SCL)LCD SCL / ADXL345 SCL / FM24CL64 SCL EZ0_RX16P3.3 (UCB0CLK)LED_3 GRight Potentiometer8P4.3 (TB0/A12)EZ0_AN ALeft Potentiometer9P4.4 (TB1/A13)Servo #1 BBuzzer (PWM)10P4.5 (TB2/A14)Servo #2 CThermistor11P4.6 (TBOUTH/A15)LED_4 Headers

39 BYU CS/ECEn 124Chapter 10 - eZ430X39 Jumpers 1 (Left Jumper)Signal2 (Right Jumper) ALeft PotentiometerP4.4 (TB1/A13)Servo #1 BBuzzer (PWM)P4.5 (TB2/A14)Servo #2 CThermistorP4.6 (TBOUTH/A15)LED_4 DADXL345 INT1/2P2.2 (TA0/A2)SW_3 ESW_4P2.3 (TA1/A3)Servo #3 FLCD BacklightP2.4 (TA2/A4)Servo #4 GRight PotentiometerP4.3 (TB0/A12)EZ0_AN HSW_2P2.1 (SMCLK/A1)EZ0_TX Jumpers

40 BYU CS/ECEn 124Chapter 10 - eZ430X40 Simon Lab "Write a MSP430 assembly language program to play the game of Simon. Each round of the game is started by flashing the LEDs several times. The colored LEDs (along with the associated tones) are then flashed one at a time in a random sequence. Sample the push button switches and count the number of colors (tones) correctly entered in the same order as the original sequence. Continue until the end of the sequence is reached or a mistake is made. Play some congratulatory tune if the sequence is correct or some raspberry sound if a mistake is made. If the sequence is successfully reproduced, restart the game adding one more color/tone to the sequence. Otherwise, restart a new sequence. Use Timer_B output (TB2) for hardware PWM of the magnetic buzzer."

41 BYU CS/ECEn 124Chapter 10 - eZ430X41 How To Code Assembler… Understand the problem (obviously) Until you are comfortable in assembly, (and even afterwards), write out your solution in something familiar English Flowchart Pseudo-code Java, C, Ruby – the pseudo-code doesn’t really matter! Then, translate to assembler Coding Assembler

42 BYU CS/ECEn 124Chapter 10 - eZ430X42 Three Basic Constructs Coding Assembler

43 BYU CS/ECEn 124Chapter 10 - eZ430X43 if-then-else Translation if-then-else if (buzzerON == 1) { pulse_buzzer(); turn_on_LED(); } else { turn_off_LED(); } cmp.w #1,&buzzerON ; jne myElse ; xor.b #0x20,&P4OUT ; bis.b #0x02,&P1OUT ; jmp myNext ; myElse: ; bic.b #0x02,&P1OUT ; ; myNext: ; Coding Assembler

44 BYU CS/ECEn 124Chapter 10 - eZ430X44 while Translation while loop… #define TRUE 1 while (TRUE) { LED_ON(); delay(); LED_OFF(); delay(); } ; while_loop: ; bis.w #Z,SR ; jnz while_done ; call #LED_ON ; call #delay ; call #LED_OFF ; call #delay ; jmp while_loop ; while_done: ; Coding Assembler

45 BYU CS/ECEn 124Chapter 10 - eZ430X45 switch/case Translation switch/case switch (myByte) { case DOT: do_dot(); break; case DASH: do_dash(); break; default: } cmp.w #DOT,&myByte ; jne sw_01 ; call #do_dot ; jmp sw_end ; sw_01: cmp.w #DASH,&myByte ; jne sw_end ; call #do_dash ; jmp sw_end ; ; sw_end: ; Coding Assembler

46 BYU CS/ECEn 124Chapter 10 - eZ430X46 for-loop Translation for-loop int i; for(i=0; i<10; i++) { do_dot(); delay(); do_dash(); delay(); }.bss i,2 ; mov.w #0,&i ; fl_ck: cmp.w #10,&i ; jge for_done ; call #do_dot ; call #delay ; call #do_dash ; call #delay ; add.w #1,&i ; jmp fl_ck ; for_done: ; Coding Assembler

47 BYU CS/ECEn 124Chapter 10 - eZ430X47

48 BYU CS/ECEn 124Chapter 10 - eZ430X48 TxCCTLx Control Register BitDescription 15-8Capture Configuration (Set to 0) 7-5OUTMODx Output mode:0 0 0  bit OUT  Set  Toggle/Reset  Set / Reset  Toggle  Reset  Toggle / Set  Reset / Set 4CCIECapture/compare interrupt enable when CCIE = 1. 3CCICapture/compare input 2OUTOutput state 1COVCapture overflow when COV = 1 0CCIFGCapture/compare interrupt flag CCIFG = 1 when interrupt pending Capture ConfigurationOUTMODxCCIECCIOUTCOV CCIFG Pulse Width Modulation (H/W)

49 BYU CS/ECEn 124Chapter 10 - eZ430X49 Timer_A/B Output modes Pulse Width Modulation (H/W)

50 BYU CS/ECEn 124Chapter 10 - eZ430X50 Timer_B PWM Example Use PWM w/Timer B for transducer tones: ;reset TimerB clr.w&TBR ;SMCLK, /1, up mode (no interrupts) mov.w#TBSSEL_2+ID_0+MC_1,&TBCTL ;TB2 output mode = set/reset mov.w#OUTMOD_3,&TBCCTL2 ;load tone (frequency) mov.w&DO,&TBCCR0 ;load volume (duty cycle) mov.w#DO/2,&TBCCR2 Pulse Width Modulation (H/W)

51 BYU CS/ECEn 124Chapter 10 - eZ430X51 First, eliminate a lot of code!! Step 12a: Use Timer Output PWM.bss duty_cycle_high,2 ; high part of cycle.bss duty_cycle_low,2 ; low part of cycle.bss duty_cycle_toggle,1 ; duty cycle flag mov.w #DO/2,&TBCCR0 ; start clock bis.w #TBIE,&TBCTL ; enable timer B interrupts mov.w #DO/2,&duty_cycle_high ; set duty cycles mov.w #DO/2,&duty_cycle_low ; > ; rra.w r4 ; 50% duty cycle ; mov.w r4,r5 mov.b volume,r5 ; get volume mov.w duty(r5),r5 ; r5 = duty cycle sub.w r5,r4 ; subtract from frequency cmp.w #0,r5 ; turn off? jne WD04 ; n mov.w #0,r4 ; y, high=low=0 WD04: mov.w r4,&TBCCR0 ; start clock (if necessary) mov.w r4,&duty_cycle_high ; set high duty cycle mov.w r5,&duty_cycle_low ; set low duty cycle TB_isr: ; timer B ISR bic.w #TBIFG,&TBCTL ; acknowledge interrupt xor.b #0x20,&P4OUT ; pulse buzzer xor.b #1,&duty_cycle_toggle ; high? jeq TB02 ; n mov.w &duty_cycle_high,&TBCCR0 ; y, set high duty cycle jmp TB04 TB02: mov.w &duty_cycle_low,&TBCCR0 ; set low duty cycle TB04: reti ; return from interrupt.sect ".int12" ; timer B section.word TB_isr ; timer B isr Pulse Width Modulation (H/W)

52 BYU CS/ECEn 124Chapter 10 - eZ430X52 Put transducer (P4.5) as secondary function Change WD ISR to just put the duty cycle in TBCCR2 Step 12b: Use Timer Output PWM bis.b #0x20,&P4SEL ; P4.5 transducer output mov.w #OUTMOD_3,&TBCCTL2 ; output mode = set/reset mov.w #DO/2,&TBCCR2 ; use TBCCR2 as volume ; > push r5 ; save r5 add.w r4,r4 ; (word index) mov.w scale(r4),r4 ; r4 = tone (frequency) mov.w r4,&TBCCR0 ; start clock (if necessary) mov.b volume,r5 ; get volume add.w r5,r5 ; (word index) mov.w duty(r5),r5 ; r5 = duty cycle mov.w r5,&TBCCR2 ; start clock (if necessary) pop r5 Pulse Width Modulation (H/W)

Download ppt "Chapter 10 – eZ430X +. BYU CS/ECEn 124Chapter 10 - eZ430X2 Topics to Cover… MSPF2274 eZ430X Development Board Peripherals Peripheral Devices Low Pass."

Similar presentations

Ads by Google