1

I am trying to get data from computer mouse with USB to TTL converter but I read nothing in rfBuff1. I check the USB to TTL whether it works or not. I connected it to computer and stm32f4, and used HTerm to send some data, it worked. Seems the problem is not the converter.

Variables

#define RX_BUFFERSIZE 2000
char rxBuff1[RX_BUFFERSIZE];
USART_InitTypeDef USART_InitStructure;

USART Configs

void USART_Configuration(void){

    USART_InitStructure.USART_BaudRate = 9600;
    USART_InitStructure.USART_WordLength = USART_WordLength_8b;
    USART_InitStructure.USART_StopBits = USART_StopBits_1;
    USART_InitStructure.USART_Parity = USART_Parity_No;
    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

    USART_Init(USART1, &USART_InitStructure); // USART configuration
    USART_Cmd(USART1, ENABLE);
    USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
}

This is the Interrupt Part

void USART1_IRQHandler(void) {
    
    rxBuff1[i++] = USART_ReceiveData(USART1);
    
    if (i == RX_BUFFERSIZE ){i = 0;}
    
    USART_ClearITPendingBit(USART1, USART_IT_RXNE);
}

This is my main code :

int main(void)
{
    
  RCC_Configuration();
 
  GPIO_Configuration();
    
  USART_Configuration();
 
  NVIC_Configuration();
    

  while(1);
    
}
Omer Sahin
  • 21
  • 3
  • It's not clear to me what you're trying to do. Are you connecting a USB mouse directly to a USB-to-UART converter (like FTDI), and expecting that to send serial data? – Thomas Jager Jun 30 '20 at 14:00
  • you cant connect mouse to USB-Serial converter. Mouse is not a serial device only HID. It will never work – 0___________ Jun 30 '20 at 14:08
  • I want to get data from mouse with UART or USART. I just used USB2TTL converter to get this data but didn't work. – Omer Sahin Jun 30 '20 at 20:48

0 Answers0