Presentation is loading. Please wait.

Presentation is loading. Please wait.

Criteria for choosing a microcontroller A microcontroller must meet the task at hand efficiency and cost effectively. Speed. What is highest speed of.

Similar presentations


Presentation on theme: "Criteria for choosing a microcontroller A microcontroller must meet the task at hand efficiency and cost effectively. Speed. What is highest speed of."— Presentation transcript:

1

2 Criteria for choosing a microcontroller A microcontroller must meet the task at hand efficiency and cost effectively. Speed. What is highest speed of microcontroller? To access the data, the address is presented to address pin, the READ pin is activated and after certin time data shows up. Packaging. Its 40 pin DIP(dual inline package) or QFP(Quad flat package). This is important in terms of space, assembling, prototyping. IEEE UMT, Presented By Farhan Ammar Ahmad

3 Criteria for choosing a microcontroller The amount of RAM and ROM. Power consumption. Especially for battery powered. The number of I/O pins and timers on chip. IEEE UMT, Presented By Farhan Ammar Ahmad

4 Types of microcontrollers There several dozen types of microcontrollers architectures and venders including PIC Intel 8051 Freescale Rabbit 2000 Ziliog eZ8 Toshiba TLCS-870 And many others types are there. But we will discuss PIC. IEEE UMT, Presented By Farhan Ammar Ahmad

5 PIC Microcontroller PIC stands for Peripheral Interface Controller PIC is product of Microchip Technology. IEEE UMT, Presented By Farhan Ammar Ahmad

6 Why PIC microcontroller? As we have discussed criteria for choosing microcontroller. PIC is very popular in industry. Wide availability Extensive collection of application notes. Availability of low cost or free development tools. Self-reprogrammable under software control We will discuss PIC16F877A. Its an 8-bit microcontroller. IEEE UMT, Presented By Farhan Ammar Ahmad

7 PIC16F877A IEEE UMT, Presented By Farhan Ammar Ahmad

8 PIC16F877A Peripheral Features Timer0: 8-bit timer/counter Timer1: 16-bit timer/counter Timer2: 8-bit timer/counter Operating speed: DC – 20 MHz clock input Up to 8K x 14 words of Flash Program Memory Up to 368 x 8 bytes of Data Memory (RAM), Up to 256 x 8 bytes of EEPROM Data Memory Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) Parallel Slave Port (PSP) – 8 bits wide with external RD, WR and CS controls IEEE UMT, Presented By Farhan Ammar Ahmad

9 PIC16F877A Analog Features: 10-bit, up to 8-channel Analog-to-Digital Converter (A/D) Special Microcontroller Features Self-reprogrammable under software control In-Circuit Serial Programming™ (ICSP™) via two pins Single-supply 5V In-Circuit Serial Programming Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation Programmable code protection Power saving Sleep mode Selectable oscillator options In-Circuit Debug (ICD) via two pins Enables you to view variable values, Special Function Register and EEPORM while the program is running. IEEE UMT, Presented By Farhan Ammar Ahmad

10 I/O ports of PIC16F877A Some pins for these I/O ports are multiplexed with an alternate function for the peripheral features on the device. There are five ports on PIC16F877A. Port A Port B Port C Port D Port E IEEE UMT, Presented By Farhan Ammar Ahmad

11 PORT A 6-bit wide, bidirectional port. Data direction register is TRISA. If TRISA=1 then PORTA input port vice versa. Pin PA4 is multiplexed with Timer0 module clock input to become the PA4/TOCK1 pin. Other PORTA pins are multiplexed with Analog input. On power reset these pins are analog input. IEEE UMT, Presented By Farhan Ammar Ahmad

12 PORTB 8-bit wide, bidirectional port. Data direction register is TRISB. If TRISB=1, then PORTB is input else output. Three pins RB3/PGM, RB6/PGC and RB7/PGD are multiplexed with in circuit debugging and low voltage programming function. RB0/INT is an external interrupt pin and is configured using then INTEDG bit OPTION_REG. IEEE UMT, Presented By Farhan Ammar Ahmad

13 PORTC PORTC is 8-bit wide, bidirectional port. Data direction register is TRISC. RC0/T1OSO/T1CKI Input/output port pin Timer1 oscillator output Timer1 clock input. RC1/T1OSI/CCP2 Input/output port pin Timer1 oscillator input PWM2 output. IEEE UMT, Presented By Farhan Ammar Ahmad

14 PORTC RC2/CCP1 Input/output port pin PWM1 output. RC3/SCK/SCL RC3 can also be the synchronous serial clock for SPI mode. RC4/SDI RC4 can also be the SPI data in (SPI mode) IEEE UMT, Presented By Farhan Ammar Ahmad

15 PORTC RC5/SDO Input/output port pin Synchronous Serial Port data output. RC6/TX/CK Input/output port pin USART asynchronous transmit synchronous clock. RC7/RX/DT Input/output port pin USART asynchronous receive synchronous data. IEEE UMT, Presented By Farhan Ammar Ahmad

16 PORTD 8-bit wide port. This port can be I/O or Parallel Slave Port. IEEE UMT, Presented By Farhan Ammar Ahmad

17 PORTE Three pins port. The PORTE pins become the I/O control inputs for the microprocessor port when bit PSPMODE (TRISE ) is set. RE0/RD/AN5 I/O port pin read control input in Parallel Slave Port mode analog input RE1/WR/AN6 I/O port pin write control input in Parallel Slave Port mode analog input RE2/CS/AN7 I/O port pin chip select control input in Parallel Slave Port mode analog input PORTE pins are multiplexed with analog inputs. IEEE UMT, Presented By Farhan Ammar Ahmad

