I am currently working on USART with STM32 and it was working while I'm using usart interrupt. It was filling the rxBuff while I am sending with HTERM via USB but it is not filling while I am trying in the main block. It just takes first character of the transmitted data. For example, I tried to send hello, it just takes "h" into rxBuff and stops. When I try to send it again, this time rxBuff becomes [h,h] which means it only takes the first character.
Working:
void USART1_IRQHandler(void) {
rxBuff[i++] = USART_ReceiveData(USART1);
if (i > RX_BUFFERSIZE ){
i = 0;
}
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
}
Not working :
int main(void){
while(1){
if ( USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == SET ){
rxBuff[i] = USART_ReceiveData(USART1);
i++;
}
if (i > RX_BUFFERSIZE ){
i = 0;
}
}
}