2014-10-23 09:27 AM
Hello everybody
I am trying to make VCP work on STM32F072 discovery board. I have written a program to send data from device to PC with the help of ST example code and this discussion:/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/STM32F072%20DISCO%20USB%20cdc%20device%20sending%20data%20to%20PC&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=464
Device is showing up as a COM port when i plug it, but i am not getting any data on a terminal. I dont know what i am doing wrong, maybe someone could give me a clue. Thanks in advance. This is my main.c/* Includes ------------------------------------------------------------------*/
#include ''usbd_cdc_core.h''
#include ''usbd_usr.h''
#include ''usbd_cdc_vcp.h''
USB_CORE_HANDLE USB_Device_dev ;
/* Private function prototypes -----------------------------------------------*/
LINE_CODING linecodingg =
{
115200,
/* baud rate*/
0x00,
/* stop bits-1*/
0x00,
/* parity - none*/
0x08
/* nb. of bits 8*/
};
USART_InitTypeDef USART_InitStructure1;
extern
uint8_t APP_Rx_Buffer [];
/* Write CDC received data in this buffer.
These data will be sent over USB IN endpoint
in the CDC core functions. */
extern
uint32_t APP_Rx_ptr_in;
/* Increment this pointer or roll it back to
start address when writing received data
in the buffer APP_Rx_Buffer. */
extern
uint16_t VCP_DataTx1 (uint8_t* Buf, uint32_t Len);
extern
uint16_t VCP_Init (
void
);
extern
uint16_t VCP_DeInit (
void
);
extern
uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len);
extern
uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len);
CDC_IF_Prop_TypeDef VCP_fops =
{
VCP_Init,
VCP_DeInit,
VCP_Ctrl,
VCP_DataTx1,
VCP_DataRx
};
/* Private functions ---------------------------------------------------------*/
extern
uint16_t VCP_DataTx1 (uint8_t* Buf, uint32_t Len)
{
uint32_t i=0;
GPIO_SetBits(GPIOC, GPIO_Pin_9);
GPIO_SetBits(GPIOC, GPIO_Pin_7);
GPIO_SetBits(GPIOC, GPIO_Pin_8);
GPIO_SetBits(GPIOC, GPIO_Pin_6);
while
(i < Len)
{
APP_Rx_Buffer[APP_Rx_ptr_in] = *(Buf + i);
APP_Rx_ptr_in++;
i++;
/* To avoid buffer overflow */
if
(APP_Rx_ptr_in == APP_RX_DATA_SIZE)
{
APP_Rx_ptr_in = 0;
}
}
return
USBD_OK;
}
int
main(
void
)
{
uint8_t work[4] = {0x57,0x6f,0x52,0x6b};
UserToPMABufferCopy(work, INT_IN_TX_ADDRESS, 4);
SetEPTxCount(ENDP1, 4);
SetEPTxValid(ENDP1);
USBD_Init(&USB_Device_dev,
&USR_desc,
&USBD_CDC_cb,
&USR_cb);
while
(1)
{
VCP_DataTx1 (work, 4);
}
}
#stm32f072-usb-cdc-vcp-datatx
2014-10-23 10:01 AM
Hi
TryVCP_DataTx1 (&work[0], 4);
2014-10-24 02:48 AM
Hi
It still doesn't work2014-10-24 03:52 AM
''It still doesn't work''
Yeah, thought it was an easy fix but I realised on my drive home, probably no good. I cannot see anything else that looks wrong. I think you are going to have to debug it.2014-10-24 06:20 AM
One thought crossed my mind : the while(1) loop is probably going around so fast that it
a) fill the APP_Rx_Buffer buffer b) the loop goes round so fast that it does not allow anything else to happen, though I do not understand why the ISR is not working for you. As I said, I think you are going to have to debug it.