[bascom-avr] Timer, adc - problem

Mar 21, 2006 0 Replies

Kawa³ek kodu: <code>



$regfile = "m48def.dat" $crystal = 4000000



Ddrd = &B11111111 Ddrb = &B00000111



Dim M As Byte , S As Byte Dim Tmp As Byte , Tmp2 As Byte , Tmp3 As Byte Dim Ust As Word , Chadc As Byte Dim Temp As Long



Config Timer1 = Timer , Prescale = 256 Timer1 = 49910



Config Adc = Single , Prescaler = 128 Admux = 0



Enable Interrupts On Ovf1 Timer_int



[Inicjacja zmiennych, deklr. procedur itp.] Start_ust: 'label aby procedura skoncz_licz mog³a wróciæ do ustawiania czasu Start ADC Stop Timer1 Do Wyswietl

Ust = Getadc(0)



Ust = Ust * 60 Ust = Ust / 1024 S = Low(ust)



Ust = Getadc(1)



Temp = Ust * 100 Temp = Temp / 1024 M = Low(temp)



If Pind.7 = 0 Then Exit Do Loop



Enable Timer1 Timer1 = 49910 Start Timer1 do Wyswietl loop end



[.. Procedury ... ]

Timer_int: Stop Timer1 Timer1 = 49910 Decr S If S = 255 Then S = 59 Decr M If M = 255 Then Daj_glos_konca End If End If



Start Timer1 Return



Procedura "Daj_glos_konca" zatrzymuje timer, "daje g³os (beep)" i skacze do labela "Start_ust" </code>


I problem mam taki i¿ Timer1 woogule nie zmniejsz mi warto¶ci "s" po uruchomienu... nie wiem co mo¿e byæ, wy³±cza³em ju¿ adc i nic , dalej nie rusza (mam bascoma 1.11.8.1)... ,a mam podobny bardzo program i z niego "skopiowa³êm" obs³ugê timera...



Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required