2017-03-22 12:50 AM
Hi, I'm using Nucleo F207ZG board and i did my testing of GPIO using STM32CubeMx(HAL lib) with Eclipse IDE on Ubuntu 04, Now i want to use the USB as Communication Device Class (CDC) but i'm not familiar with usb so is there any example coding for tranfer the data from/to Nucleo board/PC
Note: this post was migrated and contained many threaded conversations, some content may be missing.2017-05-22 05:29 AM
Hi Pranay Dhuri,
Can you tell me the procedure which you followed ,
I did STM32F207ZG USB Communication with STM32cube and eclipse IDE . So if you share your procedure then it is easy to solve your problem.
-With Thanks & Regards
K.Manikandan
2017-05-22 05:35 AM
Refer the Youtube Video :
https://www.youtube.com/watch?v=ttqRsBJQu4E
andhttps://www.youtube.com/watch?v=Jpul3w10tOU
Thanks
2017-05-22 05:58 AM
Hi, I am using STM32CubeMX for generating code and using SW4STM32 IDE.
I have configured cubeMX for CDC and generated an initialization code.
In that I have called CDC_Receive_FS(),CDC_Transmit_FS() functions as below.
uint8_t HiMsg[]=''Start\r\n'';
CDC_Transmit_FS(HiMsg,strlen(HiMsg)); HAL_Delay(500);while(1)
{
HAL_GPIO_TogglePin(GPIOB,GPIO_PIN_0);
L1= strlen(myBuffer);
status = CDC_Receive_FS(myBuffer, 5);CDC_Transmit_FS(myBuffer, 7);HAL_Delay(3000);}
then I compiled and flashed but that wasn't working.
2017-05-23 12:24 AM
What is the Heap size and Stack size you have ?
You want to increase the Heap size and Stack size.
2017-05-23 12:55 AM
Yes.I have increased heap and stack sizes..when HCLK is 120 MHz it is not working ,but when I am using HSI for sys and HCLK then it is working
2017-05-23 01:10 AM
It's also working ....
2017-05-23 01:23 AM
I tried the same but NO it isn't working for me...It doesn't pass SystemClock_Config(),Is there any jumper setting I have to do?
2017-05-23 05:25 AM
Hi
Pranay Dhuri
,Can you share your method which is used in CDC_Receive_FS() and CDC_Transmit_FS() method .
-With Thanks & Regards
K.Manikandan
2017-05-23 05:42 AM
It same as that of in the video which you shared..
updated below 2 functions in usbd_cdc_if.c
static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
{ /* USER CODE BEGIN 6 */ receive_data[_index]=Buf[0]; if(++_index==64) { _index=0; } USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); USBD_CDC_ReceivePacket(&hUsbDeviceFS); return (USBD_OK); /* USER CODE END 6 */ }uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len){ uint8_t result = USBD_OK; /* USER CODE BEGIN 7 */ memcpy(UserTxBufferFS,Buf,sizeof(uint8_t)*Len); USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; if (hcdc->TxState != 0){ return USBD_BUSY; } USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); /* USER CODE END 7 */ return result;}and called
CDC_Transmit_FS(mystring,strlen((const char *)mystring));
in main()
2017-05-23 05:52 AM
Ok ,Thank you
Pranay Dhuri .