View previous topic :: View next topic |
Author |
Message |
sandy
Joined: 08 Mar 2008 Posts: 79
|
Posted: Wed Jul 16, 2014 10:45 am Post subject: XMega128 ADC |
|
|
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 |
|
|
JC
Joined: 15 Dec 2007 Posts: 585 Location: Cleveland, OH
|
Posted: Thu Jul 17, 2014 3:04 am Post subject: |
|
|
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 |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Thu Jul 17, 2014 4:41 am Post subject: |
|
|
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 |
|
|
sandy
Joined: 08 Mar 2008 Posts: 79
|
Posted: Tue Jul 22, 2014 11:54 am Post subject: |
|
|
Hi, Thanks for the suggestions. I will check , but looks like a difficult task even for XMEGA. |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Tue Jul 22, 2014 5:32 pm Post subject: |
|
|
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 |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Jul 23, 2014 6:15 pm Post subject: |
|
|
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 |
|
|
|