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.

TM4C123GXL 使能输出GPIOB 4端口无输出

Other Parts Discussed in Thread: TM4C123GH6PM

单片机 TM4C123GXL,芯片GH6PM

CCS 版本6.0.1

程序设置两个定时器中断使能PB6和PB4,PB6输出正常,但PB4无输出,示波器观察PB4峰值只有40mv,当我把程序里的PB4换成其他口,输出就正常了。是PB4

端口已经坏了还是其他的问题?附程序如下:

#include <stdint.h>
#include <stdbool.h>
#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++;
}