SlideShare a Scribd company logo
1 of 25
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

What's hot (20)

Introduction to stm32-part1
Introduction to stm32-part1Introduction to stm32-part1
Introduction to stm32-part1
 
ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
PPT ON Arduino
PPT ON Arduino PPT ON Arduino
PPT ON Arduino
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller ppt
 
STM32 MCU Family
STM32 MCU FamilySTM32 MCU Family
STM32 MCU Family
 
Introduction to ARM LPC2148
Introduction to ARM LPC2148Introduction to ARM LPC2148
Introduction to ARM LPC2148
 
Embedded Systems - Training ppt
Embedded Systems - Training pptEmbedded Systems - Training ppt
Embedded Systems - Training ppt
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration
 
ARM Micro-controller
ARM Micro-controllerARM Micro-controller
ARM Micro-controller
 
Spi in arm7(lpc2148)
Spi in arm7(lpc2148)Spi in arm7(lpc2148)
Spi in arm7(lpc2148)
 
Pic 18 microcontroller
Pic 18 microcontrollerPic 18 microcontroller
Pic 18 microcontroller
 
Hardware View of Intel 8051
Hardware View of Intel 8051Hardware View of Intel 8051
Hardware View of Intel 8051
 
EC8562 DSP Viva Questions
EC8562 DSP Viva Questions EC8562 DSP Viva Questions
EC8562 DSP Viva Questions
 
8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
Embedded System Presentation
Embedded System PresentationEmbedded System Presentation
Embedded System Presentation
 
Introduction to stm32-part2
Introduction to stm32-part2Introduction to stm32-part2
Introduction to stm32-part2
 

Viewers also liked

Programming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded CProgramming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded CVarun A M
 
AVR programming - BASICS
AVR programming - BASICSAVR programming - BASICS
AVR programming - BASICSRobotix 2011
 
Microcontrollermesin2008 aneukmesinunsyiah
Microcontrollermesin2008 aneukmesinunsyiahMicrocontrollermesin2008 aneukmesinunsyiah
Microcontrollermesin2008 aneukmesinunsyiahafdhal teknik
 
An energy efficient street lightening system based on solar energy and mppt a...
An energy efficient street lightening system based on solar energy and mppt a...An energy efficient street lightening system based on solar energy and mppt a...
An energy efficient street lightening system based on solar energy and mppt a...eSAT Journals
 
12w led corn light IES
12w led  corn  light IES12w led  corn  light IES
12w led corn light IESngt led
 
LED Corn Light 12W new
LED Corn Light 12W newLED Corn Light 12W new
LED Corn Light 12W newngt led
 
Voltage frequency converter
Voltage frequency converterVoltage frequency converter
Voltage frequency converterXi Qiu
 
Frequency to voltage converter.final
Frequency to voltage converter.finalFrequency to voltage converter.final
Frequency to voltage converter.finalprashant singh
 
Max232
Max232Max232
Max232____
 
L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2rsamurti
 
Arduino atmega328
Arduino atmega328Arduino atmega328
Arduino atmega328Luciano FS
 
Arduino uno lcd display 16x2
Arduino uno lcd display 16x2Arduino uno lcd display 16x2
Arduino uno lcd display 16x2Robomart India
 
L16 usart-atmega328 p
L16 usart-atmega328 pL16 usart-atmega328 p
L16 usart-atmega328 prsamurti
 
L8 understanding-atmega328 p-1
L8 understanding-atmega328 p-1L8 understanding-atmega328 p-1
L8 understanding-atmega328 p-1rsamurti
 

Viewers also liked (20)

Programming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded CProgramming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded C
 
AVR programming - BASICS
AVR programming - BASICSAVR programming - BASICS
AVR programming - BASICS
 
Final Report
Final ReportFinal Report
Final Report
 
Thesis
ThesisThesis
Thesis
 
Microcontrollermesin2008 aneukmesinunsyiah
Microcontrollermesin2008 aneukmesinunsyiahMicrocontrollermesin2008 aneukmesinunsyiah
Microcontrollermesin2008 aneukmesinunsyiah
 
An energy efficient street lightening system based on solar energy and mppt a...
An energy efficient street lightening system based on solar energy and mppt a...An energy efficient street lightening system based on solar energy and mppt a...
An energy efficient street lightening system based on solar energy and mppt a...
 
12w led corn light IES
12w led  corn  light IES12w led  corn  light IES
12w led corn light IES
 
LED Corn Light 12W new
LED Corn Light 12W newLED Corn Light 12W new
LED Corn Light 12W new
 
