完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
//*****************************************************************************
// // pwm.c - Example demonstrating timer-based PWM on a 16-bit CCP. // // Copyright (c) 2010-2012 Texas Instruments Incorporated. All rights reserved. // Software License Agreement // // Texas Instruments (TI) is supplying this software for use solely and // exclusively on TI's microcontroller products. The software is owned by // TI and/or its suppliers, and is protected under applicable copyright // laws. You may not combine this software with "viral" open-source // software in order to form a larger program. // // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES, FOR ANY REASON WHATSOEVER. // // This is part of revision 9453 of the Stellaris Firmware Development Package. // //***************************************************************************** /*PB5(TIMER1_B)产生PWM并且是正常的,配置PB1(TIMER2_B)捕获产生pwm的下降沿,但是中断函数一直进不去啊,设置断点发现进不去,求助,问题出在哪里,*/(已经在startup_ccs.c中注册了中断函数) #ifndef PART_LM4F120H5QR #define PART_LM4F120H5QR #endif #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_timer.h" #include "inc/hw_ints.h" #include "inc/hw_gpio.h" #include "driverlib/timer.h" #include "driverlib/interrupt.h" #include "driverlib/sysctl.h" #include "driverlib/gpio.h" #include "utils/uartstdio.h" #include "driverlib/pin_map.h" //***************************************************************************** // // Configure Timer1B as a 16-bit PWM with a duty cycle of 66%. // //***************************************************************************** int i=0; void Timer2BIntHandler(void); int main(void) [ // // Set the clocking to run directly from the external crystal/oscillator. // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // The Timer1 peripheral must be enabled for use. // SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2); // // For this example CCP1 is used with port B pin 5. // The actual port and pins used may be different on your part, consult // the data sheet for more information. // GPIO port B needs to be enabled so these pins can be used. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // // Configure the GPIO pin muxing for the Timer/CCP function. // This is only necessary if your part supports GPIO pin function muxing. // Study the data sheet to see which functions are allocated per pin. // GPIOPinConfigure(GPIO_PB5_T1CCP1); GPIOPinConfigure(GPIO_PB1_T2CCP1); // // Set up the serial console to use for displaying messages. This is // just for this example program and is not needed for Timer/PWM operation. // GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_5); GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_1); // // Configure Timer1B as a 16-bit periodic timer. // TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_B_PWM); TimerConfigure(TIMER2_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_B_CAP_COUNT); // // Set the Timer1B load value to 50000. For this example a 66% duty // cycle PWM signal will be generated. From the load value (i.e. 50000) // down to match value (set below) the signal will be high. From the // match value to 0 the timer will be low. // TimerLoadSet(TIMER1_BASE, TIMER_B, 40000); TimerLoadSet(TIMER2_BASE, TIMER_B, 1); TimerControlEvent(TIMER2_BASE,TIMER_B,TIMER_EVENT_NEG_EDGE); // // Set the Timer1B match value to load value / 3. // TimerMatchSet(TIMER1_BASE, TIMER_B, TimerLoadGet(TIMER1_BASE, TIMER_B) / 2); TimerMatchSet(TIMER2_BASE, TIMER_B, 1); // // Enable Timer1B. // IntMasterEnable(); TimerEnable(TIMER1_BASE, TIMER_B); TimerIntEnable(TIMER2_BASE, TIMER_CAPB_EVENT); IntEnable(INT_TIMER2B); TimerEnable(TIMER2_BASE, TIMER_B); TimerIntRegister(TIMER2_BASE, TIMER_B,Timer2BIntHandler); // // Loop forever while the Timer1B PWM runs. // while(1) [ ; ] ] void Timer2BIntHandler(void) [ i++; if(i==10000) [ i=0; ] ] PB5(TIMER1_B)产生PWM并且是正常的,配置PB1(TIMER2_B)捕获产生pwm的下降沿,但是中断函数一直进不去啊,设置断点发现进不去,求助,问题出在哪里, |
|
相关推荐
2 个讨论
|
|
|
请参考下边Timer1B 作CCP的配置:
//Timer1 configure for ccp function TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_B_CAP_COUNT); TimerControlEvent(TIMER1_BASE,TIMER_B,TIMER_EVENT_NEG_EDGE); TimerControlStall(TIMER1_BASE,TIMER_B,true); TimerLoadSet(TIMER1_BASE, TIMER_B, 6003); TimerMatchSet(TIMER1_BASE, TIMER_B, 3); TimerIntEnable(TIMER1_BASE, TIMER_CAPB_MATCH); IntEnable(INT_TIMER1B); IntPrioritySet(INT_TIMER1B,0x20); IntMasterEnable(); |
|
|
|
|
|
|
|
|
按照你说的配置了,但是还是进不去中断函数,换到其他定时器的捕获端口也不行, 我已经在start_ccs.c中注册了这个函数 //***************************************************************************** #ifndef PART_LM4F120H5QR #define PART_LM4F120H5QR #endif #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_timer.h" #include "inc/hw_ints.h" #include "inc/hw_gpio.h" #include "driverlib/timer.h" #include "driverlib/interrupt.h" #include "driverlib/sysctl.h" #include "driverlib/gpio.h" #include "utils/uartstdio.h" #include "driverlib/pin_map.h" //***************************************************************************** // // Configure Timer1B as a 16-bit PWM with a duty cycle of 66%. // //***************************************************************************** int i=0; void Timer1AIntHandler(void); int main(void) [ // // Set the clocking to run directly from the external crystal/oscillator. // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // The Timer1 peripheral must be enabled for use. // SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); //SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2); // // For this example CCP1 is used with port B pin 5. // The actual port and pins used may be different on your part, consult // the data sheet for more information. // GPIO port B needs to be enabled so these pins can be used. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // // Configure the GPIO pin muxing for the Timer/CCP function. // This is only necessary if your part supports GPIO pin function muxing. // Study the data sheet to see which functions are allocated per pin. // GPIOPinConfigure(GPIO_PB5_T1CCP1); GPIOPinConfigure(GPIO_PB4_T1CCP0); // // Set up the serial console to use for displaying messages. This is // just for this example program and is not needed for Timer/PWM operation. // GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_5); GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_4); // // Configure Timer1B as a 16-bit periodic timer. // TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_B_PWM); TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_CAP_COUNT); // // Set the Timer1B load value to 50000. For this example a 66% duty // cycle PWM signal will be generated. From the load value (i.e. 50000) // down to match value (set below) the signal will be high. From the // match value to 0 the timer will be low. // TimerLoadSet(TIMER1_BASE, TIMER_B, 40000); TimerControlEvent(TIMER1_BASE,TIMER_A,TIMER_EVENT_NEG_EDGE); TimerControlStall(TIMER1_BASE,TIMER_A,true); TimerLoadSet(TIMER1_BASE, TIMER_A, 6003); // Set the Timer1B match value to load value / 3. // TimerMatchSet(TIMER1_BASE, TIMER_B, TimerLoadGet(TIMER1_BASE, TIMER_B) / 2); TimerMatchSet(TIMER1_BASE, TIMER_A, 1); // // Enable Timer1B. // TimerEnable(TIMER1_BASE, TIMER_B); TimerIntEnable(TIMER1_BASE, TIMER_CAPA_EVENT); IntEnable(INT_TIMER1A); TimerEnable(TIMER1_BASE, TIMER_A); IntPrioritySet(INT_TIMER1A,0x20); // // Loop forever while the Timer1B PWM runs. // IntMasterEnable(); while(1) [ ; ] ] void Timer1AIntHandler(void) [ TimerIntClear(TIMER2_BASE, TIMER_B); i++; if(i==10000) [ i=0; ] ] |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
608 浏览 0 评论
1660 浏览 0 评论
2102 浏览 0 评论
为啥BQ7693003DBTR芯片在和BQ769X0盒子通讯时收不到信号?
1550 浏览 0 评论
DSP 28027F 开发板 XDS100v2调试探针诊断日志显示了 Error -150 (SC_ERR_FTDI_FAIL)如何解决
1398 浏览 0 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
1801浏览 29评论
2828浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
1753浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
1671浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
1686浏览 13评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-18 13:55 , Processed in 1.091281 second(s), Total 67, Slave 52 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2583