🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

week 1 microcontroller.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Document Details

RomanticViolin

Uploaded by RomanticViolin

Tags

microcontroller interfacing embedded systems

Full Transcript

EET-323 Microcomputer Interfacing School of Engineering Technology & Applied Science (SETAS) Week # 1 Microcontroller Objects Numbering conversion History of microcontroller Microprocessor VS M...

EET-323 Microcomputer Interfacing School of Engineering Technology & Applied Science (SETAS) Week # 1 Microcontroller Objects Numbering conversion History of microcontroller Microprocessor VS Microcontroller Microcontroller hardware architecture Memory organization Registers TRIS and PORT EET-323: Week #1 2 Numbering Conversion Human prefers decimal (2510) Machine prefers binary (11012) Programmer prefers hexadecimal (1916) EET-323: Week #1 3 History of Microcontroller In the 1940s, US government asked Harvard and Princeton university to come up with a computer architecture to be used in computing tables of naval artillery shell distances for varying elevation and environmental conditions. Princeton architecture won the competition because it was better suited to the technology of the time. (even before transistors were invented) Harvard architecture was largely ignored until the late 1970s, because uC manufacturers realized that the architecture did not have the instruction/data bottleneck. PIC MCU (Micro Computer Unit) employs the Harvard architecture. (PIC: Peripheral Interface Controller) EET-323: Week #1 4 Examples of 8-Bit uC Microchip: PIC10XXX, PIC12XXX, 14, 16, 18) - PIC16F747 will be used in our lab. Intel 8051 Atmel AVR and 8051 Philips 8051 Zilogs Z8 and Z80 Freescale 68HC11 and 68HC08 * Note: – PIC16FXXX has on-chip program ROM (Read-Only Memory) in form of flash memory type EEPROM (Electronically Erasable Programmable Read-Only Memory), it is great for testing and prototyping. – PIC16CXXX has program ROM in form of OTP memory (One-Time Programmable), it is great for mass production (low cost). EET-323: Week #1 5 Microprocessor VS Microcontroller EET-323: Week #1 6 Microcontroller Selection Microcontrollers are selected based on: Computing needs (Speed, RAM, ROM, I/O…etc) Power consumptions Availability and accessibility of software and hardware such as compiler, assembler, debugger, emulator…etc Wide variety and reliable sources (Manufacturers) Cost per unit EET-323: Week #1 7 PIC Microcontroller The PIC uC uses RISC (Reduced Instruction Set Computer) architecture It comes with standard features such as; - On-chip program ROM for storing codes or instructions - RAM for storing data (volatile or temporary) - EEPROM for storing data (none-volatile or permanent) - I/O ports for interfacing with outside world - Timer for creating delays - Counter for counting events - ADC (Analog to Digital Converter) for converting continues variable to binary number - USART (Universal Synchronous Asynchronous Receiver Transmitter) for communications EET-323: Week #1 8 PIC MICROCONTROLLER Feature Comparison PIC16F747 PIC16F767 PIC18F4580 Program Memory (ROM) 4096 8192 8192 Data Memory (RAM) 368 368 768 Data Memory (EEPROM) None None 256 Input / Output 36 23 36 Timer 3 3 4 # of ADC 14 11 11 # of Pins 28/40/44 28/40/44 28/40/44 EET-323: Week #1 SETAS - AMAT: EET-323 Week #1 9 PIC MICROCONTROLLER Hardware Architecture EET-323: Week #1 10 PIC MICROCONTROLLER Programming PIC uC - Programmer ICSP (In-Circuit Serial Programmer) is an interface used to program PIC uC PICkit 2 and 3 are used as Programmer and Debugger Programming pin configurations: Pin # Name Functions 1 MCLR Master Clear/Reset (Active Low) 2 VDD 5V Power 3 VSS 0V (Ground) Power 4 PGD Programming Data 5 PGC Programming Clock EET-323: Week #1 11 PIC MICROCONTROLLER Programming PIC uC - Software MPLAB x IDE is used to program a PIC uC. Compilers: mpasm= assembly language XC8 = C language Simple C programming could also be done on Code blocks (optional) or Notepad++ EET-323: Week #1 12 MEMORY ORGANIZATION ROM – Read Only Memory EET-323: Week #1 13 MEMORY ORGANIZATION RAM (Random Access Memory) RAM: - SFR (Special Function Register) - GPR (General Purpose Register) SFRs are dedicated to specific functions such as ALU Status, Port, Timer, ADC …etc. It has a fixed hardware address. Ex: STATUS 03h PORTA ? TRISA ? GPRs are used for data storage and scratch pad, 8 bits of data can be stored in each location or address. EET-323: Week #1 14 MEMORY ORGANIZATION Data Memory Map Bank 0 Bank 1 Bank 2 Bank 3 EET-323: Week #1 Page 19 of the Data Sheet 15 Registers CPU uses many registers to store data temporarily. WREG (Working Register) is the most important one which plays a role in processing data for Assembly language. WREG is used for all arithmetic and logic operations. WREG can only store 8 bits of data. Note: Any data larger than 8 bits must be broken into 8-bit chunks or byte (8 bit) size before it is able to process. EET-323: Week #1 16 REGISTERS Working Register (WREG) Arithmetic Logic Unit EET-323: Week #1 17 REGISTERS Status Register (STASTUS) - 1 The Status register contains the arithmetic status of the ALU, the Reset status and the bank select bits for data memory. The data memory is partitioned into 4 different banks (0-3) which contain the GPR and SFR. Bits RP1 (Status ) and RP0 (Status ) of STATUS Register are the bank select bits. (Ref. p21 of Data Sheet) You must select the proper bank to access/use the data memory. EET-323: Week #1 18 REGISTERS Status Register (STASTUS) - 2 ex) BSF STATUS, 5 ;access file registers bank 1 MOVLW 0xFF ;load value to WREG MOVWF TRISD ;make PORTD as input BCF STATUS, 5 ;access file registers bank 0 MOVF PORTD, W ;copy PORT D value to WREG MOVWF PORTB ;copy WREG value to PORT B BSF (Bit set file): Makes the particular bit (5 in this example) of the STATUS register 1 (set). In order to use TRISD register, Bank 1 is accessed. BCF (Bit clear file): Clears the bit 5 of the STATUS register. After tasks are done in bank 1, now Bank 0 is accessed in order to use PORT registers. EET-323: Week #1 19 REGISTERS TRIS and PORT Register - 1 PORT is an I/O point that allows microcontroller to interact with outside world. Some pins for these I/O Ports are multiplexed with an alternate function for the peripheral features on the device. TRIS determines PORT’s direction as input or output. Set TRIS bit (= 1) will make PORT’s pin input Clear TRIS bit (= 0) will make PORT’s pin output ex) TRISA = 0xFF ➔ PORTA = input TRISB = 0 x00 ➔ PORTB = output EET-323: Week #1 20 REGISTERS TRIS and PORT Register - 2 EET-323: Week #1 21

Use Quizgecko on...
Browser
Browser