AnsweredAssumed Answered

Usart receive problem

Question asked by jourdan.cyril on Jul 22, 2011
Latest reply on Aug 2, 2011 by jourdan.cyril
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... 

Outcomes