Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Simulating XMEGA ADC

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

Bascom Member



Joined: 02 Jan 2007
Posts: 76

blank.gif
PostPosted: Sat Feb 27, 2021 4:06 am    Post subject: Simulating XMEGA ADC Reply with quote

The essence of this question is:
Does the simulator work with the XMEGA ADC?

Below is the code from
"C:\MCS\BASCAVR2083\Samples\XMEGA\ADC\xm128-ADC.bas"
In the listing below I only added $sim

The screen grab blow shows the simulation output. The output of every channel is always zero even though on the simulator, I set the ADC to a non zero value.

If it does work, can you explain what I am doing wrong and what I need to do to get it to simulate the ADC?


Code:

'----------------------------------------------------------------
'                  (c) 1995-2020, MCS
'                      xm128-ADC.bas
'  This sample demonstrates the Xmega128A1 ADC
'-----------------------------------------------------------------

$regfile = "xm128a1def.dat"
$crystal = 32000000
$hwstack = 64
$swstack = 64
$framesize = 64
$sim

'First Enable The Osc Of Your Choice
Config Osc = Enabled , 32mhzosc = Enabled

'configure the systemclock
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1

Config Com1 = 19200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8

Print "ADC test"

'setup the ADC-A converter
Config Adca = Single , Convmode = Unsigned , Resolution = 12bit , Dma = Off , Reference = Int1v , Event_mode = None , Prescaler = 32 , Ch0_gain = 1 , Ch0_inp = Single_ended , Mux0 = &B000_00 , _
Ch1_gain = 1 , Ch1_inp = Single_ended , Mux1 = &B1_000 , Ch2_gain = 1 , Ch2_inp = Single_ended , Mux2 = &B10_000 , Ch3_gain = 1 , Ch3_inp = Single_ended , Mux3 = &B11_000

Dim W As Word , I As Byte , Mux As Byte
Do
  Mux = I * 8                                               ' or you can use shift left,3 to get the proper offset
  W = Getadc(adca , 0 , Mux)
  '   W = Getadc(adca , 0)                                     'when not using the MUX parameter the last value of the MUX will be used!
  ' use ADCA , use channel 0, and use the pinA.0-pinA.3
  Print "RES:" ; I ; "-" ; W
  Incr I
  If I > 3 Then I = 0
  Waitms 500
Loop Until Inkey(#1) = 27


end 'end program
 


(BASCOM-AVR version : 2.0.8.3 )
Back to top
View user's profile
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 537

PostPosted: Sat Feb 27, 2021 2:44 pm    Post subject: Reply with quote

Which input is the simulator expecting versus the code?
Back to top
View user's profile
syndetic1

Bascom Member



Joined: 02 Jan 2007
Posts: 76

blank.gif
PostPosted: Sat Feb 27, 2021 6:04 pm    Post subject: Reply with quote

The simulator only allows you to set values for inputs 0-7.
I set all of the 8 simulator settings to non zero values.

I think Getadc(adca , 0 , Mux) where Mux = 0 should give me analogue input 0 ie PA0.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Sun Feb 28, 2021 11:23 am    Post subject: Reply with quote

Simulation of the ADC of the Xmega is not supported.
_________________
Mark
Back to top
View user's profile Visit poster's website
syndetic1

Bascom Member



Joined: 02 Jan 2007
Posts: 76

blank.gif
PostPosted: Sun Feb 28, 2021 9:01 pm    Post subject: Solved - Thank you Reply with quote

Thanks Mark for clarifying
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