The Silicon Laboratories C8051F020

Slides:



Advertisements
Similar presentations
ECE/CS-352: Embedded Microcontroller Systems The Silicon Laboratories C8051F020 Enhanced 8051 Part 5 Other Subsystems.
Advertisements

The 8051 Microcontroller and Embedded Systems
Review: Interrupts & Timers
4-1 Timers Timers can be used for  timing  event counting  pulse width measurement  pulse generation  frequency multiplication There are 8 Timers.
8051 Core Specification.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
5-1 Timer/Counters In many microprocessor systems we need to:  count logic pulses  measure the frequency of signals  measure the period of pulses 
Architecture of the 8051 INTERNAL DATA BUS Oscillator & Timing Programmable I/O (32 Pins) 80C51 CPU 64K byte Expansion Control Serial I/O 4K Program Memory.
Embedded Systems UNIT 3. Pin Details of 8051 Pins 1-8: Port 1 Each of these pins can be configured as an input or an output. Pin 9: The positive voltage.
1.  8051 Timers “count up,” incrementing the Timer’s respective “count register” each time there is a triggering clock pulse. 2  When the “count register”
Lecture 9 Timer Operations and Programming. 2  Introduction  Summary of timers  Timer programming sequence  Summary of timer SFRs  Timer 0: 8-bit.
The 8051 Microcontroller architecture
ECE/CS-352: Embedded Microcontroller Systems Embedded Microcontroller Systems.
System Clock, Crossbar and GPIO
CHAPTER TIMER PROGRAMMING Timers The 8051 has two timers/counters, they can be used as ◦ Timers to generate a time delay ◦ Event counters.
8051 timer/counter.
1 Chapter 4 Timer Operation (I. Scott MacKenzie).
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
System Clocks.
Chapter 4 TIMER OPERATION
CoE3DJ4 Digital Systems Design Chapter 4: Timer operation.
Lecture Set 9 MCS-51 Serial Port.
FREQUENCY COUNTER USING Silicon Labs C8051F020 microcontroller
Timers /Counters Programming  The 8051 has 2 timers/counters: ○ timer/counter 0 ○ timer/counter 1 They can be used as 1. The timer is used as a time.
1. Registers Used in Timer/Counter  TH0, TL0, TH1, TL1  TMOD (Timer mode register)  TCON (Timer control register) 2.
8051 Timer/Counter Lec note 7.
8051 Micro controller. Architecture of 8051 Features of 8051.
ECE/CS-352: Embedded Microcontroller Systems The Silicon Laboratories C8051F020 Enhanced 8051 Part 4 Timer3, Temperature Sensor, AD0WINT.
The Silicon Laboratories C8051F020
MCS51 - lecture 3. Lecture 3 2/30 Timers/counters MCS51.
Intel 8051 Another family of microcontroller is the Intel 8051 family. The basic 8051 microcontroller has four parallel input/output ports, port 0, 1,
1 68HC11 Timer HC11 or HC12: Chapter HC11 Timer Subsystem  Several timing functions: Basic timing Basic timing Real time interrupts Real time.
Jump, Loop, and Call Instructions
LHO 22 C and the  The Silicon Labs ISE uses the Keil C51 compiler.  The code size is limiter to 2K  C has replaced PL/M (the original Intel high.
8051 Aula 02 Prof Afonso Ferreira Miguel. Microcontrolador 8051 (MCS-51)  Timers do MCS51 Two 16-bit Counter/Timers: Two 16-bit Counter/Timers: Up counters,
Lecture 41 CSE 341 – Microprocessors Lecture 4 Md. Omar Faruqe UB 1228
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
kashanu.ac.ir Microprocessors Interrupts Lec note 8.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 4 Timers and Interrupts.
Timer Programming in Assembly and C Prepared By:
HJD Institute of Technical Education & Research- Kera(Kutch) The 8051 Microcontroller architecture PREPARED BY: RAYMA SOHIL( )
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
Embedded Microcontroller Systems
80C51 Block Diagram ECE Overview.
Assembly Language * * * * * * * 8051 Timer
Embedded Microcontroller Systems
Source: Serial Port Source:
8051 Timers Timers are the peripherals of the 8051 Microcontroller.
Timer Source: under
Interrupt Source: under
Silicon Labs C8051F020 System Overview
UNIT 5 TIMRERS/COUNTERS
Timer Operations and Programming
EMT 348: Microcontroller Timer/counter
Source: Serial Port Source:
8051 Timers Prof. Rajiv R Bhandari.
Introduction to Micro Controllers & Embedded System Design Timer Operation Department of Electrical & Computer Engineering Missouri University of Science.
Timer.
8051 Timers / Counters It has two timers Timer 0 and Timer 1.
전자의료시스템 및 실습 System Configuration/Interrupt
Timer Source: under
Interrupt Source: under
Silicon Labs C8051F020 System Overview
Interrupt Source: under
Source: Serial Port Source:
Timer Source: under
Source: Serial Port Source:
Presentation transcript:

The Silicon Laboratories C8051F020 Enhanced 8051 Part 2 Timers I ECE/CS-352: Embedded Microcontroller Systems

ECE/CS-352: Embedded Microcontroller Systems SFRs for Subsystems Control registers: XXXCN (WDTCN, ADC0CN, DAC0CN, TMR3CN) Configuration registers: XXXCF (ADC0CF, AMX0CF, EMI0CF) Data registers for subsystems: ADC0H, ADC0L, DAC0H, DAC0L Many others..... ECE/CS-352: Embedded Microcontroller Systems

ECE/CS-352: Embedded Microcontroller Systems System Clocks Internal clock oscillator default at reset 2 MHz default frequency configured by SFR OSCICN External oscillator installed on board 22.1184 MHz configured by SFR OSCXCN ECE/CS-352: Embedded Microcontroller Systems

Internal Osc Configuration OSCICN Missing clock detector enable Internal Osc. frequency ready Internal Osc. freq. control bits 00 – 2MHz 01 – 4 MHz 10 – 8 MHz 11 – 16 MHz system clock select 0 = internal 1 = external (internal by default) Default Sysclk f = 2 MHz T = ?? Internal Osc. enable (enabled by default) ECE/CS-352: Embedded Microcontroller Systems

External Osc. Configuration OSCXCN External Osc. freq. control bits Depends on frequency range of operation External Osc. mode bits 00x: Off. XTAL1 pin is grounded internally. 010: System Clock from External CMOS Clock on XTAL1 pin. 011: System Clock from External CMOS Clock on XTAL1 pin divided by 2. 10x: RC/C Oscillator Mode with divide by 2 stage. 110: Crystal Oscillator Mode 111: Crystal Oscillator Mode with divide by 2 stage. Crystal Osc. valid flag ECE/CS-352: Embedded Microcontroller Systems

Development Board Oscillator ECE/CS-352: Embedded Microcontroller Systems

To use 22.1184 MHz external oscillator 110: Crystal Oscillator Mode 111: f > 6.7 MHz Step 1. Configure the external oscillator. Step 2. Wait at least 1 ms. Step 3. Poll for XTLVLD => ‘1’. Step 4. Switch the system clock to the external oscillator. ECE/CS-352: Embedded Microcontroller Systems

ECE/CS-352: Embedded Microcontroller Systems Instruction Timing C8051F020 – Pipelined architecture Machine cycle = clock cycle Most instructions take 1 or 2 clock cycles Total of 109 distinct instruction types Summary of instruction timing: ECE/CS-352: Embedded Microcontroller Systems

Delay Loops clr A djnz A, $ ; 2 cycles if no jump, ; 3 cycles if jump ECE/CS-352: Embedded Microcontroller Systems

ECE/CS-352: Embedded Microcontroller Systems Sample Configuration Use 22.1184 MHz external oscillator Main: mov WDTCN, #0deh ; disable watchdog timer mov WDTCN, #0adh mov OSCXCN, #67h ; enable external crystal ; oscillator at 22.1184MHz clr A ; wait at least 1ms djnz A, $ ; wait ~510us (255 x 4 x 0.5us) = 510 us) djnz A, $ ; wait ~510us osc_wait: ; poll for XTLVLD-->1 mov a, OSCXCN jnb acc.7, osc_wait orl OSCICN, #08h ; select external oscillator as ; system clock source ECE/CS-352: Embedded Microcontroller Systems

ECE/CS-352: Embedded Microcontroller Systems Timers Original 8051 has 2 Timers, T0 and T1 Can think of timers as binary counters Clock is derived from system clock (frequency is configurable) Timer registers can be read via mov instructions Events (interrupts or flag bits set) occur when timers overflow Can be used to create waveforms, measure time intervals, set frequency of events, etc. ECE/CS-352: Embedded Microcontroller Systems

ECE/CS-352: Embedded Microcontroller Systems C8051F020 Timers Size of timers can be configured. Timers can count from arbitrary initial value with the “Auto-reload” feature. “Capture” allows the timer to be “frozen” when an event occurs. Timers 2 and 4 can be used to set baud rate for uarts. ECE/CS-352: Embedded Microcontroller Systems

ECE/CS-352: Embedded Microcontroller Systems Timer Clock Sources CKCON: Clock Control Register Timer0 Timer clock selects 0 = system clock  12 (for compatibility with original 8051, and for slow stuff) 1 = system clock Timer4 ECE/CS-352: Embedded Microcontroller Systems

ECE/CS-352: Embedded Microcontroller Systems Configuring Timers TCON and TMOD used to configure Timer0 and Timer1 TCON: Timer Control Register These deal with external interrupts Timer 1 Overflow Flag Timer 1 run control 0 = disable Timer 1 1 = enable Timer 1 ECE/CS-352: Embedded Microcontroller Systems

ECE/CS-352: Embedded Microcontroller Systems Configuring Timers TMOD: Timer Mode Register Timer 1 Timer 0 GATE1: 0 = timer enabled with TR1 only 1 = timer enabled only when TR1=1 and \INT=1 C/T1: 0 = timer incremented by clock input 1 = counter incremented by edge on external T1 pin ECE/CS-352: Embedded Microcontroller Systems

Using Timers For Periodic Events Using Polling Set mode to be timer – use appropriate clock and timer size In main program Check for overflow flag (polling) When overflow flag occurs Do event Reset timer overflow flag Reset timer initial value (unless using auto-reload or initial value of 0 is OK) Continue checking ECE/CS-352: Embedded Microcontroller Systems

Using Timers For Periodic Events Using Interrupts Set mode to be timer, use appropriate clock and timer size Set timer to interrupt on overflow In Interrupt Service Routine Do event Reset interrupt flag Reset timer to initial value (unless using auto-reload) Return from interrupt ECE/CS-352: Embedded Microcontroller Systems

Using Timers as Counter Set mode to be counter, with appropriate size (8, 13 or 16 bits) Initialize counter to zero Enable counter Counter can be read and reset by main program. ECE/CS-352: Embedded Microcontroller Systems

Using Timers to Measure Time Configure timers with mode 0 or 1 (13 or 16-bit timer) and desired system clock. In main program, wait for initial event. Start the timer.  Each time the timer overflows, a register should be incremented using an interrupt service routine. When the second event occurs, disable the interrupts and the timer in the main program. ECE/CS-352: Embedded Microcontroller Systems

ECE/CS-352: Embedded Microcontroller Systems Configuration Tool Fortunately, there is a tool to help configure all the subsystems in the 8051. This makes things a lot easier. To access the tool, go to Silicon Labs – Configuration Tool 2 ECE/CS-352: Embedded Microcontroller Systems