Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

XMega128 ADC

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
sandy

Bascom Member



Joined: 08 Mar 2008
Posts: 79

blank.gif
PostPosted: Wed Jul 16, 2014 10:45 am    Post subject: XMega128 ADC Reply with quote

Hi board; I need to ask if we operate the XMega128 ADC at 2Msps ,I found it can resolve its conversion in 7+1 clock cycles. What delay/overhead will Bascom-AVR induce in giving final result . I need to log a time varying waveform every 15us , is it possible . Can someone suggest me alternative.

(BASCOM-AVR version : 2.0.7.7 )
Back to top
View user's profile
JC

Bascom Member



Joined: 15 Dec 2007
Posts: 586
Location: Cleveland, OH

usa.gif
PostPosted: Thu Jul 17, 2014 3:04 am    Post subject: Reply with quote

That gives you 480 clock cycles between interrupts.
That should be enough to read the (prior) ADC value, store it, and initiate the next conversion.

Bascom will do a lot of register pushes and pops surrounding your ISR.
Some compilers will only save the registers that are used within the ISR, others just save "everything".
I suspect Bascom is in the latter category.
Obviously if you write your own ISR, (Asm), then you can push & pop only what you used.

I would set a spare I/O pin high when you enter the ISR and clear it on exit.
I would then watch the pin on an O'scope while the program is running and see how much time the ISR takes, and how much "spare time" there is for the Main Loop. Note, however, when doing this, that the Pin High time doesn't include the ISR register pushes and pops which surround your code.

The Xmegas have a DMA module. I've not used it, but you might read that section and see if it helps you out.
It can read a certain number of ADC readings and automatically store them in memory.
I am not sure at the moment how you would trigger the precise timing you seek.

JC
Back to top
View user's profile Visit poster's website
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1570
Location: Basel, Switzerland

switzerland.gif
PostPosted: Thu Jul 17, 2014 4:41 am    Post subject: Reply with quote

Hi,

Have a look at the nosave Option. This will stop Bascom from saving almost all Registers when entering an ISR, but you have to the push/Pop the Register used or things can go badly wrong.

Regards
Ian Dobson

_________________
Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile
sandy

Bascom Member



Joined: 08 Mar 2008
Posts: 79

blank.gif
PostPosted: Tue Jul 22, 2014 11:54 am    Post subject: Reply with quote

Hi, Thanks for the suggestions. I will check , but looks like a difficult task even for XMEGA.
Back to top
View user's profile
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1570
Location: Basel, Switzerland

switzerland.gif
PostPosted: Tue Jul 22, 2014 5:32 pm    Post subject: Reply with quote

Hi,

Just run you code in the Simulator, without the nosave Option. Set a breakpoint at the start of the ISR, single step through the code looking at which register Change colour, thats the Registers you'll Need to save/restore with push&pop.

Something like (This is just an example):-
Code:
 
  !push r10                                                 'save r10
  !push r11                                                 'save r11
  !push r16                                                 'save r16
  !push r23                                                 'save r23
  !push r24                                                 'save r24
  !push r26                                                 'save r26
  !push r27                                                 'Save R27
  !IN r27, SREG                                             'Copy SREG into R27
  !Push r27                                                 'Save it (sreg)
 'add your Basic code here
  !pop r27                                                  'restore sreg into r27
  !Out Sreg , R27                                           'copy to sreg
  !pop r27                                                  'restore r27
  !pop r26                                                  'restore r26
  !pop r24                                                  'restore r24
  !pop r23                                                  'restore r23
  !pop r16                                                  'restore r16
  !pop r11                                                  'restore r11
  !pop r10                                                  'restore r10
return
 


You might Need to also save/restore the RAMPZ Register, it depends on your CPU/Flash size.

Regards
Ian Dobson

_________________
Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Jul 23, 2014 6:15 pm    Post subject: Reply with quote

This interrupt stuff seems to be a pretty kludge, if it comes to an XMega, which should be well able to transfer the sampled values via DMA to SRam.
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive 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