0% found this document useful (0 votes)
5 views4 pages

Microcontroller Functions and Examples

The document provides an overview of various microcontrollers, including PIC, ATmega, Atmel (8051), and ARM, detailing their functions, working principles, and example code for LED blinking. Each microcontroller type is described with its architecture, memory usage, and applications in embedded systems, automation, and consumer electronics. The examples illustrate basic programming for each microcontroller, showcasing their capabilities in controlling outputs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Microcontroller Functions and Examples

The document provides an overview of various microcontrollers, including PIC, ATmega, Atmel (8051), and ARM, detailing their functions, working principles, and example code for LED blinking. Each microcontroller type is described with its architecture, memory usage, and applications in embedded systems, automation, and consumer electronics. The examples illustrate basic programming for each microcontroller, showcasing their capabilities in controlling outputs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Microcontrollers

PIC Microcontroller
Functions

 Executes control programs for embedded systems

 Interfaces with sensors, LCDs, motors, relays

 Performs ADC (Analog to Digital Conversion)

 Supports timers, counters, PWM, serial communication (UART, SPI, I²C)

 Used in automation, consumer electronics, and control systems

Working

 Uses Harvard architecture (separate program and data memory)

 Program is stored in Flash memory

 CPU fetches instruction → decodes → executes

 Inputs are read through I/O ports

 Output signals control external devices

 Interrupts allow fast response to external events

Example Code (LED Blink – PIC16F877A):


#include <xc.h>
#pragma config FOSC = HS
#define _XTAL_FREQ 20000000

void main() {
TRISB0 = 0;
while(1) {
RB0 = 1;
__delay_ms(500);
RB0 = 0;
__delay_ms(500);
}}
ATmega Microcontroller
Functions

 Controls digital and analog devices

 Provides ADC, PWM, timers, watchdog timer

 Serial communication (UART, SPI, I²C)

 Low power operation (sleep modes)

 Widely used in Arduino boards

Working

 Based on AVR RISC architecture

 Executes most instructions in one clock cycle.

 Program stored in Flash memory

 Data stored in SRAM and EEPROM

 I/O ports interact with peripherals

 Interrupt system handles real-time tasks

Example Code (LED Blink – ATmega328):

void setup() {
pinMode(13, OUTPUT);
}

void loop() {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}
Atmel Microcontroller (8051)
Functions

 Embedded control in industrial and consumer products

 Handles digital processing, ADC, timers, communication

 Supports power-saving modes

 Used in robotics, IoT, home automation

Working

 Uses RISC architecture

 Program execution via fetch–decode–execute cycle

 Built-in peripherals reduce external hardware

 Can be programmed using C/Assembly

 Supports ISP (In-System Programming)

Example Code (LED Blink – AT89C51):

#include <reg51.h>

void delay() {
int i, j;
for(i=0; i<100; i++)
for(j=0; j<1000; j++);
}

void main() {
while(1) {
P1 = 0x01;
delay();
P1 = 0x00;
delay();
}
}
ARM Microcontroller
Functions

 High-performance processing

 Executes complex algorithms

 Supports RTOS (Real-Time Operating System)

 Advanced communication (USB, CAN, Ethernet)

 Used in smartphones, medical devices, automotive systems

Working

 Uses 32-bit RISC architecture

 Program stored in Flash memory

 Pipeline execution increases speed

 NVIC (Nested Vector Interrupt Controller) manages interrupts

 Supports low-power and high-speed modes

 Can run bare-metal or OS-based applications

Example Code (LED Blink – ARM Cortex-M):

#include "stm32f4xx.h"

int main(void) {
RCC->AHB1ENR |= 1;
GPIOA->MODER |= 1 << 10;

while(1) {
GPIOA->ODR ^= 1 << 5;
for(int i=0; i<1000000; i++);
}
}

You might also like