Presentation 1
Presentation 1
Presentation 1
Processor Vs MCU
Key feature
Advantage
Customer benefit
Saving power
Saving power
Ease of design
Features of LPC1768
Applications
eMetering
Lighting
Industrial networking
Alarm systems
White goods
Motor control
Embedded C Programming
Most computers having a unified memory space, with the code and data sharing the same
RAM.
8051 has separate memory spaces for code, on-chip data, and external data.
Microcontrollers were originally programmed only in assembly language, but various highlevel programming languages are in common use to target microcontrollers.
These languages are general purpose languages such as the C programming language.
Compilers for general purpose languages will typically have some restrictions as well as
enhancements to better support the unique characteristics of microcontrollers.
Microcontroller vendors often make tools freely available to make it easier to adopt their
hardware.
C for Microcontrollers
Of higher level languages, C is the closest to
assembly languages
bit manipulation instructions
pointers (indirect addressing)
C Language
Embedded C Language
Available C Compilers
Keil integrated with the IDE we have been using for labs.
Keil Software
One of the most complete development tool suites for 8051 software, which is used
throughout industry.
For development of C code, their Developer's Kit product includes their C51 compiler, as well
as an integrated 8051 simulator for debugging.
The C programming language was designed for computers, though, and not embedded
systems. It does not support direct access to registers, nor does it allow for the reading and
setting of single bits, two very important requirements for 8051 software.
Most of software developers are accustomed to writing programs that will by executed by an
operating system, which provides system calls, the program may use to access the hardware.
But code is written for direct use on the processor, without an operating system. To support
this, the Keil compiler has added several extensions to the C language to replace what might
have normally been implemented in a system call, such as the connecting of interrupt
handlers.
Prototyping form-factor
40-pin 0.1" pitch DIP package, 54x26mm
5V USB, 4.5-9V supply or 2.4-3.3V battery
Built-in USB drag 'n' drop FLASH programmer
Features
On-chip SRAM
64 kB on-chip static RAM memory
32 kB SRAM
Two additional 16 kB SRAM
Memory Map
Several distinct memory regions
Features
Bit level set and clear registers allow a single instruction to
set or clear any number of bits in one port.
Direction control of individual bits.
All I/O default to inputs after reset.
USB interface
2-wire bus supports communication between a
host and one or more (up to 64) peripherals.
Features
Fully compliant with USB 2.0 specification (full speed).
Supports 32 physical (16 logical) endpoints with a 4 kB
endpoint buffer RAM.
Supports Control, Bulk, Interrupt and Isochronous endpoints.
Scalable realization of endpoints at run time.
Ethernet
12-bit ADC
Contain one ADC(12-bit successive approximation
ADC)
DMA support.
10-bit DAC
Generate a variable analog output.
The maximum output value of the Vi(VREFP .
10-bit DAC
)
CAN controller
The Controller Area Network (CAN) is a serial
communications protocol which efficiently
supports distributed real-time control with a
very high level of security.
The CAN block is intended to support multiple
CAN buses simultaneously.
Features
Data rates to 1 Mbit/s on each bus.
Compatible with CAN specification 2.0B, ISO 11898-1.
Acceptance Filter can provide FullCAN-style automatic
reception for selected Standard Identifiers.
Signing up or Logging In
Connect mbed board to
host machine using a USB
cable
Board presents itself as a
flash drive named MBED
To sign up or log in, double
click on html file in MBED
drive
Sign up or Log in using your
existing username &
password
Keep mbed board facing you with USB port pointing left
Start with Pin 1 at bottom left extreme, move from left to
right (incrementing pin numbers on the way), to Pin 20.
Then crossover to upper right to Pin 21, move from right
to left, incrementing pin numbers on the way, to Pin 40
Pin 1 0.0 V (GND)
Pin 40 3.3 V (VDD)
Pin 39 5.0 V (USB Source)
Use of LED
Longer pin is positive or anode
Shorter is negative or cathode
#include "mbed.h
DigitalOut led(p5);
int main()
{
led = 1;
led = 0;
}
Two Digital GPIO pins drive LED anodes mbed Pins 5 & 6
Connect both LED cathodes to GND, which is mbed Pin 1
mbed Interface DigitalOut in code configures Pins 5 and 6 as
Digital Outputs
Code:
#include "mbed.h"
DigitalOut redled(p5);
DigitalOut greenled(p6);
int main() {
while(1) {
redled = 1; greenled = 0;
wait(0.9);
redled = 0; greenled = 1;
wait(0.9);
}
}
7-segment Display
Use common-anode 7-segment display
Identify 7-segment Display pins
LED segments, including decimal point
Pins 3 or 8 are common-anode pins
Pins 1, 2, 4, 5, 6, 7, 9 and 10 are cathodes
dp G F E D C B A
HEX Combination
1000000
C0
1111001
F9
0100100
A4
0110000
B0
0011001
99
0010010
92
0000010
82
1111000
F8
0000000
80
0010000
90
10
11
10
12
Dp
40
3 or 8
CA
#include "mbed.h"
BusOut Disp1(p5,p6,p7,p8,p9,p10,p11,p12);
/ / ABCDEFGdp
int main() {
while (1) {
// infinite loop
Disp1 = 0xC0; wait(0.9)
// Displays '0'
Disp1 = 0xF9; wait(0.9)
// Displays '1'
Disp1 = 0xA4; wait(0.9)
// Displays 2'
Disp1 = 0xB0; wait(0.9)
// Displays 3'
Disp1 = 0x99; wait(0.9)
// Displays 4
Disp1 = 0x92; wait(0.9)
// Displays 5'
Disp1 = 0x82; wait(0.9)
// Displays 6'
Disp1 = 0xF8; wait(0.9)
// Displays 7'
Disp1 = 0x80; wait(0.9)
// Displays 8'
Disp1 = 0x90; wait(0.9)
// Displays 9'
}
}
Improves Efficiency
Uses HW/SW machine resources efficiently, may even
speed up performance
Reuse
Helps to develop new code rapidly using chunks
(modules) of previously written code
#include "mbed.h"
BusOut Disp1(p5,p6,p7,p8,p9,p10,p11,p12);
// ABCDEFGDP
int Hex[ ] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80,
0x90};
// Module - Array
int main()
{
while (1)
{
// infinite loop
for (int i = 0; i <= 9; i++)
{
Disp1 = Hex[i];
wait(0.9);
}
}
}