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.
您好!
我正在尝试测量 PWM 信号的脉宽。 这是我正在使用的代码、我会不断地被发送到 IntDefaultHandler 中。 我尝试捕获的信号是来自 RC 接收器的333hz PPM 信号。 如果有任何帮助,将不胜感激。 谢谢你。
#define PART_TMC123GH6PM #include // C99标准的变量定义。 #include // C99标准的输入和输出功能。 #include // C99标准的布尔定义。 #include "inc/hw_ints.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/rom.h" #include "driverlib/sysctl.h" #include "driverlib/pwm.h" #include "driverlib/sctl.h"/用于控制 API 和 SYDriverLib 的宏定义。 #include "driverlib/interrupt.h"//为 DriverLib 的 NVIC 控制器 API 定义和宏。 #include "driverlib/gpio.h"// DriverLib GPIO API 的定义和宏。 #include "driverlib/timer.h"//为 DriverLib 的计时器 API 定义和宏。 #include "driverlib/pin_map.h"//Mapping of peripherals to pins for all parts。 #include "driverlib/adc.h"// DriverLib 的 ADC API 定义。 #include "driverlib/fpu.h"// FPU 操作例程的原型。 #include "inc/tm4c123ghp6.h"//中断和寄存器分配的定义。 #include "inc/hw_memmap.h"// Tiva C 系列器件的存储器映射定义。 #include "inc/hw_types.h"//常用类型和宏的定义。 int ***=0; int a = 0、b = 0、c = 0; void timer_Initialize (void) { //启用计时器1 SysCtlPeripheralEnable (SYSCTL_Periph_Timer1); SysCtlPeripheralEnable (SYSCTL_Periph_GPIOB); // PB5引脚配置为定时器1 GPIOPinConfigure (GPIO_PB5_T1CCP1); //设置计时器类型 GPIOPinTypeTimer (GPIO_PORTB_BASE、GPIO_PIN_5); //将计时器配置为边沿时间捕获 TimerConfigure (Timer1_base、TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_CAP_TIME); //事件设置为两个脉冲边沿 TimerControlEvent (Timer1_base、timer_B、timer_event_both _edge); //配置计时器1b 中断 IntEnable (INT_TIMER1B); //启用计时器中断 TimerIntEnable (Timer1_base、timer_CAPB_EVENT); //启用处理器中断 IntMasterEnable(); //启用计时器 TimerEnable (Timer1_base、timer_B); } int main (void) { SysCtlClockSet ( SYSCTL_SYSDIV_64 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHz); Timer_Initialize(); while (1) { PULSE_TIME_1 = TimerLoadGet (Timer1_base、timer_B); TimerEnable (Timer1_base、timer_B); } } 空 Timer1IntHandler (空) { TimerIntClear (Timer1_base、timer_CAPB_event); b = TimerValueGet (Timer1_base、timer_B); 如果(b < a) C = 65535 + A - b; 其他 c = a - b; PULSE_TIME_1 = c / 3125; A = TimerValueGet (Timer1_base、timer_B); }
[引用 user="Tyler Lemery"]这是我要使用的代码,我会不断地发送到 IntDefaultHandler 中。 您是否修改 了 tm4c123gh6m_startup_ccs.c 源文件中的 g_pfnVectors []中断矢量表,以添加 计时器1子计时器 B 的 Timer1IntHandler?
默认 的 g_pfnVectors []中断矢量表为 所有外设中断矢量安装了 IntDefaultHandler,这可能是 启用计时器中断后程序最终在 IntDefaultHandler 中结束的原因。
非常感谢您的回复...这解决了问题。 我对此表示赞赏。