12.07.2015 Views

80C186EB/80C188EB Microprocessor User's Manual - CEUNES

80C186EB/80C188EB Microprocessor User's Manual - CEUNES

80C186EB/80C188EB Microprocessor User's Manual - CEUNES

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

TIMER/COUNTER UNIT$mod186name example_80186_family_timer_code;FUNCTION: This function sets up the timer and interrupt controller; to cause the timer to generate an interrupt every; 10 milliseconds and to service interrupts to; implement a real time clock.;; Timer 2 is used in this example because no input or; output signals are required.;;SYNTAX: extern void far set_time(hour, minute, second, T2Compare);;INPUTS: hour - hour to set time to.; minute - minute to set time to.; second - second to set time to.; T2Compare - T2CMPA value (see note below);;OUTPUTS: None;NOTE: Parameters are passed on the stack as required by; high-level languages;; For a CLKOUT of 16Mhz,;; f(timer2) = 16Mhz/4; = 4Mhz; = 0.25us for T2CMPA = 1;; T2CMPA(10ms) = 10ms/0.25us; = 10e-3/0.25e-6; = 40000;substitute register offsetsT2CON equ xxxxh ;Timer 2 Control registerT2CMPA equ xxxxh ;Timer 2 Compare registerT2CNT equ xxxxh ;Timer 2 Counter registerTCUCON equ xxxxh ;Int. Control registerEOI equ xxxxh ;End Of Interrupt registerINTSTS equ xxxxh ;Interrupt Status registertimer_2_int equ 19 ;timer 2:vector type 19data segment public ’data’public_hour, _minute, _second, _msecdata ends_hour db ?_minute db ?_second db ?_msec db ?Example 9-1. Configuring a Real-Time Clock9-18

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!