it depends on the chip you use and what you want to simulate. all normal 8051 processors instruction cycles are counted accurate.
but some 8051 chips have different cycles for different instructions (compared with the default). in such case the actual code will be quicker than in the simulator.
and last : some hardware requires time to execute while the simulator only counts the cycles of the instructions.
Just give it a try and compare with the real app. _________________ Mark
Posted: Fri Oct 31, 2014 3:09 pm Post subject: How this can be happen
Dear My friend
Test the next two program and please explain how this can be happen ?
at the simulator the result give a different time .... how ?
'***************************************************************
' MedTronic Programmable Timer
' @Medtronic
' From 11\11\2006
' To 11\11\2006
'* Auther:Eng Medhat Saber
'* Email :EngMedhatSaber@hotmail.com
'* :EngMedhat_Saber@yahoo.com
'* Program:
'* This program is a programmable timer
'***************************************************************
'$sim
'$nosp
'$noinit
$regfile "8052.dat"
$crystal = 12000000
'****************************************************************
Dim Counte0 As Byte
Config Timer0 = Timer , Gate = Internal , Mode = 2
'Timer0 = Timer : timer0 operates as AutoReload
'Gate = Internal : no external gate control
'Mode = 1 : 8-bit auto reload (default)
'Disable Serial
Config Debounce = 20
Const Xtal = 12000000
Const T0_clk = Xtal / 12
Const T0_rate = 2 '0.5 sec
Const T0_reload = &H06 'int(65536-(T0_clk/T0_rate)+0.5)
On Timer0 Timer_0_int
Load Timer0 , 200 'when the timer reaches 200 an interrupt will occur
Priority Set Timer0 'highest priority
Enable Interrupts 'enable the use of interrupts
Enable Timer0 'enable the timer
Start Timer0
Rem Setting Of Priority
Main:
Do
Loop
'****************************************************************
Timer_0_int:
inc Counte0
If Counte0 = 10 Then
Counte0 = 0
CPL P1.0
End If
Return
'****************************************************************
Code No 2
'***************************************************************
' MedTronic Timer1Mode2 Simulation
' @Medtronic
' From 30\10\2014
' To 30\10\2014
'* Auther:Eng Medhat Saber
'* Email :EngMedhatSaber@hotmail.com
'* :EngMedhat_Saber@yahoo.com
'* Program:
'* This program is a Timer1Mode2 Simulation
'*******************************************************************************
'$sim
'$nosp
'$noinit
$regfile "8052.dat"
$crystal = 12000000
'*******************************************************************************
Dim Counte1 As Byte
Config Timer1 = Timer , Gate = Internal , Mode = 2
'Timer0 = Timer : timer0 operates as AutoReload
'Gate = Internal : no external gate control
'Mode = 2 : 8-bit auto reload (default)
'Disable Serial
Config Debounce = 20
Const Xtal = 12000000
Const T0_clk = Xtal / 12
Const T0_rate = 2 '0.5 sec
Const T0_reload = &H06 'int(65536-(T0_clk/T0_rate)+0.5)
On Timer1 Timer_1_int
Load Timer1 , 200 'when the timer reaches 200 an interrupt will occur
Priority Set Timer1 'highest priority
Enable Interrupts 'enable the use of interrupts
Enable Timer1 'enable the timer
Start Timer1
Rem Setting Of Priority
Main:
Do
Loop
'*******************************************************************************
Timer_1_int:
inc Counte1
If Counte1 = 10 Then
Counte1 = 0
CPL P1.0
End If
Return
'*******************************************************************************
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