390 likes | 671 Views
UBC104 Embedded Systems. Microcontroller / 8051 family. Topics for Today. Microcontrollers Memory Registers Ports. Processors. General purpose processors: 80386 Pentium Core Duo Large number of pins External memory External peripherals . * Figure from Intel 386 DX Datasheet.
E N D
UBC104 Embedded Systems Microcontroller / 8051 family
Topics for Today • Microcontrollers • Memory • Registers • Ports UBC 104 Embedded Systems
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
Functions of Pins • Designed to be generic • Indented to move data around * Figure from Intel 386 DX Datasheet UBC 104 Embedded Systems
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
Pentium • Bigger, better, more * Figure from Intel Pentium Datasheet UBC 104 Embedded Systems
Microcontrollers • Support for peripherals inside uController • Limited number of pins • Dedicated purpose • Controlling devices, taking measurements UBC 104 Embedded Systems
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
Rita51J • 8051 • 128K of SRAM • 128K FLASH ROM • Serial port • Digital I/O lines * Figure from www.rigelcorp.com UBC 104 Embedded Systems
Motes • Sensor nodes based on Atmel ATMega128 * Figures from CrossbowMPR-MIBUser Manual UBC 104 Embedded Systems
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
AT91SAM7P64 * Figure from www.olimex.com UBC 104 Embedded Systems
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
8051 History • Introduced 1980 • 12 MHz • 128 bytes Internal RAM • 4 kbytes ROM • 1 Serial port support UBC 104 Embedded Systems
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
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
Selection of Atmel 8051Devices * Figure from Atmel Function Spreadsheet UBC 104 Embedded Systems
Datasheets – Your New Friends! * Figure from Atmel AT89C51RD2 Datasheet UBC 104 Embedded Systems
Packaging • Plastic Dual In-Line package (PDIL) * Figure from Atmel AT89C51RD2 Datasheet UBC 104 Embedded Systems
Packaging I • Very small Quad Flat Package (VQFP) * Figure from Atmel AT89C51RD2 Datasheet UBC 104 Embedded Systems
Packaging II • Plastic Leaded Chip Carrier (PLCC) * Figure from Atmel AT89C51RD2 Datasheet UBC 104 Embedded Systems
Packaging UBC 104 Embedded Systems
Pin-Out of an 8051 UBC 104 Embedded Systems
8051 Components • Ports • RAM • Interrupt Controller • Timer • SPI Controller * Figure from Atmel AT89C51RD2 Datasheet UBC 104 Embedded Systems
MCBX51 Board UBC 104 Embedded Systems
MCBx51 Board * Figure from MCBx51 Datasheet UBC 104 Embedded Systems
8051 Internal RAM * Figure from Atmel AT89C51RD2 Datasheet UBC 104 Embedded Systems
Special Function Registers (SFRs) * Figure from Atmel AT89C51RD2 Datasheet UBC 104 Embedded Systems
Special Function Registers (SFR) * Figure from Atmel AT89C51RD2 Datasheet UBC 104 Embedded Systems
Special Function Registers (SFR) * Figure from Atmel AT89C51RD2 Datasheet UBC 104 Embedded Systems
* Figure from Atmel AT89C51RD2 Datasheet UBC 104 Embedded Systems
Pin-Out of an 8051 UBC 104 Embedded Systems
Ports • Driving low-power peripherals ie. LEDs, relays UBC 104 Embedded Systems
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
Philips ARM LPC Example void 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
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
Accessing Ports in C void 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
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 UBC 104 Embedded Systems