ADC sampling rate causes hard fault

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

ADC sampling rate causes hard fault

342 Views
lpcware
NXP Employee
NXP Employee
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);
0 Kudos
1 Reply

216 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Thu Nov 13 10:17:17 MST 2014
The "+ 146" refers to the code address offset (in bytes) from the start the function, ADCInit in this case.

Use the disassembly tool to get a listing. Then you can see the actual instruction causing the problem.

Or turn on the disassembly view "the small button" (look it up in the help.)
to step through in the debugger.

NB: I can't remember of the cuff if the '146' is hex or is decimal.

Mike.
0 Kudos