Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE/CS-352: Embedded Microcontroller Systems The Silicon Laboratories C8051F020 Enhanced 8051 Part 4 Timer3, Temperature Sensor, AD0WINT.

Similar presentations


Presentation on theme: "ECE/CS-352: Embedded Microcontroller Systems The Silicon Laboratories C8051F020 Enhanced 8051 Part 4 Timer3, Temperature Sensor, AD0WINT."— Presentation transcript:

1 ECE/CS-352: Embedded Microcontroller Systems The Silicon Laboratories C8051F020 Enhanced 8051 Part 4 Timer3, Temperature Sensor, AD0WINT

2 ECE/CS-352: Embedded Microcontroller Systems The “Other” Timers Timer 3 Timer 3 – auto-reload feature – more clock sources

3 ECE/CS-352: Embedded Microcontroller Systems Timer 3 Clock sources: –External oscillator  8 (allows for real-time clock input for timed applications) –Sysclk or Sysclk  12 (like all other timers) Always 16-bit, auto-reload. –Write “reload” value to TMR3RLH : TMR3RLL –Defines the time between overflows Can be used to start ADC conversion Can be used for SMBbus timing

4 ECE/CS-352: Embedded Microcontroller Systems Auto-reload Example Suppose we want to sample the ADC every 1ms. How many counts for 1ms with: –The internal oscillator (2 MHz)?

5 ECE/CS-352: Embedded Microcontroller Systems Two More Useful Analog Subsystems Analog Programmable Window Detector Temperature Sensor

6 ECE/CS-352: Embedded Microcontroller Systems ADC0 Programmable Window Limit Registers ADC0GTH | ADC0GTL ADC0LTH | ADC0LTL ADC0GTH | ADC0GTL ADC0LTH | ADC0LTL AD0WInt = 1

7 ECE/CS-352: Embedded Microcontroller Systems Programmable Window Detector EXAMPLE

8 ECE/CS-352: Embedded Microcontroller Systems ADC0CN AD0WINT: ADC0 Window Compare Interrupt Flag This flag must be cleared by software. 0: ADC0 Window Comparison Data match has not occurred since this flag was last cleared. 1: ADC0 Window Comparison Data match has occurred.

9 ECE/CS-352: Embedded Microcontroller Systems Example – Detect Darkness Using light sensor setup, with “dark” corresponding to.25 * VREF, turn the LED on When it becomes light enough, corresponding to 0.5*VREF, turn the LED off What are the values in the GT and LT registers? How is the interrupt enabled? ADC0GTH: ADC0GTL ADC0LTH: ADC0lTL AD0WInt = 1

10 ECE/CS-352: Embedded Microcontroller Systems Example – Detect Darkness

11 ECE/CS-352: Embedded Microcontroller Systems Example – Detect Darkness cseg at 043h; set the interrupt vector ljmp adw_int …. adw_int: clr AD0WINT ; Clear interrupt flag (ADC0CN is bit addressable) mov a, ADC0H; check MSB of ADC to see which condition it is clr C subb a, #04; Is it less than 04? jnc off_light; if not, must be time to turn light off setb LED; if so, turn on light and return sjmp over off_light: clr LED over: reti

12 ECE/CS-352: Embedded Microcontroller Systems Temperature Sensor Selected with the AMX0SL register Otherwise treated the same as other ADC inputs Using above equation, and ADC0 settings and conversion equation, we can convert temperature to digital value.


Download ppt "ECE/CS-352: Embedded Microcontroller Systems The Silicon Laboratories C8051F020 Enhanced 8051 Part 4 Timer3, Temperature Sensor, AD0WINT."

Similar presentations


Ads by Google