cancel
Showing results for 
Search instead for 
Did you mean: 

VCP for STM32F4_Discovery

tony239955
Associate II
Posted on June 22, 2012 at 17:47

I have recently downloaded the latest USB libraries which include a virtual comms port project. However all the examples use the ''Eval'' boards which include an LCD etc. rather than the Discovery board which does not. I am trying to edit the configurations and files in IAR to work with the Discovery board but as a relative beginner at this, it is proving difficult. Is there an ST project for a VCP which will run on the Discovery board?

Tony
14 REPLIES 14
taha_najmee
Associate II
Posted on November 19, 2012 at 01:19

Clive,

Sorry, I didn't really understood what you said. Or maybe I wasn't clear first time.

I checked my UART 4 and 5 independently which gives me the correct frame size on the oscilloscope. But when I added the UART code into the VCP project, it messes up my baud rate. I initialize my UART ports same way and VCP ports are completely different thing. I don't understand how it affects my UART baud rates?

What I am doing in the code is that I am getting characters from hyperterminal and once I get it, it sends that character through UART 4 with baud rate of 600.

________________

Attachments :

app.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzZ2&d=%2Fa%2F0X0000000bNg%2FC8hszLqJYa2ZrYgPHuS5DYJt4.yXKljC_SXDEI4cDXc&asPdf=false

stm32fxxx_it.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzYx&d=%2Fa%2F0X0000000bNf%2F047wBUzCLxMUMvLAteuGxAKIawwICnNvJDd9ld6EzNY&asPdf=false
Posted on November 19, 2012 at 02:33

Or maybe I wasn't clear first time.

The first time you didn't provide any code, so it wasn't clear what you had done. I don't see anything here that would change the baud rate on UART4 or 5 I'm not sure I like the way this is structured

int main(void)
{
__IO uint32_t i = 0;
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb);
RCC_Configuration();
GPIO_Configuration();
UART4_Configuration();
UART5_Configuration();
Enable_Interrupt();
USART_ITConfig(UART4, USART_IT_RXNE, ENABLE);
USART_ITConfig(UART5, USART_IT_RXNE, ENABLE);
// GPIO_WriteBit(GPIOD, GPIO_Pin_5, Bit_RESET);
//
// while(GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_6) == 1);
// while(GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_6) == 0);
while(1)
{
// // while(GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_6) == 1);
// //
// // GPIO_ToggleBits(GPIOD, GPIO_Pin_5);
// //
// // while(GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_6) == 0);
// //
// // GPIO_ToggleBits(GPIOD, GPIO_Pin_5);
// //
Length = VCP_get_char(&Buff[0]);
if(Length)
{
while(USART_GetFlagStatus(UART4, USART_FLAG_TXE) == RESET); // Wait for Empty
USART_SendData(UART4, Buff[0]);
Delay(0xFFFFFF);
}
}
}

Hopefully you don't have any while() loops in your routines called under interrupt. Not sure I see that code. I might attack it more like this :

int main(void)
{
__IO uint32_t i = 0;
RCC_Configuration();
GPIO_Configuration();
UART4_Configuration();
UART5_Configuration();
Enable_Interrupt();
USART_ITConfig(UART4, USART_IT_RXNE, ENABLE);
USART_ITConfig(UART5, USART_IT_RXNE, ENABLE);
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb);
while(1)
{
if (USART_GetFlagStatus(UART4, USART_FLAG_TXE) == SET)
{
Length = VCP_get_char(&Buff[0]);
if(Length)
USART_SendData(UART4, Buff[0]);
}
} // while
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
taha_najmee
Associate II
Posted on November 19, 2012 at 02:58

I have attached my interrupt code with the previous comment as well. Although, I am not using any while loop in the interrupt.

Well, I tried one thing. I commented out the USB_OTG and USB_Device code and checked only the UART output which still gives me the incorrect frame size. So I suppose that VCP doesn't have to do anything with it.

Also I am trying to add your VCP files in my UART project just to see what happens, but the USB device is not recognized when I do that. So I am stuck badly on this problem.

Ok, now I found what was wrong in my UART code. I didn't put the PLL to 8, it was still 25. But when I change it to 8 (thats what it is suppose to be, right?), then I dont get the right frame size. Currently reading the reference manual for for information.

So in conclusion, if PLL is 25, UART works and if PLL is 8, VCP works. Is there any way to make it both work for same PLL or other clock settings?

taha_najmee
Associate II
Posted on November 19, 2012 at 18:32

Clive,

Will 25MHz external oscillator solve the problem? I am really confused about this situation. I dont want to add external components into my project if it is not necessary.
Posted on November 19, 2012 at 19:06

The Crystal, PLL and HSE_VALUE must have coherent settings/values. Correct functioning is predicated on this.

The STM32F4-Discovery has an 8 MHz crystal, the STM32xxx-EVAL boards have 25 MHz. The latter probably related to Ethernet. Neither is magically better than the other, but you can't ignore what the software is coded to expect. Fix whatever issues you have within the project.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..