Serial over USB driver STM32L0xx

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
marcoferd
Posts: 6
Joined: Fri Jun 30, 2017 5:02 pm

Serial over USB driver STM32L0xx

Post by marcoferd »

Hi,

I'm developing an application based on a board integrating the MCU STM32L052K8 and i need to build a USB to SPI bridge. Are there any example codes using the Serial over USB driver (USB CDC) running on MCU belonging to STM32L0 family?

Thanks in advantage,

Marco Ferdinandi
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Serial over USB driver STM32L0xx

Post by Giovanni »

Hi,

There isn't one but all USB demos are the same, you may start from the F0 demo then change the paths in the makefile to point to L0 components.

Giovanni
marcoferd
Posts: 6
Joined: Fri Jun 30, 2017 5:02 pm

Re: Serial over USB driver STM32L0xx

Post by marcoferd »

Hi,

thanks for the answer. Since I have a NUCLEO-F401RE and there is the F4xx demo for USB-CDC, I'm trying to start from it in order to make the porting for the STM32L0. First of all, I'm trying to test the demo on the Nucleo STM32F401RE after that I've changed the board pointed by the ChibiStudio project, but it seems not working properly. Connecting the USB to my PC nothing happens: the O.S. doesn't detect any USB and/or COM. What problem could I have with my demo? Should I change something else in the project files?

Thanks in advantage,

Marco Ferdinandi
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Serial over USB driver STM32L0xx

Post by Giovanni »

Hi,

F401 has a different USB, it requires more changes. It is better if you start from L0 or F3.

Giovanni
marcoferd
Posts: 6
Joined: Fri Jun 30, 2017 5:02 pm

Re: Serial over USB driver STM32L0xx

Post by marcoferd »

Hi,

I have started from the driver STM32F0xx-USB_CDC but i still have problems. Following I list all the steps:
-I have made the necessary changes in debug configurations;
-I have changed the pointed board (replacing with ST_NUCLEO64_L073RZ );
-I have changed the pointed files in the make file;
-I have overwritten the mcuconf.h file with another one, taken from an RT-STM32L073RZ existing project;
-I have added the following code to the mcuconf.h :

Code: Select all

/*
 * USB driver system settings.
 */
#define STM32_USB_USE_USB1                  TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND      FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY      1
#define STM32_USB_USB1_LP_IRQ_PRIORITY      2


Now I'm receiving the following error:
C:\ChibiStudio\chibios176/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c:135:2: error: #error "TIM21 is not a 32bits timer"

What am I wrong? Is there something that I haven't still done?

Thanks in advantage,

Marco Ferdinandi
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: Serial over USB driver STM32L0xx

Post by RoccoMarco »

Hi Marco,
I think that you have wrongly edited mcuconf.h

Maybe you have made a typo in this line

Code: Select all

#define STM32_ST_USE_TIMER                  2


and most likely you have written

Code: Select all

#define STM32_ST_USE_TIMER                  21
marcoferd
Posts: 6
Joined: Fri Jun 30, 2017 5:02 pm

Re: Serial over USB driver STM32L0xx

Post by marcoferd »

Hi,

I have solved the error by setting the CH_CGF_ST_RESOLUTION to 16 in the chconf.h file (it was set to 32). Now there aren't any errors but when I connect the USB to the PC i receive the windows 43 error code (Windows has stopped this device because it has reported problems. (Code 43)).

How can I fix it?

Thanks in advantage,

Marco Ferdinandi
marcoferd
Posts: 6
Joined: Fri Jun 30, 2017 5:02 pm

Re: Serial over USB driver STM32L0xx

Post by marcoferd »

Hi Rocco,

I had the problem you say. I have set

Code: Select all

STM32_ST_USE_TIMER                  2


but the problem still exist and I need to set the CH_CFG_ST_RESOLUTION from 32 to 16.

Code: Select all

#define CH_CFG_ST_RESOLUTION                16


Finally, I still receive the same error: windows 43 error code (Windows has stopped this device because it has reported problems. (Code 43)). Device Descriptor Request Failed.

Thanks,

Marco
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: Serial over USB driver STM32L0xx

Post by RoccoMarco »

Which demo are you using as starting demo? I was sure we was talking about stm32f401 were tim2 is a 32bit timer.
marcoferd
Posts: 6
Joined: Fri Jun 30, 2017 5:02 pm

Re: Serial over USB driver STM32L0xx

Post by marcoferd »

Hi Rocco,

I was starting from STM32F401RE since I have a physical board, but Giovanni said that its more complicated than starting from F0. For this reason I'm doing the porting of the demo STM32F0xx-USB_CDC for the ST_NUCLEO64_L073RZ.

Thanks,

Marco
Post Reply