SlideShare a Scribd company logo
ATMEL and PIC Microcontroller
       Programming
           using
        C language
            Presented by:
     Engr. Tirso L. Llantada, ECE
Overview
• Introduction to Microcontrollers
• Hardware Configuration
• Microcontroller Programming
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.
Central Processing Unit(CPU)
             vs
 Microprocessor Unit(MPU)
             vs
 Microcontroller Unit(MCU)
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).
ALU

Control Unit
ARE WE CLEAR?
Microcontroller Architecture
                    EEPROM
                               RAM
                    ROM



                                            Serial
Other Peripherals    Microprocessor     Communications
                                           (RS232)



                    Analog    Digital
                     I/O       I/O
Microcontroller Architecture
What you need to know!
• Before you can make a working microcontroller
  project, you should first know the following:

1.   Supply Voltage
2.   Number of I/O
3.   Special Purpose I/O(Serial Ports, ADC Ports, etc)
4.   Memory(RAM and ROM)
5.   Timers/Counters
6.   Interrupts
7.   XTAL Oscillator frequency
INTRODUCING
ATMEL 89C2051
 Supply(VCC,GND)- 2.7V to 6V Operating Range
     Pin         I/0pins:
                    o Port 1 - The Port 1 is an 8-bit bi-directional I/O port. The
Configuration         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/O
                    o   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
Hardware Configuration

 RS232
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
Microcontroller Programming
      using C language
