www.quad.ru

\\.. \\...

ATtiny2313

3,580 . : , , .

- 14,318 ( ), , , ATtiny2313-20 (20 ).

. - C7, L1 R2, 6 14 .

( - 650 mAh Siemens-, 30-50 , ). .

, . ( ) - .

5 -10 , . : .

 

 

( 1-2 ) 20-30 .

, , , R2 .

Reset .

PonyProg, fuse bits ATtiny2313 8 - , .. :

 

AVR Studio, , , , (, ). ̻, λ, Ż , , , .

F=F/2*(n+1), n= OCR0A. n=1 4, n=3 F .

.

, Ż , , , .. . .equ ch =12 ;- 12 14, .db 0x01 ; .db 0x01, 0x81, 0x03 ; ( 0x01, 0x81, 0x03 . ). , AVR Studio.

 

;********************************

; 3.5 ATtiny 2313

;********************************

 

.include "tn2313def.inc"

 

.equ freq =14318200 ;

.equ period =125 ; 125

.equ ch =12 ;-

.equ kol =4 ;-

 

.def tmp =r16

.def count1 =r17

.def count2 =r18

.equ speed =period*freq/64000

 

.CSEG

.org 0

rjmp RESET

nop ;rjmp EXT_INT0 ; IRQ0

nop ;rjmp EXT_INT1 ; IRQ1

nop ;rjmp TIM1_CAPT ; 1

rjmp TIM1_COMPA ; 1

nop ;rjmp TIM1_OVF ; 1

nop ;rjmp TIM0_OVF ; 0

nop ;rjmp USART0_RXC ;

nop ;rjmp USART0_DRE ;

nop ;rjmp USART0_TXC ;

nop ;rjmp ANA_COMP ;

nop ;rjmp PCINT

nop ;rjmp TIMER1_COMPB

nop ;rjmp TIMER0_COMPA

nop ;rjmp TIMER0_COMPB

nop ;rjmp USI_START

nop ;rjmp USI_OVERFLOW

nop ;rjmp EE_READY

nop ;rjmp WDT_OVERFLOW

.org 0x0013

TIM1_COMPA:

reti

RESET:

ldi tmp, RAMEND ;

out SPL, tmp ; .

ldi tmp, 1<<SE

out MCUCR, tmp

ldi tmp, high(speed)

out OCR1AH, tmp

ldi tmp, low(speed)

out OCR1AL, tmp

ldi tmp, 1<<OCIE1A

out TIMSK, tmp

ldi tmp, (1<<CS10)|(1<<WGM12)|(1<<CS11)

out TCCR1B, tmp

ldi tmp, 1 ;

out OCR0A, tmp ;

ldi tmp, (1<<COM0A0)|(1<<WGM01)

out TCCR0A, tmp

ldi tmp, 1

out TCCR0B, tmp

sei

ldi count2, kol

l3:

ldi count1, ch

ldi zh, high(2*Tabl)

ldi zl, low(2*Tabl)

l2:

lpm tmp, z+

cpi tmp, 0

breq l2

bst tmp, 7

brts pause

sbi DdrB, 2

l1:

sleep

dec tmp

brne l1

l4:

dec count1

brne l2

dec count2

brne l3

ldi count2, kol+1

ldi count1, 1

cbi DdrB, 2

ldi tmp, 0xFF

rjmp p1

pause:

cbr tmp, 1<<7

cbi DdrB, 2

p1: ;

sleep

dec tmp

brne p1

rjmp l4

 

; :

; 0x03 -

; 001 -

; 081 -

; 083 -

; 086 -

Tabl:

.db 0x03, 0x81, 0x03 ; "" " " ""

.db 0x83 ;

.db 0x03, 0x81, 0x03, 0x81, 0x03 ;

.db 0x83 ;

.db 0x01 ;

.db 0x86 ;

 

.exit

 

, , .

, , .

, 4 , : .equ freq =500000 ; ( 4 , 8, CKDIV8 PonyProg, 0,5 ) 堠 ldi tmp, 249 ;

ut OCR0A, tmp ; .

1 ( , 1024 , 4,096 ).

Fuse :

 

 

3,5 , .

sibmon@yandex.ru, .

: , .