TI中文支持网
TI专业的中文技术问题搜集分享网站

TM4C进入FaultISR的问题

板子是TM4C123GH6PM,总是会遇到莫名其妙进入FaultISR的问题,且不知道怎么解决,今天又遇上了。代码贴在下面,用了很多延时也没用。请问大家有什么解决办法嘛?

/*
 * main.c
 */

#include "mytype.h"
#include "stdbool.h"
#include "stdint.h"
#include "inc/hw_types.h"

#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/gpio.h"
#include "driverlib/adc.h"
#include "driverlib/pin_map.h"
#include "inc/hw_memmap.h"
#include "driverlib/interrupt.h"
#include "driverlib/timer.h"
#include "driverlib/fpu.h"
#include "inc/hw_ints.h"
#include "mytype.h"
#include "stdio.h"

long sysclock = 0;
uint32_t buffer;
byte refresh_lcd_flag;

#define DELAY SysCtlDelay(30)

#define TIMER_FREQUENCY 100
#define SYSTICK_FREQUENCY 1

void initSystem();
void LCDDisplay(char * notation,double num,unsigned char x,unsigned char y);

int main(void) {
	FPUEnable();
	FPULazyStackingEnable();
	initSystem();
	SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |SYSCTL_OSC_MAIN);
	DELAY;
	while(1){
		if(refresh_lcd_flag){
			refresh_lcd_flag = 0;
//			LCDDisplay("num1",buffer,0,0);
		}
	}
}

void initSystem(){
	sysclock = SysCtlClockGet();
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
	DELAY;
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	DELAY;
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	DELAY;
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	DELAY;


	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,GPIO_INT_PIN_0);
	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,GPIO_INT_PIN_1);
	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,GPIO_INT_PIN_5);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_INT_PIN_2);

	GPIOPinTypeADC(GPIO_PORTB_BASE,GPIO_PIN_4);
	ADCSequenceConfigure(ADC0_BASE,0,ADC_TRIGGER_PROCESSOR,0);
	ADCSequenceStepConfigure(ADC0_BASE,0,0,ADC_CTL_CH0 | ADC_CTL_END | ADC_CTL_IE);ADCSequenceEnable(ADC0_BASE, 0);ADCIntClear(ADC0_BASE, 0);ADCIntEnable(ADC0_BASE,0);IntEnable(INT_ADC0SS0);DELAY;

	i2cInit();
	i2cCls();
	DELAY;

	SysTickEnable();
	SysTickPeriodSet(SysCtlClockGet() / SYSTICK_FREQUENCY);
	SysTickIntEnable();
	IntMasterEnable();
}
void adcSeq0IntHandler(void){
	ADCIntClear(ADC0_BASE,0);
	TimerIntClear(TIMER0_BASE,TIMER_TIMA_TIMEOUT);
	while(!ADCIntStatus(ADC0_BASE, 0, false));//等待采集结束
	ADCSequenceDataGet(ADC0_BASE,0,&buffer);
}
void LCDDisplay(char * notation,double num,unsigned char x,unsigned char y){
	char buf[50];
	if(num>0){
		sprintf(
				buf,
				"%s: %d.%02d",
				notation,
				(int)num,
				(int)((num-(int)num)*100)
		);
//		i2cP6x8Str(x,y,buf);
	}else{
		sprintf(
				buf,
				"%s: -%d.%02d",
				notation,
				(int)-num,
				(int)-((num-(int)num)*100)
		);
//		i2cP6x8Str(x,y,buf);
	}
}
void sysTickIntHandler(void){
	refresh_lcd_flag = 1;
}
xyz549040622:

先定位到进入FaultISR前操作的是什么外设,TM4C对外设的顺序操作时序要求比较严格,打开外设后延时6个us就够了,应该不是这里的问题。

赞(0)
未经允许不得转载:TI中文支持网 » TM4C进入FaultISR的问题
分享到: 更多 (0)