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

程序跑飞的问题

我用的TM4C123GH6PM,Tiva C LanunchPad。

写程序,可是一运行到下面这句,

SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);

程序就跑飞了。

这是怎么回事呢?

我查了一下,串口1 U1Rx这个脚还有模拟功能USB0ID,U1Tx这个脚还有USB0VBUS的功能。

是不是这个复用了?谢谢!

ccb bcc:

高手支招啊!

xyz549040622:

应该是这个IO复位的时候默认为模拟功能了,你重新配置下IO功能试试。

ccb bcc:

回复 xyz549040622:

谢谢!应该怎么配置呢?我不会,还请明示。

xyz549040622:

回复 ccb bcc:

不对呀,不是这个语句的问题,我同样用的是Tiva C LanunchPad,开头使用了这个语句,没有跑飞的现象

//*****************************************************************************
//
// hello.c - Simple hello world example.
//
// Copyright (c) 2012-2014 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 2.1.0.12573 of the EK-TM4C123GXL Firmware Package.
//
//*****************************************************************************#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
//#include "utils/uartstdio.h"//*****************************************************************************
//
//! \addtogroup example_list
//! <h1>Hello World (hello)</h1>
//!
//! A very simple ``hello world'' example.It simply displays ``Hello World!''
//! on the UART and is a starting point for more complicated applications.
//!
//! UART0, connected to the Virtual Serial Port and running at
//! 115,200, 8-N-1, is used to display messages from this application.
//
//*****************************************************************************//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif////*****************************************************************************
////
//// Configure the UART and its pins.This must be called before UARTprintf().
////
////*****************************************************************************
//void
//ConfigureUART(void)
//{
////
//// Enable the GPIO Peripheral used by the UART.
////
//ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);////
//// Enable UART0
////
//ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);////
//// Configure GPIO Pins for UART mode.
////
//ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
//ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
//ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);////
//// Use the internal 16MHz oscillator as the UART clock source.
////
//UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);////
//// Initialize the UART for console I/O.
////
//UARTStdioConfig(0, 115200, 16000000);
//}//*****************************************************************************
//
// Print "Hello World!" to the UART on the evaluation board.
//
//*****************************************************************************
int
main(void)
{//volatile uint32_t ui32Loop;//// 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 GPIO port that is used for the on-board LED.//SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);//// Enable the GPIO pins for the LED (PF2 & PF3).//ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);//// Initialize the UART.//
//ConfigureUART();////
//// Hello!
////
//UARTprintf("Hello, world!\n");//// We are finished.Hang around doing nothing.//while(1){//// Turn on the BLUE LED.//GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);//// Delay for a bit.//SysCtlDelay(SysCtlClockGet() / 10 / 3);//// Turn off the BLUE LED.//GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);//// Delay for a bit.//SysCtlDelay(SysCtlClockGet() / 10 / 3);}
}

ccb bcc:

回复 xyz549040622:

那就奇怪了。

ccb bcc:

回复 xyz549040622:

这是我的工程,你帮我测试一下。谢谢!

ccb bcc:

回复 xyz549040622:

你这个程序,我测试了一下,确实可以。

ccb bcc:

回复 xyz549040622:

谢谢!照你说的改了,这句没有这个问题了,其他地方还有问题。很奇怪,莫名其妙的跑飞。

唉,不搞了。

xyz549040622:

回复 ccb bcc:

一点也不奇怪,继续搞吧。你需要先测试每部分的模块,然后合在一起。记住初始化需要放在最前面。

赞(0)
未经允许不得转载:TI中文支持网 » 程序跑飞的问题
分享到: 更多 (0)