ubc104 embedded systems microcontroller / 8051 family
Post on 21-Dec-2015
273 Views
Preview:
TRANSCRIPT
UBC104 Embedded Systems
Microcontroller / 8051 family
UBC 104 Embedded Systems 2
Topics for Today
Microcontrollers Memory Registers Ports
UBC 104 Embedded Systems 3
Processors
General purpose processors: 80386 Pentium Core Duo
Large number of pins External memory External peripherals
* Figure from Intel 386 DX Datasheet
UBC 104 Embedded Systems 4
Functions of Pins
Designed to be generic Indented to move data around
* Figure from Intel 386 DX Datasheet
UBC 104 Embedded Systems 5
General Purpose Registers Registers are dedicated for
moving data EAX, EBX, ECX, EDX: general
purpose registers EBP: Base pointer ESP: Stack pointer ESI, EDI: Index register
UBC 104 Embedded Systems 6
Pentium
* Figure from Intel Pentium Datasheet
Bigger,
better,
more
UBC 104 Embedded Systems 7
Microcontrollers
Support for peripherals inside uController Limited number of pins Dedicated purpose
Controlling devices, taking measurements
UBC 104 Embedded Systems 8
Microcontroller Families
68H12: Motorola 68H11, 68HC12, … 8051: Intel 8051, 8052, 80251,… PIC: Microchip PIC16F628, 18F452, 16F877, … AVR: Atmel ATmega128, ATtiny28L, AT90S8515,…
UBC 104 Embedded Systems 9
Rita51J 8051
128K of SRAM 128K FLASH ROM
Serial port Digital I/O lines
* Figure from www.rigelcorp.com
UBC 104 Embedded Systems 10
Motes
Sensor nodes based on Atmel ATMega128
* Figures from CrossbowMPR-MIBUser Manual
UBC 104 Embedded Systems 11
AT91SAM7P64 16/32 bit ARM7TDMI 64K Bytes Program
Flash, 16K Bytes RAM,
USB 2.0 10 bit ADC 384 ksps
2x UARTs I2C, SPI 3x 32bit TIMERS 4x PWM, WDT
* Figure from www.olimex.com
UBC 104 Embedded Systems 12
AT91SAM7P64
* Figure from www.olimex.com
UBC 104 Embedded Systems 13
Microcontroller Families
68H12: Motorola 68H11, 68HC12, … 8051: Intel 8051, 8052, 80251,… PIC: Microchip PIC16F628, 18F452, 16F877, … AVR: Atmel ATmega128, ATtiny28L, AT90S8515,…
We are going to look at 8051s
UBC 104 Embedded Systems 14
8051 History
Introduced 1980 12 MHz 128 bytes Internal RAM 4 kbytes ROM 1 Serial port support
UBC 104 Embedded Systems 15
Typical features of modern 8051
32 input / output lines. Internal data (RAM) memory - 256 bytes. Up to 64 kbytes of ROM memory (usually flash) Three 16-bit timers / counters 9 interrupts (2 external) with two priority levels. Low-power Idle- and Power-down modes
UBC 104 Embedded Systems 16
8051 Manufacturers AMD: Enhanced 8051 parts (no longer producing 80x51 parts) Atmel: FLASH and semi-custom parts Dallas: Battery backed, program download, and fastest variants Intel: 8051 through 80c51gb / 80c51sl ISSI: IS80C51/31 runs up to 40MHz Matra: 80c154, low voltage static variants OKI: 80c154, mask parts
Philips87c748 thru 89c588 - more variants than anyone else now NXP
Siemens: 80c501 through 80c517a, and SIECO cores SMC: COM20051 with ARCNET token bus network engine SSI: 80x52, 2 x HDLC variant for MODEM use
from http://www.faqs.org/faqs/microcontroller-faq/8051/
UBC 104 Embedded Systems 17
Selection of Atmel 8051DevicesDevice Flash
(Kbytes)RAM
(Bytes)F.max (MHz)
Vcc (V)
I/O Pins
UART
16-bit Timer
s
SPI 10-bit A/D
channels
AT89C5115 16 512 40 3-5.5 20 1 2 -- 8
AT89C51AC2 32 1280 40 3-5.5 34 1 3 -- 8
AT89C51AC3 64 2304 60 3-5.5 32 1 3 Yes 8
AT89C51ED2 64 2048 60 2.7-5.5 32 1 3 Yes --
AT89C51IC2 32 1280 60 2.7-5.5 34 1 3 Yes --
AT89C51ID2 64 2048 60 2.7-5.5 32 1 3 Yes --
AT89C51RB2 16 1280 60 2.7-5.5 32 1 3 Yes --
AT89C51RC 32 512 33 4.0-6.0 32 1 3 -- --
AT89C51RC2 32 1280 60 2.7-5.5 32 1 3 Yes --
AT89C51RD2 64 2048 60 2.7-5.5 32 1 3 Yes --
AT89C51RE2 128 2048 60 2.7-5.5 34 2 3 Yes --
* Figure from Atmel Function Spreadsheet
UBC 104 Embedded Systems 18
Datasheets – Your New Friends!
* Figure from Atmel AT89C51RD2 Datasheet
UBC 104 Embedded Systems 19
Packaging
Plastic Dual In-Line package (PDIL)* Figure from Atmel AT89C51RD2 Datasheet
UBC 104 Embedded Systems 20
Packaging I
Very small Quad Flat Package (VQFP)
* Figure from Atmel AT89C51RD2 Datasheet
UBC 104 Embedded Systems 21
Packaging II
Plastic Leaded Chip Carrier (PLCC)
* Figure from Atmel AT89C51RD2 Datasheet
UBC 104 Embedded Systems 22
Packaging
UBC 104 Embedded Systems 23
Pin-Out of an 8051
UBC 104 Embedded Systems 24
8051 Components
Ports RAM Interrupt Controller Timer SPI Controller
* Figure from Atmel AT89C51RD2 Datasheet
UBC 104 Embedded Systems 25
MCBX51 Board
UBC 104 Embedded Systems 26
MCBx51 Board
* Figure from MCBx51 Datasheet
UBC 104 Embedded Systems 27
8051 Internal RAM
* Figure from Atmel AT89C51RD2 Datasheet
UBC 104 Embedded Systems 28
Special Function Registers (SFRs)
* Figure from Atmel AT89C51RD2 Datasheet
UBC 104 Embedded Systems 29
Special Function Registers (SFR)
* Figure from Atmel AT89C51RD2 Datasheet
UBC 104 Embedded Systems 30
Special Function Registers (SFR)
* Figure from Atmel AT89C51RD2 Datasheet
UBC 104 Embedded Systems 31
* Figure from Atmel AT89C51RD2 Datasheet
UBC 104 Embedded Systems 32
Pin-Out of an 8051
UBC 104 Embedded Systems 33
Ports
Driving low-power peripherals ie. LEDs, relays
UBC 104 Embedded Systems 34
Port Defintion in Header Files#define Sfr(x, y) sfr x = y#define Sbit(x, y, z) sbit x = y^z#define Sfr16(x,y) sfr16 x = y
/* BYTE Register */Sfr (P0 , 0x80);
Sbit (P0_7 , 0x80, 7);Sbit (P0_6 , 0x80, 6);Sbit (P0_5 , 0x80, 5);Sbit (P0_4 , 0x80, 4);Sbit (P0_3 , 0x80, 3);Sbit (P0_2 , 0x80, 2);Sbit (P0_1 , 0x80, 1);Sbit (P0_0 , 0x80, 0);
Sfr (P1 , 0x90);
Sbit (P1_7 , 0x90, 7);Sbit (P1_6 , 0x90, 6);Sbit (P1_5 , 0x90, 5);
UBC 104 Embedded Systems 35
Philips ARM LPC Examplevoid Initialize() {
/* Initialize PLL *//* Setting Multiplier and divider values */PLLCFG=0x25;feed();
/* Enabling the PLL */PLLCON=0x1;feed();
/* Wait for the PLL to lock to set frequency */while(!(PLLSTAT & PLOCK)){}/* Connect the PLL as the clock source */PLLCON=0x3;feed();...
UBC 104 Embedded Systems 36
Another Example
static unsigned short ADC_Read (unsigned char ch) {
unsigned int i;
ADCR = 0x00200300 | ch; // Init ADC & select channel
ADCR |= 0x01000000; // Start A/D Conversion
do {
i = ADDR; // Read A/D Data Register
} while ((i & 0x80000000) == 0); // Wait for end of A/D Conversion
return (i >> 6) & 0x03FF; // bit 6:15 is 10 bit AD value
}
UBC 104 Embedded Systems 37
Accessing Ports in Cvoid main (void) { unsigned int i; /* Delay var */ unsigned char j; /* LED var */
while (1) { /* Loop forever */ for (j=0x01; j< 0x80; j<<=1) { /* Blink LED 0, 1, 2, 3, 4, 5, 6 */ P1 = j; /* Output to LED Port */ for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */ wait (); /* call wait function */ } }
for (j=0x80; j> 0x01; j>>=1) { /* Blink LED 6, 5, 4, 3, 2, 1 */ P1 = j; /* Output to LED Port */ for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */ wait (); /* call wait function */ } } }}
UBC 104 Embedded Systems 38
Exercise 4
Becoming familiar with the development environment: Simulation & Execution on board Debugging Using peripherals Ports Using low-level C e.g. bit-level operations
top related