ATAVRMC321 Atmel, ATAVRMC321 Datasheet - Page 82

no-image

ATAVRMC321

Manufacturer Part Number
ATAVRMC321
Description
KIT EVAL MOTOR CTRL LOW COST
Manufacturer
Atmel
Series
AVR®r
Datasheets

Specifications of ATAVRMC321

Main Purpose
Power Management, Motor Control
Embedded
Yes, MCU, 8-Bit
Utilized Ic / Part
ATtinyx61
Primary Attributes
3-Ph BLDC, Brushed DC, Stepper Motor- Controller Board
Secondary Attributes
Includes ATAVRMC300 Power Driver Board
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
82
ATtiny261/461/861
The following code examples show how to do an atomic read of the TCNT0 register contents.
Reading any of the OCR0 register can be done by using the same principle.
Note:
The assembly code example returns the TCNT0H/L value in the r17:r16 register pair.
Assembly Code Example
TIM0_ReadTCNT0:
C Code Example
unsigned int TIM0_ReadTCNT0( void )
{
}
; Save global interrupt flag
in r18,SREG
; Disable interrupts
cli
; Read TCNT0 into r17:r16
in r16,TCNT0L
in r17,TCNT0H
; Restore global interrupt flag
out SREG,r18
ret
unsigned char sreg;
unsigned int i;
/* Save global interrupt flag */
sreg = SREG;
/* Disable interrupts */
_CLI();
/* Read TCNT0 into i */
i = TCNT0L;
i |= ((unsigned int)TCNT0H << 8);
/* Restore global interrupt flag */
SREG = sreg;
return i;
See
“Code Examples” on page
6.
2588E–AVR–08/10

Related parts for ATAVRMC321