Atmel ARM-Based Evaluation Kit for SAM4S16C, 32-Bit ARM® Cortex® Microcontroller ATSAM4S-WPIR-RD ATSAM4S-WPIR-RD Data Sheet

Product codes
ATSAM4S-WPIR-RD
Page of 1231
849
SAM4S Series [DATASHEET]
Atmel-11100G-ATARM-SAM4S-Datasheet_27-May-14
37.6.14.5Speed Measurement
When SPEEDEN is set in the TC_BMR, the speed measure is enabled on channel 0. 
A time base must be defined on channel 2 by writing the TC_RC2 period register. Channel 2 must be configured in 
waveform mode (WAVE bit set) in TC_CMR2. The WAVSEL field must be defined with 0x10 to clear the counter 
by comparison and matching with TC_RC value. Field ACPC must be defined at 0x11 to toggle TIOA output.
This time base is automatically fed back to TIOA of channel 0 when QDEN and SPEEDEN are set.
Channel 0 must be configured in capture mode (WAVE = 0 in TC_CMR0). The ABETRG bit of TC_CMR0 must be 
configured at 1 to select TIOA as a trigger for this channel. 
EDGTRG can be set to 0x01, to clear the counter on a rising edge of the TIOA signal and field LDRA must be set 
accordingly to 0x01, to load TC_RA0 at the same time as the counter is cleared (LDRB must be set to 0x01). As a 
consequence, at the end of each time base period the differentiation required for the speed calculation is 
performed.
The process must be started by configuring bits CLKEN and SWTRG in the TC_CCR.
The speed can be read on field RA in TC_RA0.
Channel 1 can still be used to count the number of revolutions of the motor.
37.6.15 2-bit Gray Up/Down Counter for Stepper Motor
Each channel can be independently configured to generate a 2-bit gray count waveform on corresponding TIOA, 
TIOB outputs by means of the GCEN bit in TC_SMMRx.
Up or Down count can be defined by writing bit DOWN in TC_SMMRx.
It is mandatory to configure the channel in WAVE mode in the TC_CMR.
The period of the counters can be programmed in TC_RCx.
Figure 37-20. 2-bit Gray Up/Down Counter
37.6.16 Register Write Protection
To prevent any single software error from corrupting TC behavior, certain registers in the address space can be 
write-protected by setting the WPEN bit in the 
 (TC_WPMR).
The following registers can be write-protected:
TIOAx
TIOBx 
DOWNx
TC_RCx
WAVEx = GCENx =1