FREQUENCY COUNTER USING Silicon Labs C8051F020 microcontroller

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
Interrupts Professor Yasser Kadah –
Review: Interrupts & Timers
Chung-Ta King National Tsing Hua University
Introduction of Holtek HT-46 series MCU
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or 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 
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”
Indian Institute of Technology Hyderabad CONTACTLESS TACHOMETE R Group members: Moruboyina Alekhya Kodi Padmasree D.Hima Varsha.
Lecture 10 Serial Communication.
Chung-Ta King National Tsing Hua University
Lecture 9 Timer Operations and Programming. 2  Introduction  Summary of timers  Timer programming sequence  Summary of timer SFRs  Timer 0: 8-bit.
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
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).
ARM Timers.
1 4-Integrating Peripherals in Embedded Systems. 2 Introduction Single-purpose processors  Performs specific computation task  Custom single-purpose.
Chapter 4 TIMER OPERATION
Lecture 11: TI MSP430 Timers Compare Modes
1 LHO 13 The 8051CF020 and the University Daughter Card.
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.
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
8051 Timer/Counter Lec note 7.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals.
Intel 8051 Another family of microcontroller is the Intel 8051 family. The basic 8051 microcontroller has four parallel input/output ports, port 0, 1,
Saxion University of Applied Sciences Advanced Microcontrollers A practical approach.
Real Time Interrupts Section Real-Time Interrupt (RTI) Most operating systems (OS) require an interrupt every T seconds by the RTI RTI interrupts.
Jump, Loop, and Call Instructions
Chapter 5 - Interrupts.
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.
The Silicon Laboratories C8051F020
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,
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
1 68HC11 Timer. 2 68HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output compare.
Timer & Watch Dog Test UNIT 16 로봇 SW 교육원 조용수. 학습 목표 Timer Init Timer Delay Test Timer Interrupt Test –One Shot Mode –Periodic Mode Watch Dog Test 시계 만들어.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 4 Timers and Interrupts.
Timer Programming in Assembly and C Prepared By:
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.
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
8051 Timers Timers are the peripherals of the 8051 Microcontroller.
Prof. Chung-Ta King Department of Computer Science
Timer Source: under
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Interrupt Source: under
Introduction to Micro Controllers & Embedded System Design Interrupt
UNIT 5 TIMRERS/COUNTERS
Timer Operations and Programming
* * * * * * * 8051 Interrupts Programming.
EMT 348: Microcontroller Timer/counter
8051 Timers Prof. Rajiv R Bhandari.
Interrupt.
Timer.
8051 Timers / Counters It has two timers Timer 0 and Timer 1.
Timer Source: under
Interrupt Source: under
Interrupt Source: under
8051 Micro Controller.
Timer Source: under
Wireless Embedded Systems
CS4101 Introduction to Embedded Systems Lab 2: Basic IO and Timer
Prof. Chung-Ta King Department of Computer Science
Presentation transcript:

FREQUENCY COUNTER USING Silicon Labs C8051F020 microcontroller Embedded Systems EGRE631 Smitha Gautham Dept. of Electrical and Computer Engineering Virginia Commonwealth University

Outline Application Theory Implementation Results and Discussions Summary and Future Work

Examples of Application Calibrate other equipment Guitar tuner (attach to a crystal) Measure rpm of wheel

Theory: Keeping track of time System clock is 22.45 MHz. Timer count = 22,450 → 1 ms Start counter Counter counts external clock pulses Every 1 ms → interrupt Count 1000 in ISR → 1 second delay

Theory: counting frequency Every second: stop counter Store value in counter register Counter registers:16 bits → count 65,535 Higher frequencies: track counter overflows

Theory: LCD display Display the frequency on LCD Integer → string Pass string to LCD routine

Implementation: Overview of Microcontroller T4 is P0.4 Data port Command port Reference: Embedded programming , Chew Moi Tin and Gourab Sen Gupta

Implementation: Hardware Schematic

Implementation: Actual Hardware Set-up Complete Set-up MC and LCD