Structure of Microcontroller C Programming
Sample Programs
        #include<AT892051.h>
        /*Function to delay about a second
        void 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();
             }
        }
Oops! First we
   configure!
• Select
  Project – Components,
  Environment, Books
Configuration
• Set the following parameters
Compiling the
   Project
• Select
  Project – Build target
Check Status
   Window
• There should be
  0 errors and
  0 warnings
Burn the program
Interrupt Subroutines
1. Interrupt subroutine for timer 1
               Void timer1() interrupt 3
               {
               Interrupt service code goes here
               }
2. Interrupt subroutine for timer 3
              Void timer0() interrupt 1
              {
              Interrupt service code goes here
              }
Interrupt Sources
BORING?
Lets go with a more interesting one!

More Related Content

DOC
PIC MICROCONTROLLERS -CLASS NOTES
PPTX
ARM Processors
PDF
Arm instruction set
PDF
Introduction to arm architecture
PPTX
8051 Microcontroller ppt
PDF
ARM CORTEX M3 PPT
PDF
ARM Architecture
PPTX
ARM Processor
PIC MICROCONTROLLERS -CLASS NOTES
ARM Processors
Arm instruction set
Introduction to arm architecture
8051 Microcontroller ppt
ARM CORTEX M3 PPT
ARM Architecture
ARM Processor

What's hot (20)

DOCX
ARM7-ARCHITECTURE
PPTX
Digital modulation techniques...
PPTX
LCD Interacing with 8051
PPTX
Digital signal processor architecture
PPTX
Microcontrollers and its applications unit 1
PPT
8051 MICROCONTROLLER
PPTX
Vhdl programming
PPTX
4th UNIT Microwave Engineering.pptx
PPTX
ISI & niquist Criterion.pptx
PPTX
Multistage amplifier
PPT
PIC Introduction and explained in detailed
PPTX
PULSE WIDTH MODULATION &DEMODULATION
PPTX
Probabilistic Power Analysis
PDF
Microcontroller pic 16f877 architecture and basics
PPTX
Embedded Systems - Training ppt
PPTX
PIC16F877A interfacing with LCD
PPT
Arm organization and implementation
ARM7-ARCHITECTURE
Digital modulation techniques...
LCD Interacing with 8051
Digital signal processor architecture
Microcontrollers and its applications unit 1
8051 MICROCONTROLLER
Vhdl programming
4th UNIT Microwave Engineering.pptx
ISI & niquist Criterion.pptx
Multistage amplifier
PIC Introduction and explained in detailed
PULSE WIDTH MODULATION &DEMODULATION
Probabilistic Power Analysis
Microcontroller pic 16f877 architecture and basics
Embedded Systems - Training ppt
PIC16F877A interfacing with LCD
Arm organization and implementation
Ad

Viewers also liked (20)

PPSX
Programming ATmega microcontroller using Embedded C
PPTX
AVR programming - BASICS
PDF
Final Report
PDF
Thesis
PDF
Microcontrollermesin2008 aneukmesinunsyiah
PDF
An energy efficient street lightening system based on solar energy and mppt a...
PDF
12w led corn light IES
PDF
LED Corn Light 12W new
PDF
Voltage frequency converter
PPTX
Frequency to voltage converter.final
PDF
Max232
DOC
04 Sadt A4
PDF
L9 understanding-atmega328 p-2
PDF
Arduino atmega328
PDF
Max 232
PPTX
Flow chart programming
PPTX
Arduino uno lcd display 16x2
PDF
L16 usart-atmega328 p
PDF
L8 understanding-atmega328 p-1
PPT
Programming ATmega microcontroller using Embedded C
AVR programming - BASICS
Final Report
Thesis
Microcontrollermesin2008 aneukmesinunsyiah
An energy efficient street lightening system based on solar energy and mppt a...
12w led corn light IES
LED Corn Light 12W new
Voltage frequency converter
Frequency to voltage converter.final
Max232
04 Sadt A4
L9 understanding-atmega328 p-2
Arduino atmega328
Max 232
Flow chart programming
Arduino uno lcd display 16x2
L16 usart-atmega328 p
L8 understanding-atmega328 p-1
Ad

Similar to Atmel and pic microcontroller (20)

DOCX
8051 microcontroller
DOC
Embedded training report(mcs 51)
PPTX
CHAPTER1.pptx ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
PPT
Embedded systems, 8051 microcontroller
PPTX
embedded system
KEY
Introduction to Microcontrollers
PPTX
Iot Workshop NITT 2015
PDF
8449972 embedded-systems-and-model-of-metro-train
PPTX
LECT 2.pptx
PDF
MT2301_Unit II.pdf
PDF
Introduction of Arduino Uno
PPTX
Microcontroller overview 1
PDF
Download
PDF
20838382 microprocessor-8085-notes
PPTX
Embedded systems and robotics by scmandota
PDF
2 8085 microprocessor
PPTX
microcontroller 8051 hfdsdsyghydfhdsgukhdfsdgjkghu
PPTX
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
PDF
Introduction to Microcontroller
PDF
Introduction to Microcontroller
8051 microcontroller
Embedded training report(mcs 51)
CHAPTER1.pptx ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
Embedded systems, 8051 microcontroller
embedded system
Introduction to Microcontrollers
Iot Workshop NITT 2015
8449972 embedded-systems-and-model-of-metro-train
LECT 2.pptx
MT2301_Unit II.pdf
Introduction of Arduino Uno
Microcontroller overview 1
Download
20838382 microprocessor-8085-notes
Embedded systems and robotics by scmandota
2 8085 microprocessor
microcontroller 8051 hfdsdsyghydfhdsgukhdfsdgjkghu
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
Introduction to Microcontroller
Introduction to Microcontroller

Atmel and pic microcontroller

  • 1. ATMEL and PIC Microcontroller Programming using C language Presented by: Engr. Tirso L. Llantada, ECE
  • 2. Overview • Introduction to Microcontrollers • Hardware Configuration • Microcontroller Programming
  • 3. 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.
  • 4. Central Processing Unit(CPU) vs Microprocessor Unit(MPU) vs Microcontroller Unit(MCU)
  • 5. 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).
  • 8. Microcontroller Architecture EEPROM RAM ROM Serial Other Peripherals Microprocessor Communications (RS232) Analog Digital I/O I/O
  • 10. What you need to know! • Before you can make a working microcontroller project, you should first know the following: 1. Supply Voltage 2. Number of I/O 3. Special Purpose I/O(Serial Ports, ADC Ports, etc) 4. Memory(RAM and ROM) 5. Timers/Counters 6. Interrupts 7. XTAL Oscillator frequency
  • 12.  Supply(VCC,GND)- 2.7V to 6V Operating Range Pin  I/0pins: o Port 1 - The Port 1 is an 8-bit bi-directional I/O port. The Configuration 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/O o 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
  • 14. 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
  • 15. Microcontroller Programming using C language
  • 17. Sample Programs #include<AT892051.h> /*Function to delay about a second void 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(); } }
  • 18. Oops! First we configure! • Select Project – Components, Environment, Books
  • 19. Configuration • Set the following parameters
  • 20. Compiling the Project • Select Project – Build target
  • 21. Check Status Window • There should be 0 errors and 0 warnings
  • 23. Interrupt Subroutines 1. Interrupt subroutine for timer 1 Void timer1() interrupt 3 { Interrupt service code goes here } 2. Interrupt subroutine for timer 3 Void timer0() interrupt 1 { Interrupt service code goes here }
  • 25. BORING? Lets go with a more interesting one!