520 likes | 529 Vues
Chapter 10 – eZ430X. +. Topics to Cover…. MSPF2274 eZ430X Development Board Peripherals Peripheral Devices Low Pass Filter Headers Jumpers Simon Lab Coding Assembler. MSP430F2274. MSP430 Typical Applications. Handheld Measurement Air Flow measurement Alcohol meter Barometer
E N D
Topics to Cover… • MSPF2274 • eZ430X Development Board • Peripherals • Peripheral Devices • Low Pass Filter • Headers • Jumpers • Simon Lab • Coding Assembler Chapter 10 - eZ430X
MSP430F2274 MSP430 Typical Applications 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 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 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 Chapter 10 - eZ430X
MSP430F2274 MSP430 Roadmap Chapter 10 - eZ430X
MSP430F2274 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! Chapter 10 - eZ430X
MSP430F2274 MSP430F2274 Chapter 10 - eZ430X
eZ430X Development Board eZ430X Development Board Transponder Servos Ferrite RAM USB Programmer Thermistor Configuration Stakes Accelerometer MSP430F2274 Potentiometer Battery Power LEDs LCD Push Buttons Speaker Chapter 10 - eZ430X
eZ430X Development Board eZ430X Development Board Chapter 10 - eZ430X
eZ430X Development Board Computrol Facilities Chapter 10 - eZ430X
eZ430X Development Board Printed Circuit Boards Chapter 10 - eZ430X
eZ430X Development Board Apply Solder Paste Chapter 10 - eZ430X
eZ430X Development Board Robots Place Parts Chapter 10 - eZ430X
eZ430X Development Board Discrete Parts Added Chapter 10 - eZ430X
eZ430X Development Board Flow Soldered Chapter 10 - eZ430X
eZ430X Development Board 276 Solder Bath Chapter 10 - eZ430X
eZ430X Development Board Final Inspection Chapter 10 - eZ430X
Peripherals 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 • i2c – Inter-Integrated Circuit • Watchdog+ Chapter 10 - eZ430X
Peripherals 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 Chapter 10 - eZ430X
Port1 Port3 Port2 Port4 Function Select Register PxSEL yes yes Interrupt Edge Select Register PxIES yes no Interrupt Enable Register PxIE yes no Interrupt Flag Register PxIFG yes no Direction Register PxDIR yes yes Output Register PxOUT yes yes Input Register PxIN yes yes 7 6 5 4 3 2 1 0 Peripherals 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 Chapter 10 - eZ430X
Peripherals 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 Chapter 10 - eZ430X
Peripherals USART Serial Port The Universal Synchronous/Asynchronous Receive/Transmit peripheral interface supports two serial modes with one hardware module • UART • SPI (Synchronous Peripheral Interface) • I2C (Inter-Integrated Circuit) • Double-buffered • Baud-rate generator Chapter 10 - eZ430X
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) • 100-400 kbit/sec (relatively slow) • Master provides clock Slave acknowledgment Stop condition Start condition Write SDA Chapter 10 - eZ430X SDA stable Read SDA SDA may change
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 Chapter 10 - eZ430X
Peripheral Devices 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) Chapter 10 - eZ430X
Peripheral Devices Switches • Switches • P2.0-3 • Internal pull-ups • Require debouncing Chapter 10 - eZ430X
Peripheral Devices LED’s • LED’s • P2.0-1, P3.3, P4.6 • Use PWM for brightness • 0 = OFF, 1 = ON Chapter 10 - eZ430X
Peripheral Devices LCD • LCD - 100 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. Chapter 10 - eZ430X
Page 13 Page 12 Page 11 Page 10 Page 9 Page 8 Page 7 Page 6 Page 5 Page 4 Page 3 Page 2 Page 1 Page 0 Peripheral Devices LCD • LCD - 100 x 160 pixels display Y (0-99) X (0-159) Chapter 10 - eZ430X
Peripheral Devices 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, ...); Chapter 10 - eZ430X
Peripheral Devices FRAM • FRAM • Ferroelectric Non-volatile RAM • 8192 x 8 bits • 45 year retention • i2c serial bus • Unlimited R/W cycles Y X Chapter 10 - eZ430X
Peripheral Devices 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); Chapter 10 - eZ430X
Peripheral Devices LCD Backlight • LCD Backlight • P4.2 / TA2 (Jumper F) • Use PWM for dimming // configure Timer_A: SMCLK, /1, up/down mode #define BACKLIGHT_FREQUENCY 4 #define BL_INCREMENT 1 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 Chapter 10 - eZ430X
Peripheral Devices Potentiometers • Potentiometers • Use VREF+ (2.5v) internal reference and Vss (GND) • Linear potentiometers return 0-1023 values • ADC10 Channels: • 12 = left potentiometer (P4.4, Jumper A1) • 13 = right potentiometer (P4.3, Jumper G1) 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 Chapter 10 - eZ430X
Peripheral Devices Thermistor • Thermistor • 10k thermistor • Non-linear resistance • ADC10 Channels: • 10 = internal temperature • 15 = thermistor (Jumper C1) 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 Chapter 10 - eZ430X
Peripheral Devices 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 Chapter 10 - eZ430X
Peripheral Devices Sonar Transponder • MaxBotix EZ0/1 Sonar Transponder • Sonar range from 6 to 254 inches (1 inch resolution) • Analog/serial digital output Chapter 10 - eZ430X
Filters Low Pass Filter • Digital equivalent of an analog low pass RC filter 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; } Chapter 10 - eZ430X
Headers J1 Header Chapter 10 - eZ430X
Jumpers Jumpers Chapter 10 - eZ430X
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." Chapter 10 - eZ430X
Coding Assembler 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 Chapter 10 - eZ430X
Coding Assembler Three Basic Constructs Chapter 10 - eZ430X
Coding Assembler if-then-else Translation • if-then-else cmp.w #1,&buzzerON ; jne myElse ; xor.b #0x20,&P4OUT ; bis.b #0x02,&P1OUT ; jmp myNext ; myElse: ; bic.b #0x02,&P1OUT ; ; myNext: ; if (buzzerON == 1) { pulse_buzzer(); turn_on_LED(); } else { turn_off_LED(); } Chapter 10 - eZ430X
Coding Assembler while Translation • while loop… ; while_loop: ; bis.w #Z,SR ; jnz while_done ; call #LED_ON ; call #delay ; call #LED_OFF ; call #delay ; jmp while_loop ; while_done: ; #define TRUE 1 while (TRUE) { LED_ON(); delay(); LED_OFF(); delay(); } Chapter 10 - eZ430X
Coding Assembler switch/case Translation • switch/case 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: ; switch (myByte) { case DOT: do_dot(); break; case DASH: do_dash(); break; default: } Chapter 10 - eZ430X
Coding Assembler 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: ; Chapter 10 - eZ430X
Pulse Width Modulation (H/W) TxCCTLx Control Register Chapter 10 - eZ430X
Pulse Width Modulation (H/W) Timer_A/B Output modes Chapter 10 - eZ430X
Pulse Width Modulation (H/W) 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 Chapter 10 - eZ430X