2015-11-10 09:32 AM
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 thisvoid 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
2015-11-10 10:00 AM
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++);
}
}
2015-11-10 10:03 AM
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);