PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Timer2 anstelle von Timer1 benutzen



BlaueLed
02.07.2007, 12:38
Hallo,

ich habe ein programm, das einen Infrarot Code aussendet. Das Programm läuft mit Timer1. Jetzt würde ich gerne einen weitere Funktion einbauen, bei der aber auch ein 16 Bit Timer benötigt wird. Kann man den Timer1 so umschreiben, das mein programm auch mit timer2 anstelle von Timer1 läuft ?

hier mal mein code :



$regfile = "m32def.dat"
$crystal = 7372800


Const T_oc1 = 124

Const Carrier_on = &B01000000
Const Carrier_off = &B11000000

Config Timer1 = Timer , Prescale = 1 , Compare A = Toggle , Clear Timer = 1
Timer1 = 0
Compare1a = T_oc1

Tccr1a = Carrier_off
Config Portd.5 = Output
Portd.5 = 1
Ir Alias Tccr1a

Config Porta.0 = Output
Led Alias Porta.0
Taste1 Alias Pinc.1
Taste2 Alias Pinc.0
Config Portc = Input
Config Debounce = 30
Dim I As Byte


'---[ main program loop ]----------------------------------------------------

Main:
Debounce Taste2 , 0 , Anaus , Sub
Goto Main


'### Code für An/Aus ###
'-----------------------
Anaus:
Waitms 100
Toggle Led
Waitms 100
Toggle Led

Waitms 100
Toggle Led
Waitms 100
Toggle Led
Waitms 100

Ir = Carrier_on
Waitus 400
Ir = Carrier_off

Waitus 270
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 270
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 270
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 720
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 411
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 411
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 288
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 288
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 288
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 514
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 411
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 267
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 267
Ir = Carrier_on
Waitus 205
Ir = Carrier_off


Waitms 50


Ir = Carrier_on
Waitus 400
Ir = Carrier_off

Waitus 270
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 270
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 270
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 720
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 411
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 411
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 288
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 288
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 288
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 514
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 411
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 267
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 267
Ir = Carrier_on
Waitus 205
Ir = Carrier_off


Waitms 50

Ir = Carrier_on
Waitus 400
Ir = Carrier_off

Waitus 270
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 270
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 270
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 720
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 411
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 411
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 288
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 288
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 288
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 514
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 411
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 267
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Waitus 267
Ir = Carrier_on
Waitus 205
Ir = Carrier_off

Return

'---- Ende -----



mfg Kay