Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

The big difference between AVR simulator and Real hardware

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

Bascom Member



Joined: 31 Jul 2013
Posts: 32
Location: Serbia

blank.gif
PostPosted: Sun Feb 14, 2016 9:08 pm    Post subject: The big difference between AVR simulator and Real hardware Reply with quote

Please help,

I work on some time critical project and I found that time (cycl.) need for
GETADC is not like in AVR simulator. With DSO I measured 80 times bigger value !

This is simple code for measure purpose:

$Regfile="m328pdef.dat"
$Crystal=16000000
$hwstack=32
$swstack=8
$framesize=50

Config PortD.2 = Output

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Start Adc

Dim W As Word

portd.2=1

Do
portd.2=0
W = Getadc(0) ' in AVR Simulator need 0.00125ms, BUT IN REAL HARDWARE WITH DSO I measured ~ 0.2ms !!!
portd.2=1
waitms 2
Loop

End


Where is the problem ?

Best regards

Z.D

(BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 )
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sun Feb 14, 2016 11:04 pm    Post subject: Reply with quote

Simulation time is likely pure execution time of ASM code and does not reflect actual conversion time.
If it's time critical, then the auto setting of config adc and the command GetADC is probably not the right thing anyway.
Reading the data sheet and manually setting the prescaler is self-evident.

The "auto" setting chooses the greatest ADC-prescaler and such the slowest conversion rate, also the GetADC always takes a dummy sample, thus needs two times a sampling cycle.

And btw., your problem whatsoever is in no way more important than others. Coloring the code in red instead of using proper code tags doesn't show most clever behavior.
Back to top
View user's profile
dabatek

Bascom Member



Joined: 31 Jul 2013
Posts: 32
Location: Serbia

blank.gif
PostPosted: Mon Feb 15, 2016 12:19 am    Post subject: Reply with quote

Thank you MWS for clear and quick answer,
also is clear for coloring code...
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR 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