Programing Microcontroller -The Embedded World!

@geek_explorer

Vikrant thakur

1st September 2019

 

#include <stdio.h>
void main()
{
 printf('Welcome to the world of controllers');
}

Vikrant Thakur

Software engineer, open-source hardware enthusiastic.
Currently working as an R&D hardware engineer at Thingify. In the past, worked with Lenovo and DRDO as Research Intern.

He is a geek with a keen interest in IoT and embedded domain as well have strong exposure to product development, market research,hardware research among many others.
He frequently shares his knowledge in IoT community and mentors students in the field of electronics, hardware and embedded.

 

What is Microcontroller?

A programmable chip designed in a way that it embeds certains features such as on-board flash(ROM)-program memory, RAM-Data Memory ,CPU,ADC ,I/O ports & serial ports 

Who Invented Microcontroller?

Gary Boone of Texas Instruments created first micro controller TMS1802NC.

Gary Boone of Texas Instruments created first microcontroller TMS1802NC.

Characterisitics of Embedded system

  • Sophisticated functionality
  • Real time OS -RTOS or Linux -Maybe or Maybe not
  • Low manufacturing cost
  • Restricted memory
  • Low Power consumption

THE IMPORTANT ASPECT OF THE EMBEDDED SYSTEM IS TO REACH NECESSARY PERFORMANCE AT THE LOWEST COST

NASA Sojourner uses a 8-bit microprocessor

Macbook charger uses MSP430 controller

Generic Examples

Sony Aibbo uses a 64 bit RISC processor

Products based on embedded controllers...

Architecture Basics 

On the basis of Instruction set :-

RISC and CISC

        Apple phone processor is RISC based processors

        Intel processor are mostly CISC based processors

On the Basic of memory architecture:-

 

Modified PIC 18 F Hardvard architecture

Von Neumann Architecture

Operating System Based Architecture 

ABSTRACTION

Power Circuitary 

              Components for bringing up a microcontroller

                    Power supply ->230 AC to 5V DC

  • LM7805 : Fixed positive voltage regulator
  • LM1117-3.3 : 800mA low-dropout linear regulator
  • LM431: 3-terminal adjustable shunt regulator with temperature stability
  • FDN340P : P-Channel logic level MOSFET–2A, 20 V
  • 1N5817 : Schottky barrier rectifier 1A, 20V

Reset Button-> Activate the register -(Non maskable Hardware Interrupt) to start  the microcontroller from starting of program chip address (0x00).

Oscillator circuitary ->Provide external high resolution clock to the controller

Power supply vs Frequency curve

ATmega 328p.

Programing Microcontrollers

Why C Programing is used till this date as we have so many objective orientated lanuguages ?

Light weight compliers and directly it can communicate with hardware

Pointers

// example code for pointers

long *pt;       // pointer to 32-bit data
long data;      // 32-bit
long buffer[4]; // array of 4 32-bit numbers
int main(void)

{
  pt = &buffer[1];
  *pt = 1234;
  data = *pt;
  return 1;
}

More examples regarding pointers!

int compare (const void * a, const void * b) 
{ 
  return ( *(int*)a - *(int*)b ); 
} 
  
int main () 
{ 
  int arr[] = {10, 5, 15, 12, 90, 80}; 
  int n = sizeof(arr)/sizeof(arr[0]), i; 
  
  qsort (arr, n, sizeof(int), compare); 
  
  for (i=0; i<n; i++) 
     printf ("%d ", arr[i]); 
  return 0; 
} 
void swap (int *a, int *b);
int main() 
{
  int m = 25;
  int n = 100;
  printf("m is %d, n is %d\n", m, n);
  swap(&m, &n);
  printf("m is %d, n is %d\n", m, n);
  return 0;
}
void swap (int *a, int *b) 
{
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;}
}

Why there is a need to reduce the size of program?

// program for arduino uno

int x;

int sensor_data[1000];

void setup()
{


}

void loop
{

sensor_data[x++]=x;

}

//In place of int ,uint32_t  is used then it will give error

In embedded memory restriction are there!

Interrupts!

Interrupts make the programing in microcontroller more optimised reducing delay!.

Are Interrupts desirable?

ISR -Interrupt service routine

Types of ISR

Thanks

Thanks !

Programing Microcontroller -The Embedded World

By Vikrant Thakur

Programing Microcontroller -The Embedded World

This small tech talk was presented in hardware hacker community

  • 315