Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Using Compiler Simulation

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-8051
View previous topic :: View next topic  
Author Message
MedhatSaber

Bascom Member



Joined: 11 Aug 2005
Posts: 25

blank.gif
PostPosted: Thu Oct 30, 2014 3:29 pm    Post subject: Using Compiler Simulation Reply with quote

Dear All my friends

Can i use the bascom8051 ide V2.0.14 simulation (Program --- Simulate ) for calculate an accurate time

Thanks and best regards

MedTronic
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Thu Oct 30, 2014 8:47 pm    Post subject: Reply with quote

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
Back to top
View user's profile Visit poster's website
MedhatSaber

Bascom Member



Joined: 11 Aug 2005
Posts: 25

blank.gif
PostPosted: Fri Oct 31, 2014 3:09 pm    Post subject: How this can be happen Reply with quote

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
'*******************************************************************************
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-8051 All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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