Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20849

BASCOM-AVR : problem with aritmatic : NEWTOPIC

$
0
0
hi all..i need your help.. Waktu: Start Timer1 Set Portb.4 'this pin use for active dinamo Pul = Pul + 6 ''here the problem..if interrupt we switch 2 time then "pul" is 12 so i want 6+6=2,how to create that If Pul > 9 Then 'one time i switch the interrupt "pul"=6 and "det"=0 and timer is 60 inthe same time Pul = 0 'two time i switch the interrupt,"rat"=1 and "pul"=2 and "det"=0 and timer is 120 inthe same time Rat = Rat + 1 'example:timer is countdown until "pul"=2 and "det"=5 so if we switch the interrupt then "pul" and "det" must be add 60 so"pul"=8 and "det"=5 End If Return ==================================================================================================== $regfile = "attiny2313.dat" $crystal = 4000000 $sim Dim A As Byte Dim Det As Byte Dim Pul As Byte Dim Rat As Byte Config Pind.4 = Input Config Portd.1 = Output Config Portb = Output Config Timer1 = Timer , Prescale = 8 Config Int1 = Low Level Enable Interrupts Enable Timer1 Enable Int1 , On Int1 Waktu On Ovf1 Nilai Stop Timer1 Tcnt1 = 65386 Do Portb = Lookup(det , Seg) 'for 7 segment Waitus 1 Portd = &B1111111 'for 7 segment katoda Waitus 500 Portb = Lookup(pul , Seg) 'for 7 segment Waitus 1 If Pul = 0 Then Portd = &B1111111 'for 7 segment katoda If Pul > 0 Then Portd = &B1111101 Waitus 500 Portb = Lookup(rat , Seg) 'for 7 segment Waitus 1 If Rat = 0 Then Portd = &B1111111 'for 7 segment katoda If Rat > 0 Then Portd = &B1111011 Waitus 500 Loop Until Portb..4 = 0 End Waktu: Start Timer1 Set Portb.4 'this pin use for active dinamo Pul = Pul + 6 ''here the problem..if interrupt we switch 2 time then "pul" is 12 so i want 6+6=2,how to create that If Pul > 9 Then 'one time i switch the interrupt "pul"=6 and "det"=0 and timer is 60 inthe same time Pul = 0 'two time i switch the interrupt,"rat"=1 and "pul"=2 and "det"=0 and timer is 120 inthe same time Rat = Rat + 1 'example:timer is countdown until "pul"=2 and "det"=5 so if we switch the interrupt then "pul" and "det" must be add 60 so"pul"=8 and "det"=5 End If Return Nilai: Incr A If A = 150 Then Decr Det If Det = 255 Then Det = 9 If Det = 0 Then Decr Pul If Pul = 255 Then Pul = 0 If Pul = 0 Then Decr Rat If Rat = 255 Then Rat = 0 If Det = 0 And Pul = 0 And Rat = 0 Then Portd = &B1111111 Stop Timer1 Reset Portd.4 Return Seg: 'nilai 7 segment common katoda Data &B00111111 , &B00000101 , &B01011011 , &B01001111 Data &B01100101 , &B01101110 , &B01111100 , &B00000111 Data &B01111111 , &B01100111 very need your help please...thanks :D [b:1c2b43cc5e][color=red:1c2b43cc5e](BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.6 )[/b:1c2b43cc5e][/color:1c2b43cc5e]

Viewing all articles
Browse latest Browse all 20849

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>