Posted: Tue Aug 07, 2012 7:28 pm Post subject: Problems with the timing
Ok the issue with the switches is solved.
I have a another issue with the timing of the wait and waitms if I write the value with the wait 1 (wait 1 second) it will take about 5 seconds to pass.
I have the program posted here and I am a little bit curious about the reactions.
$regfile = "m32def.dat"
$crystal = 16000000
' port configuration
Config Portd = Output ' Setting port D for output
Config Portb = Input ' Setting port B for input
Portb.0 = 1 ' Activate pull up
Portb.1 = 1
'statements
Dim Teller As Byte
Dim Functie As Byte
Dim Strt As Byte
Dim Timerspeed As Byte
Strt = 0
Timerspeed = 10
Do
Do
If Pinb.0 = 0 Then Incr Strt
If Pinb.1 = 0 Then Timerspeed = 250 Else Timerspeed = 10
Portd = &B10000000
Waitms 5
Portd = &B00000000
Loop Until Strt = 1
Strt = 0
Do
Incr Teller
Portd = Teller
Waitms Timerspeed
If Teller = &HFF Then Functie = 1
Loop Until Functie = 1
Teller = &HFF
Functie = 0
Do
Portd = Teller
Decr Teller
Waitms Timerspeed
If Teller = 0 Then Functie = 1
Loop Until Functie = 1
the simulator can not simulate in real time. this means that depending on the used pc, 1 waitms 1000 will take a fraction of a second, or multiple seconds.
the pc need to perform other tasks as well so the sim can not get 100% of the resources. a waitms 1000 will executes thousands of instructions (a loop with a number of instructions).
To remove delays of wait, waitms, you can read about $sim in the help. _________________ Mark
Ok, I have burn this code to my proc and the timing is of the wait 250 instruction generates about 1 second in real time.
I am glad to have any info about this to correct this little problem.
you specify this : $crystal = 16000000
but is that the actual clock speed?
you can use : config clockdiv=1 , to make sure there is no divisor active. But you should also check the fuse bytes. Maybe you run on the internal oscillator? _________________ Mark
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum