$regfile = "xm32E5def.dat"
$crystal = 32000000
$hwstack = 65
$swstack = 65
$framesize = 65
'baud 19200
$programmer = 16 'USBprog Programmer/ AVR ISP mkII (Atmel)
'(
... clock correction ...
')
'UARTD0, PIN 32, 33
'-----------------------------------------
Config Com1 = 19200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Open "com1:" For Binary As #1
'Open UARTS
Enable Interrupts
'Startausgabe
'-----------------------------------------
Print #1 , "-------------------------------------"
Print #1 , " Welcome"
Print #1 , "-------------------------------------"
'Variablen
'------------------------------------------
Dim CounterSecondByte as Byte
Dim CounterTotal As Word
Config PortC.4 = Input
Config Xpin = PortC.4 , Outpull = Pullup , Sense = Falling 'enable Pullup and reaction on falling edge
Config Event_system = Dummy , Mux0 = PortC.4 , Digflt0 = 8 'Eventchannel 0 = PINE.5, enable digital filtering
Config Tcc4 = Normal , Prescale = E0 , Event_source = E0 , EVENT_ACTION = RESTART , RESOLUTION = Byte ' Normal = no waveform generation, Event Source = Event Channel 0
' set the direction to count up
TCC4_CTRLGSET.0 = 0
On Tcc4_ovf Timerc4_int
Enable Tcc4_ovf , Lo
' Interrupt @ 256 -> 0xFF
Tcc4_per = 255
'################MAINLOOP#######################################################
Do
' Interval
Waitms 500
' CounterTotal = (CounterSecondByte << 8) | TCC4_CNT
CounterTotal = CounterSecondByte
Shift CounterTotal , Left , 8
CounterTotal = CounterTotal Or TCC4_CNT
' Debug Ausgabe
Print #1 , "TCC4_CNT = " ; CounterSecondByte ; " | " ; TCC4_CNT ; " = " ; CounterTotal ; " EXT " ; High(TCC4_CNT)
Loop
'################MAINLOOP#######################################################
Timerc4_int:
' increment high
Incr CounterSecondByte
Return
|