#define ADC_DATA_BASE_ADDRESS 0x40034000 // AD0DR0 to AD0DR7 are 0xE003-4010 to 0xE003-402C
#define ADC_CR 0x000 //A/D Control Register. The ADCR register must be written to selectthe operating mode before A/D conversion can occur.
#define ADC_GDR 0x004 //A/D Global Data Register. This register contains the ADCs DONE bit and the result of the most recent A/D conversion.
#define ADC_INTEN 0x00C //A/D Interrupt Enable Register. This register contains enable bits that allow the DONE flag of each A/D channel to be included or excluded from contributing to the generation of an A/D interrupt.
#define ADC_DR0 0x40034010 //A/D Channel 0 Data Register. This register contains the result of the most recent conversion completed on channel 0.
#define ADC_DR1 0x40034014 //
#define ADC_DR2 0x40034018 //
#define ADC_DR3 0x01C //
#define ADC_DR4 0x020 //
#define ADC_DR5 0x024 //
#define ADC_DR6 0x028 //
#define ADC_DR7 0x02C //
#define ADC_STAT 0x030 //A/D Status Register. This register contains DONE and OVERRUN flags for all of the A/D channels, as well as the A/D interrupt/DMA flag.
#define ADC_trm 0x034 //ADC trim register.
#define SHIFT 0x4
As Gus say’s you have the wrong base address. The lpc1788 user manual is available from NXP’s website and is an essential resource if you’re working with RLP.
Hi guys I noticed that this example is just reading a register to get the voltage level of the A2D but how often is this registry value refreshed?
If I need to read a value on a specific moment (not before that time), how can I make sure when the reading was taken?
I have another post where I try to manually ask for an specific reading at an specific time, but is is not stable and it always has the overrun bit on, I wondering if there is a proper way to do that.
I think you can check the status bit before you read the ADC channel.
int stat = (*((int*)(ADC_DATA_BASE_ADDRESS) + ADC_STAT)) & 0x007; //.Read status of ADC's just chaneels 1, 2 and 3
while(stat != 0x7){
underFlow+=1;
stat = (*((int*)(ADC_DATA_BASE_ADDRESS) + ADC_STAT)) & 0x007;
}//Wait for it to be ready
RLPext->Delay(3);//3uS = 333KHz Sampling - So it should be safe to read the data