wateras1 发表于 2017-4-10 13:47
是的,你这块不是用一个GPIO控制的吗
配置了一个GPIO控制,输出的量还是00。
#include
#include
#include
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "inc/hw_types.h"
#include "driverlib/fpu.h"
#include "driverlib/debug.h"
#include "driverlib/pwm.h"
#include "inc/hw_gpio.h"
#define UARTConfigSet(a, b, c) UARTConfigSetExpClk(a, 16000000, b, c)
#define GPIO_PA5_U3TX 0x00001401
#define GPIO_PA4_U3RX 0x00001001
#define GPIO_PA6_U2RX 0x00001801
#define GPIO_PA7_U2TX 0x00001C01
void
UARTSend(uint32_t ui32UARTBase, const uint8_t *pui8Buffer, uint32_t ui32Count);
//void uartPuts();
int main(void)
{
uint8_t ui8DataTx[4];
uint8_t ui8DataRx[4];
uint32_t ui32index;
uint32_t ui32SysClock;
ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);///PC7£¬485¿úμÄêÕ·¢¿ØÖÆ
GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_7);
GPIOPinWrite(GPIO_PORTC_BASE,GPIO_PIN_7,0xff);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);//ê1ÄüGPIOA¿ú
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
GPIOPinConfigure(GPIO_PA4_U3RX);
GPIOPinConfigure(GPIO_PA5_U3TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_4 | GPIO_PIN_5);
UARTConfigSet(UART3_BASE, 115200, (UART_CONFIG_WLEN_8 |
UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
//UARTLoopbackEnable(UART3_BASE);
ui8DataTx[0] = 'u';
ui8DataTx[1] = 'a';
ui8DataTx[2] = 'r';
ui8DataTx[3] = 't';
/*
// UARTSend(UART3_BASE, (uint8_t *)"\n\n\rSending : ",
// strlen("\n\n\rSending : "));
//UARTSend(UART3_BASE, (uint8_t*)ui8DataTx, 4);
for(ui32index = 0 ; ui32index < 4 ; ui32index++)
{
UARTCharPut(UART3_BASE, ui8DataTx[ui32index]);
}
//
// Wait for the UART module to complete transmitting.
//
while(MAP_UARTBusy(UART3_BASE))
{
}
// UARTSend(UART3_BASE, (uint8_t *)"\n\rReceiving : ",
// strlen("\n\rReceiving : "));
//
// Read data from the UART's receive FIFO and store it.
//
for(ui32index = 0 ; ui32index < 4 ; ui32index++)
{
//
// Get the data received by the UART at its receive FIFO
//
ui8DataRx[ui32index] = UARTCharGet(UART3_BASE);
}
*/
UARTSend(UART3_BASE, (uint8_t*)ui8DataRx, 4);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);//ê1ÄüGPIOH¿ú
GPIODirModeSet(GPIO_PORTH_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,GPIO_DIR_MODE_OUT);
GPIOPadConfigSet(GPIO_PORTH_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,GPIO_STRENGTH_8MA_SC,GPIO_PIN_TYPE_STD);
while(1)
{
UARTSend(UART3_BASE, (uint8_t *)"\nUART Loopback Example ->",
strlen("\nUART Loopback Example ->"));
//UARTCharPut(UART3_BASE,ui8DataTx);
//uartPuts("HELLO EEWORLD:\r\n"); // Çëêäèëò»¸öÃüá°′»Ø3μÖ′DD
GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x00);///½óêÕμ½êy¾Y£¬ááμÆ
SysCtlDelay(500 * (ui32SysClock/ 3000));///Ñóê±3ìDò
GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0xff);///½óêÕμ½êy¾Y£¬ááμÆ
SysCtlDelay(500 * (ui32SysClock/ 3000));///Ñóê±3ìDò
/* c=UARTCharGet(UART3_BASE);
if(c=='1')
{
GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_3,0x07);///½óêÕμ½êy¾Y£¬ááμÆ
SysCtlDelay(1000 * (ui32SysClock/ 3000));///Ñóê±3ìDò
}
if(c=='0')
{
GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_3,0xff);///½óêÕμ½êy¾Y£¬ááμÆ
SysCtlDelay(1000 * (ui32SysClock/ 3000));///Ñóê±3ìDò
}
SerialRxData[SerialDataCount]=UARTCharGet(UART3_BASE);///2»½óêÕμ½êy¾Y£¬μè′y
if(SerialRxData[SerialDataCount])
{
GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_3,0x07);///½óêÕμ½êy¾Y£¬ááμÆ
SysCtlDelay(1000 * (ui32SysClock/ 3000));///Ñóê±3ìDò
}
*/
}
}
void
UARTSend(uint32_t ui32UARTBase, const uint8_t *pui8Buffer, uint32_t ui32Count)
{
//
// Loop while there are more characters to send.
//
while(ui32Count--)
{
//
// Write the next character to the UART.
//
MAP_UARTCharPut(ui32UARTBase, *pui8Buffer++);
}
}
// í¨1yUART·¢Ëíò»¸ö×Ö·û
void uartPutc(const char c)
{
UARTCharPut(UART3_BASE, c);
}
// í¨1yUART·¢Ëí×Ö·û′®
void uartPuts(const char *s)
{
while (*s != '\0')
{
//UARTCharPut(UART3_BASE, *(s++));
uartPutc(*(s++));
}
}