cancel
Showing results for 
Search instead for 
Did you mean: 

USB CDC by STM32f767zi

mohsen
Associate II
Posted on August 04, 2016 at 18:57

I have Nucleo board with STM32f767zi MCU. I use STM32CubeMX and Atollic TrueStudio for ARM. I want to use CDC to communicate with PC.

First, the code is not working. I changed the stack size to 2000 and heap size to 4000. Also I moved the defenition of CDC_Receive_FS function from .c to .h. Also Ichange the USB frequency to 48Mhz.

now, I can send data to PC. I tried to recieve a data from pc and resend it. I wrote following code:

#include ''stm32f7xx_hal.h''
#include ''usb_device.h''
#include ''usbd_cdc_if.h''
void
SystemClock_Config(
void
);
void
Error_Handler(
void
);
static
void
MX_GPIO_Init(
void
);
int
main(
void
)
{
int8_t status;
uint8_t myBuffer[7]=
''Start!''
;
uint32_t L1;
HAL_Init();
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USB_DEVICE_Init();
uint8_t HiMsg[]=
''Start\r\n''
;
CDC_Transmit_FS(HiMsg,
strlen
(HiMsg));
HAL_Delay(500);
while
(1)
{
L1= 
strlen
(myBuffer);
status = CDC_Receive_FS(myBuffer, 5);
CDC_Transmit_FS(myBuffer, 7);
HAL_Delay(3000);
}
}

when I tyoe '3', '33' , '333' ... in terminal. I see same respoce '╜3¬'. when I type '8', '88', '888' ... I see '╜8AmΩ'

I do not know what is wrong.

#stm32-usb-fs-cdc-vcp #stm32f767zi-nucleo-board
0 REPLIES 0