Bertrik wrote:
> Just curious because I'm working on something similar...
>
> How are you triggering the ADC?
Well I tried lots of different ways but found this line to be the
fastest in my case.
#define ADC_CLK_60_50 0x0B00 // 60MHz/12 = 5.0mhz
#define ADC_SEL1 0x02 // Select ADC n.1
#define ADC_PDN 0x00200000 // bit 21 Power down (1 for power)
#define ADC_START_NOW 0x01000000 // bit 24 Start ADC now
AD0CR = ADC_CLK_60_50 | ADC_SEL1 | ADC_PDN | ADC_START_NOW;
> ADC burst mode looks a bit awkward because with (for example) 8-bit
Yep, I dont trust burst mode because if an interrupt takes over would
you miss samples and hit over run? Not sure but what I have works nice.
> resolution, the ADC takes a sample every 9 ADC clocks, which makes
> it hard to get a nice round sampling rate.
> I tried to synchronise the ADC to a timer. This works and I make
> almost any sample rate I want, but it only works when the trigger
> signal is sent out to a pin.
Yep, been there done that, but you will only get 320k (from my testing,
I have been wrong before.) sample at best compared to the 500k+ I am
getting.
> How are you storing the ADC data?
I just use a for loop to loop through all the pixels
uint32_t tADC;
tADC = (AD0DR1 << 16) >> 22; // copy ADC out to get 10 bits.
cambuff[tIdx] = tADC; // store ADC in camera buffer.
> Just a tight loop polling the ADC? or a FIQ? something else?
I found that polling the done flag to be a waste of time. Limited me to
that 320 samples again. I figured we know how many clocks it takes for
a conversion so I just NOPed it plus some extras for pipeline things
that I dont know enough about
The dreaded inline assembly which works awesome for me. It doesnt use
any variables so thats good I guess.
e.g
#define NOP2 {__asm {nop}\
__asm {nop}}
Some people may want to pipe up and say I am doing it all wrong. I dont
care. That part of my project is complete and runs very fast within the
noise specs.
I also fixed my intermittent bug. It was a spurious intterrupt. When I
was starting the hardware camera shutter I was turning off the USB
interrupt. This caused the usual issues.
The fix I copied from here worked a treat.
VICDefVectAddr = (unsigned long) default_interrupt_handler;// spurious
interrupt handler
void default_interrupt_handler(void) __irq
{ // this does get called occasionally
return;
}
Cheers
KeithMessage
Re: ADC zooming along
2006-04-26 by pitstock_kiwi
Attachments
- No local attachments were found for this message.