Voltage frequency converter
Voltage frequency converterVoltage frequency converter
Voltage frequency converter
 
Frequency to voltage converter.final
Frequency to voltage converter.finalFrequency to voltage converter.final
Frequency to voltage converter.final
 
Max232
Max232Max232
Max232
 
04 Sadt A4
04 Sadt A404 Sadt A4
04 Sadt A4
 
L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2
 
Arduino atmega328
Arduino atmega328Arduino atmega328
Arduino atmega328
 
Max 232
Max 232Max 232
Max 232
 
Flow chart programming
Flow chart programmingFlow chart programming
Flow chart programming
 
Arduino uno lcd display 16x2
Arduino uno lcd display 16x2Arduino uno lcd display 16x2
Arduino uno lcd display 16x2
 
L16 usart-atmega328 p
L16 usart-atmega328 pL16 usart-atmega328 p
L16 usart-atmega328 p
 
L8 understanding-atmega328 p-1
L8 understanding-atmega328 p-1L8 understanding-atmega328 p-1
L8 understanding-atmega328 p-1
 
Pic16f84
Pic16f84Pic16f84
Pic16f84
 

Similar to Atmel and pic microcontroller

8449972 embedded-systems-and-model-of-metro-train
8449972 embedded-systems-and-model-of-metro-train8449972 embedded-systems-and-model-of-metro-train
8449972 embedded-systems-and-model-of-metro-trainJitendra Saroj
 
Pc based wire less data aquisition system using rf(1)
Pc based wire less data aquisition system using rf(1)Pc based wire less data aquisition system using rf(1)
Pc based wire less data aquisition system using rf(1)Vishalya Dulam
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduinoSantosh Verma
 
Arduino_Beginner.pptx
Arduino_Beginner.pptxArduino_Beginner.pptx
Arduino_Beginner.pptxaravind Guru
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scopeArshit Rai
 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerRup Chowdhury
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollersnehapvs
 
Microcontroller from basic_to_advanced
Microcontroller from basic_to_advancedMicrocontroller from basic_to_advanced
Microcontroller from basic_to_advancedImran Sheikh
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the ArduinoWingston
 
Best-embedded-corporate-training-in-mumbai
Best-embedded-corporate-training-in-mumbaiBest-embedded-corporate-training-in-mumbai
Best-embedded-corporate-training-in-mumbaiUnmesh Baile
 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf818Farida
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scopeArshit Rai
 
programmable logical controller(PLC)
programmable logical controller(PLC)programmable logical controller(PLC)
programmable logical controller(PLC)hemadri sharma
 

Similar to Atmel and pic microcontroller (20)

8449972 embedded-systems-and-model-of-metro-train
8449972 embedded-systems-and-model-of-metro-train8449972 embedded-systems-and-model-of-metro-train
8449972 embedded-systems-and-model-of-metro-train
 
Pc based wire less data aquisition system using rf(1)
Pc based wire less data aquisition system using rf(1)Pc based wire less data aquisition system using rf(1)
Pc based wire less data aquisition system using rf(1)
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduino
 
Embedded system
Embedded  systemEmbedded  system
Embedded system
 
Arduino_Beginner.pptx
Arduino_Beginner.pptxArduino_Beginner.pptx
Arduino_Beginner.pptx
 
Iot Workshop NITT 2015
Iot Workshop NITT 2015Iot Workshop NITT 2015
Iot Workshop NITT 2015
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontroller
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
unit-2.pptx
unit-2.pptxunit-2.pptx
unit-2.pptx
 
Microcontroller from basic_to_advanced
Microcontroller from basic_to_advancedMicrocontroller from basic_to_advanced
Microcontroller from basic_to_advanced
 
PILOT Session for Embedded Systems
PILOT Session for Embedded Systems PILOT Session for Embedded Systems
PILOT Session for Embedded Systems
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
 
Best-embedded-corporate-training-in-mumbai
Best-embedded-corporate-training-in-mumbaiBest-embedded-corporate-training-in-mumbai
Best-embedded-corporate-training-in-mumbai
 
Microcontroller 8051 gs
Microcontroller 8051 gsMicrocontroller 8051 gs
Microcontroller 8051 gs
 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
 
Embedded systemsc
Embedded systemscEmbedded systemsc
Embedded systemsc
 
programmable logical controller(PLC)
programmable logical controller(PLC)programmable logical controller(PLC)
programmable logical controller(PLC)
 
Microcontroller at89 s52 datasheet
Microcontroller at89 s52 datasheetMicrocontroller at89 s52 datasheet
Microcontroller at89 s52 datasheet
 

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!