cancel
Showing results for 
Search instead for 
Did you mean: 

Usart receive problem

cyril2399
Associate II
Posted on July 22, 2011 at 15:10

Hello,

I try to write what I receive into a .txt.

First I do this:

RCC_Configuration();

GPIO_Configuration();

 

  USART_InitStructure.USART_BaudRate = 115200;

  USART_InitStructure.USART_WordLength = USART_WordLength_8b;

  USART_InitStructure.USART_StopBits = USART_StopBits_1;

  USART_InitStructure.USART_Parity = USART_Parity_No ;

  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

  USART_Init(USARTy, &USART_InitStructure);

  USART_Cmd(USARTy, ENABLE);

  USART_SetPrescaler(USARTy, 0x1);

  USART_IrDAConfig(USARTy, USART_IrDAMode_Normal);

  USART_IrDACmd(USARTy, ENABLE);

I think this is the good configuration (well sure...)

then I send the command like this:  USART_SendData(USART2, 'a');

then I have tried to do:

int size= 128;

for (i=0;i<size;i++)

  {

   buf[i]= USART_ReceiveData(USART2);

   fprintf(t1,''%c'',buf);

  }

and I tried to use the USART_Scanf(128);

but none of them runs. I don't know how to write into t1, all the text I receive.

thanks to any help...
20 REPLIES 20
cyril2399
Associate II
Posted on August 02, 2011 at 11:48

Ok thanks, I succeed.

But not with the flag TC...

I have used a kind of timer for stop the wait if nothing arrive.

After this time I leave the loop and thanks to this it runs.

Thanks for your help