0% found this document useful (0 votes)
10 views17 pages

(MCU) Lecture1 - Introduction

The document outlines a course on Micro-Processing Systems, focusing on microcontrollers and microprocessors, with a structure of 15 weeks of lectures and 6 weeks of labs. It includes information on project requirements, programming languages, and applications of microcontrollers in various fields. Key concepts such as the differences between microcontrollers and microprocessors, as well as programming techniques using C language and finite state machines, are also discussed.

Uploaded by

tangphont
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views17 pages

(MCU) Lecture1 - Introduction

The document outlines a course on Micro-Processing Systems, focusing on microcontrollers and microprocessors, with a structure of 15 weeks of lectures and 6 weeks of labs. It includes information on project requirements, programming languages, and applications of microcontrollers in various fields. Key concepts such as the differences between microcontrollers and microprocessors, as well as programming techniques using C language and finite state machines, are also discussed.

Uploaded by

tangphont
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Micro Processing System

Micro-Controller and Micro-Processor


Unit

LÊ TRỌNG NHÂN
[email protected]
[email protected]
Zalo Group [CLC]
▪ 15 weeks for Lectures
▪ 6 weeks for Labs (30%)
▪ MCQs for Mid-term (20%)
▪ MCQs for Final-term (50%)
▪ Final project: +2 maximum

3
15 Weeks for Lectures
▪ Understand microcontroller basics including all
common interfaces:
▫ General Input/Output GPIO (LEDs, Buttons)
▫ Interrupts: Timer Interrupt
▫ Serial communications: UART, I2C, SPI

▪ Final projects:
▫ Validate on hardware platforms
▫ Group of 3 students
▫ Presentations and Demos

5
6 Weeks for Labs
▪ Software requirements:
▫ STMCubeIDE
▫ Proteus simulations
▫ Github

▪ Reports are required to submit

6
24h Project for Midterm
▪ A project is given and students have 24 hour to
submit
▪ The format is similar to the LAB:
▫ Project description
▫ Project manual
▫ 5 – 10 steps to finalize the project

▪ Topic is related to LED – Buttons – Timer Interrupt

▪ Programing on STM32CubeIDE
▪ Simulate on Proteus
▪ Submit the Report for evaluation
7
Microcontroller and Microprocessor
Applications
▪ Networking & communications
▪ phones, modems, switches, routers, signal processors

▪ Embedded products & systems


▪ consumer electronics, appliances, entertainment
devices, medical devices, security, transportation

▪ Scientific instruments & equipment


▪ simulation, testing, sensing, logging, reporting,
analyzing

▪ Many more.
8
Microprocessor vs Microcontroller

MPU MCU
Stand-alone CPU, RAM, CPU, RAM, ROM and IO
ROM and IO (and Timer) (and Timer) are all on a
are separated single chip
ROM, RAM and IO can be ROM, RAM and IO are fixed
customized
Expensive, versatility and Low cost, power and single-
general purpose purpose (control-oriented)
High resource of power, Low resource of power,
processing and memory (for processing and memory (for
AI inferences) device controller)
Normal Operating System Real Time Operating
(32 or 64 bits) System (8 or 16 bit)

9
Micro-Controller Platform
▪ Micro-Controller Unit (MCU) contains
RAM, ROM and IO
▪ Micro-Processor Unit (MPU) only
contains the CPU
▪ System on Chip (SoC) refers to MCUs
with a greater number of onboard
peripherals and functionality

http://www.ti.com http://www.microchip.com
1
Program on MPU vs MCU

1
Warm up Exercises
▪ LED turns on and off every second (LED Blinky)

▪ LED turns on for 3 seconds and then turns off for


5 second.

▪ Digital Clock with hour, minute and second

▪ Change the delay from 1000 to 10

1
C Language: Header and C++ Files

#include “led.h”
#ifndef __LED_H_
#define __LED_H_
int T_on;
int T_off;
#include <system_lib.h>
int counter;
#include “user_lib.h”
#include “UserFolder/lib.h”
void setOn(long duration){
//TODO: set LED on here
extern int T_on;
}
extern int T_off;
void setoff(long duration){
//TODO: set LED off here
void setOn(long duration);
}
void setoff(long duration);
void delay(long duration){
//TODO: set delay here
#endif
}
1
C Language: Main File
#include “led.h” ▪ Modules/ Libraries
#include “timer.h” are included
#include “gpio.h”
#include “button.h”

void main(){
initGPIO(); ▪ Modules/ Libraries
LED
initTimer(); are initiated
initButton();
initLED();
TIMER
….
….
while(1){};
GPIO }
void timer_isr(){ ▪ System operations
} are implemented in
BUTTON void ext_isr(){ interrupt functions
}
1
Finite State Machine (FSM)
▪ Finite-State Machine (FSM) or Deterministic Finite
Automata (DFA), finite automaton, or simply a state
machine, is a mathematical model of computation
Current Input Next State
State
Locked Coin Unlocked
Push Locked
Unlocked Coin Unlocked
A turnstile
Push Locked

1
Finite State Machine Programming
while(1){
switch(status){
case LOCKED:
lock_turnstile(); //operation in a state
if(Coin == true) //transition condition
status = UNLOCKED; //next state
break;
case UNLOCKED:
unlock_turnstile(); //operation in a state
if(Push == true) //transition condition
status = LOCKED; //next state
break;
default:
break;
}
}
1
Example
▪ Given an LED turns on for T_on and then turns off
for T_off.
▫ Design an DFA for this LED
▫ Implement the DFA in Arduino

▪ digitalWrite(13, HIGH): turn on the LED


▪ digitalWrite(13, LOW): turn off the LED
▪ setTime(duration): set a clock (timer_flag =
0), when the clock is expired, timer_flag = 1;
duration is in mili-seconds.

1
Answer
timer_flag == 1

INIT LED_ON LED_OFF


timer_flag == 1

▪ INIT: Set pin 13 to OUTPUT mode, set timer


▪ LED_ON: Turn on the LED
▪ LED_OFF: Turn off the LED

1
Answer (Arduino Code)
void loop(){
switch(status){ void timer_run(){
case INIT: if(timer_counter > 0)
pinMode(13, OUTPUT);
timer_counter--;
setTimer(T_on);
status = LED_ON; if(counter_timer == 0)
digitalWrite(13, HIGH); timer_flag =1;
break; }
case LED_ON:
void setTimer(long duration){
if(timer_flag == 1){
status = LED_OFF; timer_counter = duration;
setTimer(T_off); timer_flag = 0;
digitalWrite(13, LOW); }
}
break;
case LED_OFF:
if(timer_flag == 1){
status = LED_ON;
setTimer(T_on);
digitalWrite(13, HIGH);
}
break;

default:
break;
}
delay(10);
} 1

You might also like