Reply by jtw131 September 2, 20102010-09-02
--- In l..., Bertrik Sikken wrote:
>
> On 29-8-2010 4:06, omprakash alone wrote:
> > Hi,
> > I am using LPC2148 ARM Controller having 2 adc(6 + 8 channels) and one
> > dac channel.
> >
> > My ADC is having sampling frequency of 410 ksps ad dac of 400 ksps.
> >
> > but i want both adc/dac should work on max of 500 Hz.
> >
> > For setting sampling frequency of adc/dac ie 500 Hz, what i have to do?
>
> What I'm doing on my LPC2148 project to record from the ADC is letting
> a timer generate a signal on the MAT0.0 pin and configuring the ADC to
> start a conversion on the rising edge of the MAT0.0 pin. This gives an
> accurate ADC timing.
> In the interrupt routine for the ADC (I use the FIQ for that), I
> read the converted value and put it in a ringbuffer/FIFO.
> You could push out a processed sample out the DAC in the same interrupt
> handler.
>
> To set up the timer:
> // enable timer
> PCONP |= PCTIM0;
>
> // stop timer and reset
> TIMER0_TCR = 2;
> // count PCLKs
> TIMER0_CTCR = 0;
> // no prescaler
> TIMER0_PR = 0;
> // match register
> TIMER0_MR0 = iDivider - 1;
> // reset counter on MR0 match
> TIMER0_MCR = 2;
>
> // configure MAT0.0 to toggle on match
> TIMER0_EMR = (3 << 4);
>
> // clear interrupts
> TIMER0_IR = 0xff;
>
> // enable mat0.0 (P0.22)
> HalPinSelect(22, 3);
>
> To set up the ADC:
> // enable ADC
> PCONP |= PCAD0;
>
> AD0CR = (1 << iChan) | // SEL
> ((iDiv - 1) << 8) | // CLKDIV
> (0 << 16) | // BURST,
> (0 << 17) | // CLKS,
> (1 << 21) | // PDN,
> (3 << 24) | // START,
> (0 << 27); // EDGE,
>
> // enable input AD0.x
> HalPinSelect(iPin, adc0_chan2pin[iChan].iSel);
>
> To set up the A/D interrupt:
> // configure interrupts
> VICIntSelect = 0x00040000; // A/D interrupt
> VICIntEnable = 0x00040000;
>
> // enable int for all channels
> AD0INTEN = (1 << 8);
>
> This is just partial code to serve as an example.
>
> Kind regards,
> Bertrik
>
What doest he corresponding ISR look like? I am trying to set up a very similar Timer1/ADC1 based sampling routine but I am not seeming to get into the ISR.

An Engineer's Guide to the LPC2100 Series

Reply by Bertrik Sikken August 29, 20102010-08-29
On 29-8-2010 4:06, omprakash alone wrote:
> Hi,
> I am using LPC2148 ARM Controller having 2 adc(6 + 8 channels) and one
> dac channel.
>
> My ADC is having sampling frequency of 410 ksps ad dac of 400 ksps.
>
> but i want both adc/dac should work on max of 500 Hz.
>
> For setting sampling frequency of adc/dac ie 500 Hz, what i have to do?

What I'm doing on my LPC2148 project to record from the ADC is letting
a timer generate a signal on the MAT0.0 pin and configuring the ADC to
start a conversion on the rising edge of the MAT0.0 pin. This gives an
accurate ADC timing.
In the interrupt routine for the ADC (I use the FIQ for that), I
read the converted value and put it in a ringbuffer/FIFO.
You could push out a processed sample out the DAC in the same interrupt
handler.

To set up the timer:
// enable timer
PCONP |= PCTIM0;

// stop timer and reset
TIMER0_TCR = 2;
// count PCLKs
TIMER0_CTCR = 0;
// no prescaler
TIMER0_PR = 0;
// match register
TIMER0_MR0 = iDivider - 1;
// reset counter on MR0 match
TIMER0_MCR = 2;

// configure MAT0.0 to toggle on match
TIMER0_EMR = (3 << 4);

// clear interrupts
TIMER0_IR = 0xff;

// enable mat0.0 (P0.22)
HalPinSelect(22, 3);

To set up the ADC:
// enable ADC
PCONP |= PCAD0;

AD0CR = (1 << iChan) | // SEL
((iDiv - 1) << 8) | // CLKDIV
(0 << 16) | // BURST,
(0 << 17) | // CLKS,
(1 << 21) | // PDN,
(3 << 24) | // START,
(0 << 27); // EDGE,

// enable input AD0.x
HalPinSelect(iPin, adc0_chan2pin[iChan].iSel);

To set up the A/D interrupt:
// configure interrupts
VICIntSelect = 0x00040000; // A/D interrupt
VICIntEnable = 0x00040000;

// enable int for all channels
AD0INTEN = (1 << 8);

This is just partial code to serve as an example.

Kind regards,
Bertrik
Reply by omprakash alone August 29, 20102010-08-29
Hi,
I am using LPC2148 ARM Controller having 2 adc(6 + 8 channels) and one dac channel.

My ADC is having sampling frequency of 410 ksps ad dac of 400 ksps.

but i want both adc/dac should work on max of 500 Hz.

For setting sampling frequency of adc/dac ie 500 Hz, what i have to do?

Omprakash Alone