18 Serial Programming Universal Synchronous Asynchronous Receiver Transmitter (USART) module a serial communication module. USART is also known as Serial Communication Interface SCI. IEEE UMT, Presented By Farhan Ammar Ahmad

19 Serial Programming USART can be configured full-duplex or half-duplex. Using USART you can communicate with peripherals, EEPROM or other microcontrollers IEEE UMT, Presented By Farhan Ammar Ahmad

20 Serial Programming Data is transmitted in binary. Difficult to understand unless sender and receiver agree on same protocol. Commonly used standard protocol is RS232. IEEE UMT, Presented By Farhan Ammar Ahmad

21 Serial Programming In asynchronous each character is placed between a start and stop bit and this is called framing. Normally ASCII characters are packed in frames. Data is transferred in bits per seconds. And widely used term is baud rate. IEEE UMT, Presented By Farhan Ammar Ahmad

22 Serial Programming In UART mode six registers are associated with serial. 1. SPBRG (Serial Port Baud Rate Generator) 2. TXREG (Transfer Register) 3. RCREG (Receive Register) 4. TXSTA (Transmit status and control register) 5. RCSTA (Receive status and control register) 6. PIR (Peripheral Interrupt Register) IEEE UMT, Presented By Farhan Ammar Ahmad

23 Serial Programming How to enable Asynchronous 8-bit UART mode? Calculate Baud rate and load then in SPBRG register Desired Baud Rate = Where X is valued loaded into the SPBGR and Fosc is oscillator frequency. For example Fosc=4MHz X= X= = 25 IEEE UMT, Presented By Farhan Ammar Ahmad

24 Serial Programming TXSTA (Transmit status and control register) Load “00100100” CSRC –clock source select 1 for synchronous and 0 for asynchronous TX9 – 9-bit Transmit enable 1=9-bit data and 0=8-bit data TXEN –Transmit Enable 1=Transmit Enable and 0=Transmit Disable SYNC –USART mode select 1=Synchronous and 0=Asynchronous CSRCTX9TXENSYNC0BRGHTRMTTXD9 IEEE UMT, Presented By Farhan Ammar Ahmad

25 Serial Programming BRGH –High Baud Rate Select 0=Low speed and 1=High Speed TRMT –Transmit Shift Register Status 1=TSR empty and 0=TSR Full TXD9 -9 th bit of Transmit Data If 8-bit data option then D0=0 IEEE UMT, Presented By Farhan Ammar Ahmad

26 Serial Programming RCSTA (Receive status and control register) Load “10010000” SPEN –Serial port enable bit 1=port enable and 0=port disable RX9 -9-bit receive enable 1=select 9-bit reception and 0=select 8-bit reception SREN –Single receive enable bit Not used in asynchronous mode SPENRX9SRENCRENADDEFERROERRTXD9 IEEE UMT, Presented By Farhan Ammar Ahmad

27 Serial Programming CREN –Continuous receive enable bit 1=enable and 0=disable ADDEN –Address delete enable bit Used with 9-bit, in 8-bit it is 0 FERR –Framing error bit 1=Framing error and 0=No framing error OERR –Overrun error bit 1=Overrun error and 0=No overrun error TXD9 -9 th bit of receive data In 8-bit mode it is 0 IEEE UMT, Presented By Farhan Ammar Ahmad

28 Serial Programming PIR (Peripheral Interrupt Register) RCIF –Receive Interrupt Flag bit 1=UART has received data and sitting in RCREG to be picked 0=RCREG is empty TXIF –Transmit Interrupt Flag bit 0=The TXREG register is full 1=The TXREG is empty -------- RCIFTXIF-------- IEEE UMT, Presented By Farhan Ammar Ahmad

29 Analog to Digital Conversion ADCs are most widely used devices for data acquisition. Physical world is analog but our microcontroller and microprocessors are digital. Temperature, velocity, humidity are few examples. A physical quantity is converted to electrical signal using sensor. And then analog signal is converted to digital for further processing. IEEE UMT, Presented By Farhan Ammar Ahmad

30 Analog to Digital Conversion Important factors are to considered when doing ADC. Resolution ADC has n-bit resolution. PIC16F877A supports 8 and 10 bit. Higher resolution ADC provides smaller step size. Step size is smallest change that ADC can detect. Step size can be control with Vref. Conversion Time Conversion time is time it takes the ADC to convert the analog input to Digital. Vref Vref is input voltage used for reference. Vref and resolution dictates the step size. For 8-bit step size =Vref/256. IEEE UMT, Presented By Farhan Ammar Ahmad

31 Analog to Digital Conversion Digital Data Output Dout=Vin/Step size ADC channel Many data acquisition application need more than one ADC. PIC16F877A supports 10 ADC channels. Start Conversion (SC) and End of Conversion Signals (EOC) For multiple channels, these is a single digital output register. SC and EOC is necessary. When SC is activated, ADC start converting and after conversion data is put in output register. IEEE UMT, Presented By Farhan Ammar Ahmad

32 Timers The Timer0 module timer/counter has the following features: 8-bit timer/counter Readable and writable Internal or external clock select Interrupt on overflow from FFh to 00h Edge select for external clock IEEE UMT, Presented By Farhan Ammar Ahmad

33 Thank You IEEE UMT, Presented By Farhan Ammar Ahmad


Download ppt "Criteria for choosing a microcontroller A microcontroller must meet the task at hand efficiency and cost effectively. Speed. What is highest speed of."

Similar presentations


Ads by Google