ARM Session 3 2010, Spring Copyright © 2012 Mohammad Moallemi

Preview:

Citation preview

ARMSession 3

2010, Spring

Copyright © 2012 Mohammad Moallemi

Timer - Counter بیتی کامال16سه واحد تایمر/کانتر

مجزا و قابل برنامه ریزی مستقل

رودی کالک خارجی، 3هر کانال دارای

ورودی کالک داخلی و دو ورودی/ 5

خروجی قابل تنظیم توسط کاربر

:کار در دو مد کاری مختلف

Capture Mode به منظور اندازه گیری بر روی :

سیگنال ورودی به سیستم )فرکانس- اختالف فاز –

دوره تناوب و ...(

Waveform Mode به منظور تولید شکل موج های :

مورد نیاز

: منابع کالک تایمر- کانتر

PB12/ETXER/TCLK0PB19/PWM0/TCLK1PA15/SPI0_NPCS3/TCLK2

PB23/TIOA0/DCD1PB24/TIOB0/DSR1

PB25/TIOA1/DTR1PB26/TIOB1/RI1

PB27/TIOA2/PWM0/AD0PB28/TIOB2/PWM1/AD1

منابع کالک

داخلی

کالک منWWWابع خارجی

ورودی / خروجی TCواحد

TIOA0,TIOA1,TIOA می توانند ورودی 2

کالک هم باشند

چند نکته

I/O LinesThe pins used for interfacing the compliant external devices may be multiplexed with PIO lines.The programmer must first program the PIO controllers to assign the TC pins to their peripheralfunctions.

Power ManagementThe TC is clocked through the Power Management Controller (PMC), thus the programmer mustfirst configure the PMC to enable the Timer Counter clock.

InterruptThe TC has an interrupt line connected to the Advanced Interrupt Controller (AIC). Handling theTC interrupt requires programming the AIC before configuring the TC.

منابع کالک تایمر- : کانتر

منابع کالک

داخلی

نماینده کالک خارجی

The clock of each counter can be controlled in two different ways: it can be enabled/disabledand started/stopped

TC Operating Modes

Each channel can independently operate in two different modes:• Capture Mode provides measurement on signals.• Waveform Mode provides wave generation.The TC Operating Mode is programmed with the WAVE bit in the TC Channel Mode Register.In Capture Mode, TIOA and TIOB are configured as inputs.In Waveform Mode, TIOA is always configured to be an output and TIOB is an output if it is not selected to be the external trigger.

TriggerA trigger resets the counter and starts the counter clock. Three types of triggers are common toboth modes, and a fourth external trigger is available to each mode.The following triggers are common to both modes:• Software Trigger: Each channel has a software trigger, available by setting SWTRG inTC_CCR.• SYNC: Each channel has a synchronization signal SYNC. When asserted, this signal hasthe same effect as a software trigger. The SYNC signals of all channels are asserted simultaneously by writing TC_BCR (Block Control) with SYNC set.• Compare RC Trigger: RC is implemented in each channel and can provide a trigger when the counter value matches the RC value if CPCTRG is set in TC_CMR.The channel can also be configured to have an external trigger. In Capture Mode, the external trigger signal can be selected between TIOA and TIOB. In Waveform Mode, an external eventcan be programmed on one of the following signals: TIOB, XC0, XC1 or XC2. This external event can then be programmed to perform a trigger by setting ENETRG in TC_CMR.If an external trigger is used, the duration of the pulses must be longer than the master clockperiod in order to be detected.Regardless of the trigger used,

TC – Capture Mode

TC – Waveform Mode

WAVSEL

WAVSEL

WAVSEL

WAVSEL

WAVSEL

WAVSEL

WAVSEL

WAVSEL

TC Registers

External Clock Selection

In all cases, if an external clock is used, the duration of each of its levels must be longer than the master clock period. The external clock frequency must be at least 2.5 times lower than the master clock.

External Clock Frequency < 2.5 MCK

External Clock Selection

ب&رای واح&د را داش&تیم این TCپس در ص&ورتی ک&ه قص&د اس&تفاده از کالک خ&ارجی ( مقدار دهی می کنیم.TC_BMRرجیستر را )

Channel Control Reg.

Chanel Mode Reg.

Chanel Mode Reg. [Capture Mode]

Chanel Mode Reg. [Capture Mode]

Chanel Mode Reg. [Waveform Mode]

Chanel Mode Reg. [Waveform Mode]

1. If TIOB is chosen as the external event signal, it is configured as an input and no longer generates waveforms and subsequently no IRQs.

Chanel Mode Reg. [Waveform Mode]

Counter Value / A-B-C Reg.

ایWه و BرجیسWتر C ترWرجیس هماننWد نWیز A می باشند.

Recommended