lpcware

ADC sampling rate causes hard fault

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Ano on Thu Nov 13 10:09:52 MST 2014
Working on LPC11C14 which should have a max ADC frequency of 400kHz.

Debug Register view shows:
Fault PC   = 0x000001FE
           = ADC_Init + 146 in section .text   <----- what does this mean? The 146 I mean
           = File: ../example/src/adc.c  Line: 74


Code:
//Must be performed before each ADC-Measurement
void ADC_Init(uint8_t channel)
{
if(channel == 0)
{
Gain1Time = EEPROM_GetGain1Time();
Gain2Time = EEPROM_GetGain2Time();
Gain3Time = EEPROM_GetGain3Time();
SampleQuantity = EEPROM_GetSampleQuantity();

Chip_IOCON_PinMuxSet(LPC_IOCON, UltrasonicPin, FUNC2);
Chip_ADC_Init(LPC_ADC, &ADCSetup);                                        //Default Setup 400kHz/10bit
Chip_ADC_SetSampleRate(LPC_ADC, &ADCSetup, EEPROM_GetADCFrequ()));//Set Rate to X kHz
Chip_ADC_EnableChannel(LPC_ADC, TempChannel, DISABLE);
Chip_ADC_EnableChannel(LPC_ADC, UltrasonicChannel, ENABLE);

}
else if(channel == 1)
{
Chip_IOCON_PinMuxSet(LPC_IOCON, TempPin, FUNC2);
Chip_ADC_Init(LPC_ADC, &ADCSetup);//Default Setup 400kHz/10bit
Chip_ADC_SetBurstCmd(LPC_ADC, DISABLE);
Chip_ADC_SetSampleRate(LPC_ADC, &ADCSetup, 10000);//Set Rate to 10kHz
Chip_ADC_EnableChannel(LPC_ADC, UltrasonicChannel, DISABLE);
Chip_ADC_EnableChannel(LPC_ADC, TempChannel, ENABLE);
}
} <-------------- Line 74


The problem seems to be in the "Chip_ADC_SetSampleRate(LPC_ADC, &ADCSetup, EEPROM_GetADCFrequ()));". If the Frequency loaded is for example 200kHz or below, everything works fine. Even 300kHz works. But if I try to set it to 400kHz, it doesn't work anymore. (Even if i do it manually by changing it to:
Chip_ADC_SetSampleRate(LPC_ADC, &ADCSetup, 400000);

Outcomes