完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
单片机 TM4C123GXL,芯片GH6PM
CCS 版本6.0.1 程序设置两个定时器中断使能PB6和PB4,PB6输出正常,但PB4无输出,示波器观察PB4峰值只有40mv,当我把程序里的PB4换成其他口,输出就正常了。是PB4 端口已经坏了还是其他的问题?附程序如下: #include #include #include "inc/tm4c123gh6pm.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/gpio.h" #include "driverlib/timer.h" uint8_t count0=0; uint8_t count1=0; int main(void) [ uint32_t ui32Period0, ui32Period1; SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_4|GPIO_PIN_6|GPIO_PIN_7); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC); ui32Period0 = (SysCtlClockGet() / 220) / 10; ui32Period1 = (SysCtlClockGet() / 260) / 10; TimerLoadSet(TIMER0_BASE, TIMER_A, ui32Period0 -1); TimerLoadSet(TIMER1_BASE, TIMER_A, ui32Period1 -1); IntEnable(INT_TIMER0A); IntEnable(INT_TIMER1A); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT); IntMasterEnable(); TimerEnable(TIMER0_BASE, TIMER_A); TimerEnable(TIMER1_BASE, TIMER_A); while(1) [ ] ] void Timer0IntHandler(void) [ // Clear the timer interrupt TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); if(count0 == 20) [ count0 = 0; ] // Read the current state of the GPIO pin and // write back the opposite state if((count0 == 0)||(count0 == 10)||(count0 == 11)||(count0 == 12)||(count0 == 13)||(count0 == 14)) [ GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_6, 64); ] else [ GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_6, 0); ] count0++; ] void Timer1IntHandler(void) [ // Clear the timer interrupt TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT); if(count1 == 20) [ count1 = 0; ] // Read the current state of the GPIO pin and // write back the opposite state if((count1 == 0)||(count1 == 1)||(count1 == 2)||(count1 == 3)||(count1 == 4)||(count1 == 10)) [ GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, 16); ] else [ GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, 0); ] count1++; ] |
|
相关推荐
14 个讨论
|
|
|
这个是我写的一个测试程序,经验证是PB4可以正常翻转。
可以到你的板子上测试一下。如果无法输出可能是硬件的问题. int main(void) [ // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // ROM_FPULazyStackingEnable(); // // Set the clocking to run directly from the crystal. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); // // Enable the peripherals used by this application. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlDelay(10);//模块时钟使能需要等待6个cycle以上 ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_4); ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4,GPIO_PIN_4); // while(1) [ ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_PIN_4); SysCtlDelay(5000); ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, 0); SysCtlDelay(5000); ] ] |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
550 浏览 0 评论
1613 浏览 0 评论
2047 浏览 0 评论
为啥BQ7693003DBTR芯片在和BQ769X0盒子通讯时收不到信号?
1514 浏览 0 评论
DSP 28027F 开发板 XDS100v2调试探针诊断日志显示了 Error -150 (SC_ERR_FTDI_FAIL)如何解决
1338 浏览 0 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
1759浏览 29评论
2786浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
1726浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
1636浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
1647浏览 13评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 21:12 , Processed in 1.199624 second(s), Total 91, Slave 75 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
3296