Implementation: Initializing cross-bars Timer 2 to count internal clock pulses Counter 4 to count external frequency Configuring the Crossbar registers void init_crossbar (void) { XBR0 = 0x04; // UART 0 TX to P0.0, RX to P0.1 XBR1 = 0x40; // Sysclk out XBR2 = 0x58; // Enable cross bar rout T4 to port pin }

Implementation: Crossbars XBR0=0x04 XBR1=0x40 XBR2=0x58

Implementation: Initializing Ports Configuring ports void init_ports(void) { P0MDOUT = 0x00; //configure P0 as input port P0=0x04; P1MDOUT = 0xFF; // P1 is push pull P2MDOUT = 0xFF;// P2 as push pull P3MDOUT = 0x00; P5 = 0x00; }

Implementation: Initializing Timer and Counter CKCON=0x20 T2C0N=0X00

Implementation: Initializing Timer and Counter T4CON=0X03

Implementation: Initialize timer void init_timer(int cnt) { T2CON =0x00; //clear Timer 2 T4CON=0x03; //clear Timer4 config Timer 4 as counter CKCON= 0X20; //Timer 2 uses sys clk TMR2RL=-cnt; //load count to get 1 ms delay TMR2=TMR2RL; TMR4RL=0x00; // clear Counter4 TMR4=TMR4RL; ET2=1; //Enable Timer2 interrupt TR2=1; // Run Timer2 T4CON= 0x0F;//Run Counter4 }

Implementation: ISR void Timer2_ISR (void) interrupt 5 { unsigned int scnt; TF2=0; //clear timer2 interrupt flag scnt++; if (scnt==100) // ISR every 1ms, 1ms *100 gives .1 s flag=1; z=z+TMR4; //TMR4 value is repeatedly added to z TMR4=0x00; scnt=0; zcnt=zcnt+1; // to get 10 counts of .1 s } if (zcnt==10) //.1s* 10 gives 1 s delay T4CON =0x00; init_timer(mSEC_CNT);

Implementation: Main Program int main(void) { unsigned int arr4[12]; unsigned int *ptra; Init(); EA=1; init_timer(mSEC_CNT); while(1) if(flag==1) flag=0; if(zcnt==10) // Initialize the microcontroller // Enable Global Interrupts // Initialize timer //flag is enabled after .1s // zcnt = 10 means 1 s is complete

Implementation: Main Program cont’d { zcnt=0; if ( z> 550000 ) // if value in z is >550K indicate ptra=& arr4[0]; ptra="out of range"; z=0; if(ptra!='\0') lcd_disp(* ptra); lcd_init(); }

Implementation: Main Program cont’d else sprintf(arr4, "%ld Hz", z); // convert z to string and display z=0; ptra= & arr4[0]; lcd_init(); lcd_disp(*ptra); }

Implementation: LCD Display void lcd_init() { cmd_write(0x38); micro100_delay(30); // gives delay of 1 ms cmd_write(0x0E); // Display on Cursor off; 0000 1DCB micro_delay(1); cmd_write(0x01); //Clear the display cmd_write(0x06); //Entry mode 0000 01 I/D S }

Implementation: LCD Display cont’d void cmd_write(char cmd) { RS=0; micro_delay(1); RW=0; micro100_delay(10); // gives delay of 1 ms LCD_DAT_PORT = cmd; E=1; micro_delay(1); //gives a delay of 1 micro second E=0; }

Implementation: LCD Display cont’d void data_write(char dat) { EA=1; RS=1; micro_delay(1); RW=0; micro100_delay(10); LCD_DAT_PORT = dat; //Data is written E=1; micro_delay(1); //enable must be high for 300 ns to capture data E=0; }

Range of few Hz to 100s of k HZ Results Range of few Hz to 100s of k HZ

Discussions Sampling time = 0.1 s Number of times = 10 Total =1 s Register TMR4→ MAX 65,535 every 0.1 s Z=z+TMR4 each time Max Freq= 655,350 Hz

Discussions Theoretically cannot measure freq > 655,350 Hz Display “0” beyond 550,000 Hz

Summary Inexpensive frequency counter implemented Can measure frequency from 1 Hz to 550 K Hz TMR4 is16 bits → max count of 65,535 repeat 10 times per sec→ max frequency of 655,350

Future Work Expand range of frequency counter Other ways of implementations Explore use of other Timers/Counters

Thank you Questions?