This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
初学M4遇到的问题,我在ti官方的例程timers上加入了ADC模块的使用,同时使用了一个普通IO口驱动的显示屏,发现一旦运行就会进入FaultISR函数。查阅Program Status Register (xPSR) 寄存器,为0x01000003,应该是出现了hard fault。但是我不知道是什么原因。
1.去掉ADC部分程序可以运行,显示屏工作正常;
2.加入ADC初始化程序,程序调试时可以工作,掉电后重新上电无法工作;
3.加入ADC初始化及调用函数,程序运行后很快进入FaultISR函数。
请问大家知道是什么原因吗?
工程见附件。
ADC初始化函数:
void ConfigureADCs(void){
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 1, 3, ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 1);
}
ADC调用在while (1)循环中:
while(1)
{
//show power-on time
show_time(79,0,Power_On_time);
//show internal temperature of the core
/*ADCIntClear(ADC0_BASE, 1);
ADCProcessorTrigger(ADC0_BASE, 1);
while(!ADCIntStatus(ADC0_BASE, 1, false)){}
ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);
ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4;
ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10;*/
//LCD_P6x8Int(85,2,Main_Loop_Count);
//show main loops
Main_Loop_Count++;
if (Main_Loop_Count > 9999999) Main_Loop_Count = 0;
LCD_P6x8Int(85,7,Main_Loop_Count);
}