STM32F4 USB CDC Communication transfers only specific characters without noise?

I'm working with STM32F407VET6 board. And I'm trying to make communication between my PC and Micro Controller via sample which transmits what it receives through USB. I've created sample USB Device example via STM32CubeMX Version 4.16.0 and FW_F4 1.13.0.

My problem is very fantastic and I don't know how to google it. I'm using;

uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)  

and

int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)  

functions.

I'm listening outputs from /dev/ttyACM0 via CuteCom. Also, sending commands through it. If I put some string to buffer, it doesn't send without noise. But it sends this caharacters correctly(!):

DEC   OCT    HEX    BINARY   CHARACTER   DESCRIPTION ------------------------------------------------------- 63    077    3F    00111111      ?       Question Mark 71    107    47    01000111      G       Uppercase G 75    113    4B    01001011      K       Uppercase K 83    123    53    01010011      S       Uppercase S 99    143    63    01100011      c       Lowercase c 111   157    6F    01101111      o       Lowercase o 119   167    77    01110111      w       Lowercase w 

Also I read this characters on buffer if the string which I sent via CuteCom ends with one of them. If I only listen port, doesn't send anything, first string is changing and turns to tilde(~) character after several transmits. Here, I'm starting application, waiting, and sending string in order of: "w", "c", "asdfw", "a", "b", "c", "G" :

USB_Tx_buf: STRING_OF_TRANSMIT_BUFFER USB_Rx_buf: STRING_OF_RECEIVE_BUFFER ----------------------------------- USB_Tx_buf: E�L USB_Rx_buf: 1�k ----------------------------------- USB_Tx_buf: [email protected]� USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf: A�� USB_Rx_buf: [email protected] ----------------------------------- USB_Tx_buf:  Ag USB_Rx_buf: E�L ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf: A�� ----------------------------------- USB_Tx_buf: E�L USB_Rx_buf: 1�k ----------------------------------- USB_Tx_buf: [email protected]� USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf:  �z USB_Rx_buf:  �z ----------------------------------- USB_Tx_buf: ~ USB_Rx_buf: ~ ----------------------------------- USB_Tx_buf: ~ USB_Rx_buf: ~ ----------------------------------- USB_Tx_buf: ~ USB_Rx_buf: ~ ----------------------------------- USB_Tx_buf: ~ USB_Rx_buf: ~ ----------------------------------- USB_Tx_buf: ~ USB_Rx_buf: ~ ----------------------------------- USB_Tx_buf: ~ USB_Rx_buf: ~ ----------------------------------- USB_Tx_buf: ~ USB_Rx_buf: ~ ----------------------------------- USB_Tx_buf: ~ USB_Rx_buf: ~ ----------------------------------- USB_Tx_buf: ~ USB_Rx_buf: ~ ----------------------------------- USB_Tx_buf: ~ USB_Rx_buf: ~ ----------------------------------- USB_Tx_buf: ~ USB_Rx_buf: w ----------------------------------- USB_Tx_buf: w USB_Rx_buf: w ----------------------------------- USB_Tx_buf: w USB_Rx_buf: w ----------------------------------- USB_Tx_buf: c USB_Rx_buf: c ----------------------------------- USB_Tx_buf: c USB_Rx_buf: c ----------------------------------- USB_Tx_buf: c USB_Rx_buf: c ----------------------------------- USB_Tx_buf: w USB_Rx_buf: w ----------------------------------- USB_Tx_buf: w USB_Rx_buf: w ----------------------------------- USB_Tx_buf: w USB_Rx_buf: w ----------------------------------- USB_Tx_buf: w USB_Rx_buf: w ----------------------------------- USB_Tx_buf: w USB_Rx_buf: a�Wc~���CEIVE_BUFFER ----------------------------------- USB_Tx_buf: a�Wc~���CEIVE_BUFFER USB_Rx_buf: a�Wc~���CEIVE_BUFFER ----------------------------------- USB_Tx_buf: a�Wc~���CEIVE_BUFFER USB_Rx_buf: a�Wc~���CEIVE_BUFFER ----------------------------------- USB_Tx_buf: b�Vc~���CEIVE_BUFFER USB_Rx_buf: b�Vc~���CEIVE_BUFFER ----------------------------------- USB_Tx_buf: b�Vc~���CEIVE_BUFFER USB_Rx_buf: b�Vc~���CEIVE_BUFFER ----------------------------------- USB_Tx_buf: b�Vc~���CEIVE_BUFFER USB_Rx_buf: b�Vc~���CEIVE_BUFFER ----------------------------------- USB_Tx_buf: b�Vc~���CEIVE_BUFFER USB_Rx_buf: c ----------------------------------- USB_Tx_buf: c USB_Rx_buf: c ----------------------------------- USB_Tx_buf: c USB_Rx_buf: c ----------------------------------- USB_Tx_buf: c USB_Rx_buf: c ----------------------------------- USB_Tx_buf: c USB_Rx_buf: c ----------------------------------- USB_Tx_buf: c USB_Rx_buf: c ----------------------------------- USB_Tx_buf: G USB_Rx_buf: G ----------------------------------- USB_Tx_buf: G USB_Rx_buf: G ----------------------------------- USB_Tx_buf: G USB_Rx_buf: G ----------------------------------- USB_Tx_buf: G USB_Rx_buf: G ----------------------------------- USB_Tx_buf: G USB_Rx_buf: G ----------------------------------- USB_Tx_buf: G USB_Rx_buf: G ----------------------------------- USB_Tx_buf: G USB_Rx_buf: G ----------------------------------- USB_Tx_buf: G USB_Rx_buf: G ----------------------------------- USB_Tx_buf: G USB_Rx_buf: G ... 

And here is communication part of code:

/* init code for USB_DEVICE */ MX_USB_DEVICE_Init();  /* USER CODE BEGIN startUSBTask */ uint8_t USB_Tx_buf[MAX_COMMAND_STR_SIZE]; uint8_t USB_Rx_buf[MAX_COMMAND_STR_SIZE]; sprintf ( (char*)USB_Tx_buf, "STRING_OF_TRANSMIT_BUFFER" ); sprintf ( (char*)USB_Rx_buf, "STRING_OF_RECEIVE_BUFFER" ); uint32_t dummylength = MAX_COMMAND_STR_SIZE; printf ( "USB_Tx_buf: %s\nUSB_Rx_buf: %s\n", ( char * ) USB_Tx_buf, ( char * ) USB_Rx_buf );  /* Infinite loop */ for ( ;; ) {     CDC_Receive_FS ( USB_Rx_buf, &dummylength );     HAL_Delay ( 10 );     if ( strcmp ( (char*)USB_Tx_buf, (char*)USB_Rx_buf ) != 0 )     {         sprintf ( (char*)USB_Tx_buf, (char*)USB_Rx_buf );     }     CDC_Transmit_FS ( USB_Tx_buf, (uint16_t) strlen ( (char*)USB_Tx_buf ) );     osDelay ( 10 );     printf ( "USB_Tx_buf: %s\nUSB_Rx_buf: %s\n-----------------------------------\n", ( char * ) USB_Tx_buf, ( char * ) USB_Rx_buf ); } /* USER CODE END startUSBTask */ 

Where should I look for solution? Or How can i search it on Google?

Replay

Category: usb device Time: 2016-07-29 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.257 (s). 12 q(s)