ADC Burst?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC Burst?

1,144 Views
bmildh
Contributor I

 

I'm trying to get ADC Burst working on my LPC1758, but It seems like my ADC ISR does not fire. If anyone could shed some light on this I would be most grateful.

The way that I think I understand it, burst-mode should give me continuous ADC conversion on the channels that I select. If I have selected channel 2,4,5 and 7, and also enable the interrupt for channel 7, then, when channel 7 finish a conversion, I should be able to harvest the values for channel 2,4,5 and 7.

This is my initialization:

 

#define SBIT_AD0_CLCKDIV	8u		// ADC0CR (Bits 15:8)
#define SBIT_AD0_BURST		16u		// ADC0CR 
#define SBIT_AD0_PDN		21u		// ADC0CR
#define SBIT_AD0_START		24u		// ADC0CR (Bits 26:24)
#define SBIT_AD0_EDGE		27u		// ADC0CR 
#define SBIT_AD0_ADGINTEN	8u		// AD0INTEN
#define SBIT_AD0_PCADC		12u		// PCONP
#define SBIT_AD0_INTEN2		2u
#define SBIT_AD0_INTEN4		4u		// AD0INTEN
#define SBIT_AD0_INTEN5		5u
#define SBIT_AD0_INTEN7		7u

void Init_ADC(void)
{
	set_PINSEL(0,25,1);		// Ch 2
	set_PINSEL(1,30,3);		// Ch 4 
	set_PINSEL(1,31,3);		// Ch 5 
	set_PINSEL(0,2,2); 		// Ch 7 

	// No pull-up no pull-down (function ADC) 
	set_PINMODE(0,25,NOPULL);	// Ch 2
	set_PINMODE(1,30,NOPULL); 	// Ch 4
	set_PINMODE(1,31,NOPULL); 	// Ch 5
	set_PINMODE(0,2,NOPULL);	// Ch 7 
	
	// ADC enabled, turning on power
	LPC_SC->PCONP |= (1<<SBIT_AD0_PCADC); 

	// Stop ADC (in burst mode this should be 000)		
	LPC_ADC->CR &= ~(7<<SBIT_AD0_START); 	

	// Enable interrupt on all of the selected channels
	LPC_ADC->INTEN &= ~(1<<SBIT_AD0_ADGINTEN);
	LPC_ADC->INTEN |= (1<<SBIT_AD0_INTEN7) | (1<<SBIT_AD0_INTEN2) | (1<<SBIT_AD0_INTEN4) | (1<<SBIT_AD0_INTEN5);

	// Select channel 2,4,5,7
	LPC_ADC->CR |= ((1<<2) | (1<<4) | (1<<5) | (1<<7));		
	
	// PCLK = CCLK / 2 => 40Mhz; We divide the PCLK with 4 and get 10Mhz.
        // The ADC clock should be 13Mhz or slightly less (see doc)
	LPC_ADC->CR |= ((4-1)<<SBIT_AD0_CLCKDIV);
	
	// Enable burst mode
	LPC_ADC->CR |= (1<<SBIT_AD0_BURST);						
	
	// ADC operational
	LPC_ADC->CR |= (1<<SBIT_AD0_PDN);			
	
	NVIC_EnableIRQ(ADC_IRQn);
}

 

 

And this is my ISR: (right now I'm only interesting in the ADCbusyflag. I just want to know if this flag is set. In my main loop I print out on serial every second, the value of ADCbusyflag. The value is always zero, indicating that the ISR is never called. Also, the STAT register of the ADC is always zero. 

 

void ADC_IRQHandler(void)
{
	ADCmean[7] = ((LPC_ADC->DR[7]>>4) & 0x0FFF);
	ADCmean[5] = ((LPC_ADC->DR[5]>>4) & 0x0FFF);
	ADCmean[2] = ((LPC_ADC->DR[2]>>4) & 0x0FFF);
	ADCmean[4] = ((LPC_ADC->DR[4]>>4) & 0x0FFF);
	ADCbusyflag = 1;
}

 

 

What I'm I missing?

Labels (1)
Tags (1)
0 Kudos
4 Replies

1,101 Views
bmildh
Contributor I

I tried just enabling channel 7 interrupt, but no dice. 

Anyway, I'll figure It out, probably just some bit in some register that is wrong. It usually is  

Thanks for the help. 

0 Kudos

1,126 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello bmildh,

Have you test whether it works well when without burst mode? 

And confirm connect to the right pin to ADC signal.

 

BR

Alice

0 Kudos

1,123 Views
bmildh
Contributor I

Aey, It works in software mode. I use one channel at a time with interrupt. In the ISR I read the adc value for the current channel, then I setup the adc for the next channel. I can then start the timer at arbitrary time intervals (like, 1ms, 10ms or whatever). 

0 Kudos

1,106 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

How about just enable channel 7 interrupt?

If still can't work, you can attach your project, I will check it on my side.

 

BR

Alice

0 Kudos