atmel and pic microcontroller
TRANSCRIPT
![Page 1: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/1.jpg)
ATMEL and PIC MicrocontrollerProgramming
usingC language
Presented by:
Engr. Tirso L. Llantada, ECE
![Page 2: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/2.jpg)
Overview
• Introduction to Microcontrollers
• Hardware Configuration
• Microcontroller Programming
![Page 3: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/3.jpg)
What is a Microcontroller(MCU)
• It is a single chip microprocessor system which contains data and program memory, serial and parallel I/O ports, timers, external and internal interrupts, ALL integrated into a single chip.
![Page 4: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/4.jpg)
Central Processing Unit(CPU)vs
Microprocessor Unit(MPU)vs
Microcontroller Unit(MCU)
![Page 5: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/5.jpg)
Central Processing Unit• this could refer to the actual processor part of a
microcontroller, the microprocessor within a computer, or the processor "box" of a computer system.
Microprocessor Unit• This devices tend to be aimed at computer
applications.
Microcontroller Unit• This devices tend to be aimed at embedded control
applications• They tend to consist of a processor plus a number of
useful peripherals (MMU, Timers, watchdog, A/D, etc, etc, etc).
![Page 6: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/6.jpg)
ALU
Control Unit
![Page 7: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/7.jpg)
ARE WE CLEAR?
![Page 8: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/8.jpg)
Microcontroller Architecture
MicroprocessorSerial
Communications(RS232)
RAM
EEPROM
ROM
Digital I/O
AnalogI/O
Other Peripherals
![Page 9: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/9.jpg)
Microcontroller Architecture
![Page 10: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/10.jpg)
What you need to know!
• Before you can make a working microcontroller project, you should first know the following:
1. Supply Voltage2. Number of I/O3. Special Purpose I/O(Serial Ports, ADC Ports, etc)4. Memory(RAM and ROM) 5. Timers/Counters6. Interrupts7. XTAL Oscillator frequency
![Page 11: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/11.jpg)
INTRODUCINGATMEL 89C2051
![Page 12: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/12.jpg)
Pin Configuration
Supply(VCC,GND)- 2.7V to 6V Operating Range I/0pins:
o Port 1 - The Port 1 is an 8-bit bi-directional I/O port. The Port 1 out-put buffers can sink 20 mA and can drive LED displays directly.
o Port 3 - Port 3 pins P3.0 to P3.5, P3.7 are seven bi-directional I/O pins with internal pull-ups.
Special Purpose I/Oo P3.0 RXD (serial input port)o P3.1 TXD (serial output port)o P3.2 INT0 (external interrupt 0)o P3.3 INT1 (external interrupt 1)o P3.4 T0 (timer 0 external input)o P3.5 T1 (timer 1 external input)
Memory(2Kbytes)
Timers/Counters - 2 16-bit timer/counter Interrupts(6 sources of interrupts)
o Reset, Timer 0 overflow, Timer 1 overflow, External Interrupt 0, External Interrupt 1, Serial Port events (buffer full, buffer empty, etc)
XTAL frequency - 0 Hz to 24 MHz
![Page 13: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/13.jpg)
Hardware Configuration
RS232
![Page 14: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/14.jpg)
Microcontroller Programming
• Traditionally, it can only be programmed using assembly language.
• But due to the complexity of assembly language, high level language were developed such as BASIC and C Programming
![Page 15: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/15.jpg)
Microcontroller Programmingusing C language
![Page 16: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/16.jpg)
Structure of Microcontroller C Programming
![Page 17: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/17.jpg)
Sample Programs
#include<AT892051.h>/*Function to delay about a secondvoid wait_a_sec(){Unsigned int x;for(x=0;x<33000;x++);}/*start of main program*/main(){int LED = 1;
for(;;){
P1=~LED;LED++;wait_a_sec();
}
}
![Page 18: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/18.jpg)
Oops! First we configure!
• Select
Project – Components, Environment, Books
![Page 19: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/19.jpg)
Configuration
• Set the following parameters
![Page 20: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/20.jpg)
Compiling the Project
• SelectProject – Build target
![Page 21: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/21.jpg)
Check Status Window
• There should be 0 errors and
0 warnings
![Page 22: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/22.jpg)
Burn the program
![Page 23: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/23.jpg)
Interrupt Subroutines
1. Interrupt subroutine for timer 1Void timer1() interrupt 3{Interrupt service code goes here}
2. Interrupt subroutine for timer 3Void timer0() interrupt 1{Interrupt service code goes here}
![Page 24: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/24.jpg)
Interrupt Sources
![Page 25: Atmel and pic microcontroller](https://reader033.vdocuments.mx/reader033/viewer/2022052203/559dd90c1a28ab3d318b47e6/html5/thumbnails/25.jpg)
BORING?Lets go with a more interesting one!