我想用openmv和ti的板子tm4c123做串行通讯嘛,然后openmv和tm4c各自收发在电脑上的串口助手都能显示出来,但是把openmv的tx端接到tm4c的rx端,然后tm4c的tx端接到电脑,openmv发出的数据在电脑上显示不出来。
#openmv上运行的代码
from pyb import UART
import time
uart = UART(3, 115200)
while(True):
uart.write('1')
time.sleep_ms(1000)
#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/uart.h"
#include "driverlib/systick.h"
#include "driverlib/pin_map.h"
#include "uartstdio.h"
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
//使能外设
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
//配置复用功能
GPIOPinConfigure(GPIO_PB0_U1RX);
GPIOPinConfigure(GPIO_PB1_U1TX);
//分配UART信号
GPIOPinTypeUART(GPIO_PORTB_BASE,GPIO_PIN_0|GPIO_PIN_1);
//配置UART参数(这样配置可以用UARTprintf)
UARTClockSourceSet(UART1_BASE, UART_CLOCK_PIOSC); //使用16MHz内部高精度振荡器(PIOSC)作为UART模块时钟
UARTStdioConfig(1,115200, 16000000); //UART编号、波特率、UART时钟频率(频率要和上一行设的一致)
UARTprintf("Enter Text: \n");
//UARTCharPut(UART1_BASE,'0');
uint8_t getChar;
while (1)
{
UARTCharPut(UART1_BASE,'0');
getChar=UARTCharGet(UART1_BASE);//接收指定字符并赋值给getChar
UARTCharPut(UART1_BASE,getChar);
if(getChar=='1')
{
UARTprintf("Yes");
}
else
{
UARTprintf("No");
}
}
}
如果用openmv的tx单独连接电脑,串duan口助手有显示,tm4c单独连接电脑同样有显示,但是将openmv的P4端连接tm4c的PB0端。PB1端接ttl转串口通讯接电脑,串口通讯助手上面没有显示。