Hallo Hubert,
der Code stammt aus der Bascom-Hilfe
Irgendwo habe ich inzwischen in der BASCOM-Hilfe gefunden, daß PortB.0 als Inpulseingang für Timer/Counter0 konfiguriert werden kann:Code:'name : timer0.bas 'copyright : (c) 1995-2005, MCS Electronics 'purpose : shows how to use TIMER0 related statements 'micro : 90S2313 'suited for demo : yes 'commercial addon needed : no '----------------------------------------------------------------------------------------- $regfile = "2313def.dat" ' specify the used micro $crystal = 8000000 ' used crystal frequency $baud = 19200 ' use baud rate $hwstack = 32 ' default use 32 for the hardware stack $swstack = 10 ' default use 10 for the SW stack $framesize = 40 ' default use 40 for the frame space 'First you must configure the timer to operate as a counter or as a timer 'Lets configure it as a COUNTER now 'You must also specify if it will count on a rising or falling edge Config Timer0 = Counter , Edge = Rising 'Config Timer0 = Counter , Edge = falling 'unremark the line aboven to use timer0 to count on falling edge 'To get/set the value from the timer access the timer/counter register 'lets reset it to 0 Tcnt0 = 0 Do Print Tcnt0 Loop Until Tcnt0 >= 10 'when 10 pulses are count the loop is exited 'or use the special variable TIMER0 Timer0 = 0
The Port B pins with alternate functions are shown in the following table:
When the pins are used for the alternate function the DDRB and PORTB register has to be set according to the alternate function description.
Port B Pins Alternate Functions
PORTB.0 T0 (Timer/Counter 0 external counter input)
Ist der obengenannte Code jetzt alles was man braucht?
Wird PortB.0 damit automatisch als Pulse-Input für den Counter geschaltet?
Gruß
Peter







Zitieren

Lesezeichen