cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f4 USART

puneethj
Associate II
Posted on November 10, 2015 at 18:32

Hello Every one! Can any 1 please help me with USART data transfer..

The problem is i want to transfer 16 bit value which is saved in global variable to computer from USART. i am trying this

void usart_send()
{
USART_puts(''S1'');
USART_puts(sensor1val);
}
void USART_puts(volatile char *s){

 while(*s){
 // wait until data register is empty
 while( !(USART3->SR & 0x00000040) );
 USART_SendData(USART3, *s);
 *s++;
 }

Note S1 is received successfully but i need help on how to transfer the value in sensor1val. Thanks for trying to slove my problem :) #usart #stm32 #stm32f4
2 REPLIES 2
Posted on November 10, 2015 at 19:00

void usart_send()
{
char buf[16];
sprintf(buf, ''S1 %d
'', sensor1val); 
USART_puts(buf);
}
void USART_puts(volatile char *s)
{
while(*s)
{
// wait until data register is empty
while( !(USART3->SR & 0x00000040) );
USART_SendData(USART3, *s++);
}
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
puneethj
Associate II
Posted on November 10, 2015 at 19:03

Thanks a lot Clive this was helpful and gave me much knowledge about usart send function, i wrote this and it works cool

USART_puts(''S1'');

while( !(USART3->SR & 0x00000040) );

USART_SendData(USART3,(sensor1val >> 8));

while( !(USART3->SR & 0x00000040) );

USART_SendData(USART3,sensor1val);