Receive text file from HyperTerminal via UART
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-03-03 1:18 AM
Posted on March 03, 2015 at 10:18
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
Labels:
- Labels:
-
UART-USART
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-03-03 4:00 AM
Posted on March 03, 2015 at 13:00
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
}
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-03-03 5:45 AM
Posted on March 03, 2015 at 14:45
Fantastic !!! It works fine now !!
Thank you for your fast reply clive1 !