logo

串口后32没有反应,32的串口已经初始化了没问题了,openMV代码怎么写呢?

2019-03-01 23:17
N
vba1
int main(void)
 {  
	  
	 u8 t;
	 u8 len;
   u16 times=0;
	 delay_init();    
	 LED_init();
	 uart_init(115200); 
	 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);

	 
	 while(1)
	 {
	  USART_SendData(USART1,4);
		while(USART_GetFlagStatus(USART1,USART_FLAG_TC)!=SET);
   	
		 
		if(USART_RX_STA&0x8000) 
		{ 
			USART_RX_STA=0;
      GPIO_SetBits(GPIOE,GPIO_Pin_5);
      GPIO_SetBits(GPIOB,GPIO_Pin_5);			
		}

    else
    {
		  GPIO_SetBits(GPIOE,GPIO_Pin_5);
		  GPIO_ResetBits(GPIOB,GPIO_Pin_5);  
			 times++; 
			if(times%10==0)
      {   
			GPIO_SetBits(GPIOB,GPIO_Pin_5);
			GPIO_ResetBits(GPIOE,GPIO_Pin_5);
			} 
      delay_ms(100);   			
		}			
	 
	 
	 
	 }
 }

上面的是32的代码。

下面的是OPENMV,连接了之后32没有反应

# UART Control
#
# This example shows how to use the serial port on your OpenMV Cam. Attach pin
# P4 to the serial input of a serial LCD screen to see "Hello World!" printed
# on the serial LCD display.

import time
from pyb import UART

# Always pass UART 3 for the UART number for your OpenMV Cam.
# The second argument is the UART baud rate. For a more advanced UART control
# example see the BLE-Shield driver.
uart = UART(3, 19200)

while(True):
    uart.write("3")
    time.sleep(1000)
2019-03-02 11:38
V
。。。。

对了,波特率在调试时我改成一样的了,所以和波特率应该没有关系

2019-03-02 18:32
I
网红小智智 星瞳科技

先用串口调试扩展板或者示波器或者ttl转串口电路,查看OpenMV发送的数据。

然后用ttl转串口电路,发送数据给stm32,看一下stm32的反应,确认stm32的代码没有问题。

最后一步才是把OpenMV和stm32接在一起。