2015-03-03 01:18 AM
Hello everybody,
I have to send a file from the computer (so from HyperTerminal) to the STM3240G eval via USART3 (or any UART). I wrote a program to receive one data from USART (getchar() ) and it works fine but I don't understand how I can receive more than one data ... I think I have to play with the flag RXNE with a reset after each reception but i'm not sure. My getchar() program :char USART_getc(USART_TypeDef* USARTx){
while(!(USARTx->SR & USART_FLAG_RXNE));
return ((int)USARTx->DR & 0xFF);
} My program to receive a text file from HyperTerminalvoid reception_donnee(USART_TypeDef* USARTx,tablo tableau)
{
uint8_t i;
char T='\0';
while(!USART_GetFlagStatus(USART3,USART_FLAG_RXNE) && (T !='\n') && i<SIZE_BUFFER)
{
T= USART3->DR;
tableau[i]= T;
i++;
}
} For information the SIZE_BUFFER is a constant for tablo. Here tablo[600] tableau. I hope you understand my problem. If not, I can answer to your questions. Sorry for my english mistakes, I'm French :) Thanks in advance. #usart-stm3240x-hyperterminal
2015-03-03 04:00 AM
void reception_donnee(USART_TypeDef* USARTx,tablo tableau)
{
uint8_t i;
char T='\0';
while((T !='
') && (i < (SIZE_BUFFER-1)))
{
while(!USART_GetFlagStatus(USART3,USART_FLAG_RXNE)); // Wait for each
T= USART3->DR;
tableau[i]= T;
i++;
}
tableau[i]= 0; // NUL terminate string, if you expect to use strxxx() functions
}
2015-03-03 05:45 AM
Fantastic !!! It works fine now !!
Thank you for your fast reply clive1 !