Presentation is loading. Please wait.

Presentation is loading. Please wait.

EMBEDDED SYSTEMS UNIT 4.

Similar presentations


Presentation on theme: "EMBEDDED SYSTEMS UNIT 4."— Presentation transcript:

1 EMBEDDED SYSTEMS UNIT 4

2

3

4

5

6

7

8

9

10

11

12

13

14 TTL level RTL level

15

16 UART

17

18

19 MSP430 communication peripherals
F2xx,4xx 2xx Bit-Banging

20 SPI Motorola SSx SSx

21

22

23

24 USI IN SPI MODE

25 USCI IN SPI MODE

26 I2C Philips (now NXP) Semiconductors
Drawback is ACK is sent for every byte transfer, we need to implement in s/w

27

28 Universal Serial Bus, USB
The Universal Serial Bus industry standard was established in 1995, and then quickly adopted by Intel, Compaq, Microsoft and other companies. USB 1.x  Mbps USB hi-speed USB  megabits per second (Mbps) USB SuperSpeed USB 5.0 gigabits per second (Gbps) USB SuperSpeed Gbps USB Type-C same as USB 3.1 and is a reversible-plug   3 feet to just over 16 feet MODES Control-commands Isochronous-audio Bulk-printer Interrupt-keyboard

29 USCI in UART mode UCSYNC bit in UCA0CTL0. 4 asynchronous modes
Standard UART mode, UCMODExx=00. Multiprocessor modes, UCMODExx=01 or 10. These are used to detect addresses when more than two devices are used on a bus, such as RS-485. Automatic baud rate detection, UCMODExx=11. This is particularly intended for LIN. UCIREN bit.-IrDA enable Setting the Baud Rate with the USCI_A BRCLK is the input to the module (SMCLK, ACLK, or UCA0CLK). BITCLK controls the rate at which bits are received and transmitted. Ideally its frequency should be the same as the baud rate, fBITCLK = fbaud. BITCLK16 is the sampling clock in oversampling mode, with a frequency fBITCLK16 = 16fBITCLK.

30

31

32

33 PROGRAMMING SPI

34

35

36 USCI IN SPI MODE

37 #include <msp430.h>
volatile char received_ch = 0; int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1DIR |= BIT5; P1OUT |= BIT5; P1SEL = BIT1 | BIT2 | BIT4; P1SEL2 = BIT1 | BIT2 | BIT4; UCA0CTL1 = UCSWRST UCA0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC;//3-pin,8-bit SPI MST UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 |= 0x02; // /2 UCA0BR1 = 0; // UCA0MCTL = 0; // No modulation UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** P1OUT &= (~BIT5); // Select Device while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready? UCA0TXBUF = 0xAA; // Send 0xAA over SPI to Slave while (!(IFG2 & UCA0RXIFG)); // USCI_A0 RX Received? received_ch = UCA0RXBUF; // Store received data P1OUT |= (BIT5); // Unselect Device }

38 PROGRAMMING UART On the MSP430G2553 that is on the MSP430 Launchpad, UCA0 pins are present on pins P1.1 and P1.2 as UCA0RXD and UCA0TXD, respectively

39

40 #include <msp430.h>
int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT DCOCTL = 0; /* Use Calibration values for 1MHz Clock DCO*/ BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; P1SEL = BIT1 | BIT2 ; /* Configure Pin Muxing P1.1 RXD and P1.2 TXD */ P1SEL2 = BIT1 | BIT2; UCA0CTL1 = UCSWRST; /* Place UCA0 in Reset to be configured */ /* Configure */ UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 104; // 1MHz 9600 UCA0BR1 = 0; // 1MHz 9600 UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1 UCA0CTL1 &= ~UCSWRST; /* Take UCA0 out of reset */ IE2 |= UCA0RXIE; /* Enable USCI_A0 RX interrupt */ __bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled } /* Echo back RXed character, confirm TX buffer is ready first */ #pragma vector=USCIAB0RX_VECTOR __interrupt void USCI0RX_ISR(void) { while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready? UCA0TXBUF = UCA0RXBUF; // TX -&gt; RXed character

41 CASE STUDY A Low-Power Battery-Less Wireless Temperature and Humidity Sensor for the TI PaLFI Device SHT21 relative humidity and temperature (RH&T) sensor from Sensirion MSP430F2274 microcontroller TMS37157(PaLFI) low-frequency device from TI. The complete power for the wireless sensor and the MSP430F2274 is provided by the RFID base station (ADR2) reader included in the eZ430-TMS37157 demo kit.


Download ppt "EMBEDDED SYSTEMS UNIT 4."

Similar presentations


Ads by Google