№2

, . Bascom , , - , .

Bascom :

-

-

-

, , , .

Bascom :

- Bit

0 1. , , / .

- Byte

X (8 ). 0 255 . AVR tiny, . , 1 Byte, 255, 0.

- Integer

. -32768 +32767. , 15 . , +32767 -32768.

- Word

, . 16 , .. 0 65535. 65535 0.

- Long

4 . 32 , -2147483648 2147483647. +2147483647 -2147483648.

- Single

. 1.510ˆ45 3.4x10ˆ38. .

:

Dim X as Byte Byte

X = 100 100

INT0, 1. , , , , . , , 50 . . . INT0 + DEB. Ÿ .1.

.1 - - "INT0+DEB"

, : . , . INT0 + DEB.

DEBOUNCE, Waitms. , 75 . INT0.

$Regfile = "attiny2313.dat"

$Crystal = 4000000

$hwstack = 40

$swstack = 16

$framesize = 32

config Portd.6 = output 'PD6-

config portd.6 = 0 ' PD6=0

config PORTD.2 = input 'PD2-

config portd.2 = 1 ' PD2=1 ()

config INT0 = FALLING ' INT0

config DEBOUNCE = 75 ' 75

dim Wtime as Byte ' Byte

on Int0 Displey '

cls '

Wtime = 255 '

Enable INTERRUPTS '

Enable INT0 ' INT0

do '

cls

set Portd.6 ' PD6=1

waitms Wtime '=255

reset PortD.6 ' PD6=0

waitms Wtime

loop '

Displey: '

Lcd "stop" ' Stop

Waitms 75 ' 75

return '

end 'end program

C 堠 1 .

. ATtiny2313 : (0 0) (1 1), Bascom , Timer0 Timer1 ( AT90S2313). ATtiny2313.

(Timer0) 0 255. Config :

Config Timer0 = Timer, Prescale = 1|8|64|256|1024

Timer0 . 1, 8, 64, 256, 1024. 4, 1024, 0.256 (1024/4000000 ) 65 (255 0.256). Timer1 Timer0, , , 65535. .

Start Stop. : Start Timer0 Stop Timer0 Start Timer1 Stop Timer1.

, , :

. . . .

Timcounter = Timer0

Lcd inftimer; Timcounter

. . . .

, ( ) : Timer0 Byte, Timer1 Word . :

Stop Timer1

. . . .

Timer1 = 560

. . . .

Start Timer1

, . . timer .2, , : D6 ().

.2 - - "timer"

Timer0 , , , , PB1. PD6. T , . timer .

$Regfile = "2313def.dat"

$Crystal=4000000

$hwstack=40

$swstack=16

$framesize=32

Config Pind.6 = Output 'PD6-

Config PinB.1 = Output 'PB1-

Config Timer0 = Timer , Prescale = 64 '.

Dim Wtime As Byte '

On Timer0 Pulse: '

Wtime = 100

Enable INTERRUPTS '

Enable Timer0 '. 0

Do '

Set PORTD.6 'PD6=1

Waitms Wtime '

Reset PORTD.6 'PD6=0

Waitms Wtime

Loop '

Pulse: '

Toggle PortB.1 ' PB1

Return

End 'end program

2 .

imer1 . , , ICP (PD6) , Timer1 Input Capture, .

.3 CAPT.

.3 - - "CAPT"

, ICP, , Timer1. CAPT :

$Regfile = "2313def.dat"

$Crystal = 4000000

$hwstack = 40

$swstack = 16

$framesize = 32

config PortD.6 = input

config TIMER1 = TIMER , PRESCALE = 64 , Capture Edge = Rising '. 64,

dim Wtime as Byte '

dim Timcount as Word

on Capture1 Capt '.

Wtime = 100

Timcount = 0

enable INTERRUPTS '

enable Capture1 '

Do

Waitms Wtime

Cls

Lcd "Timer:" ; " " ; Timcount

Loop

Capt: '

Timcount = capture1 '

Timer1 = 0 '

return

End 'end program

Timer1, capture1 Timcount, . ICP , Timcount ICP. 3.