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);
}