A good day to all,
does anybody know about an USB low level driver file for the Keil lib on STM32L chips?
Unfortunately Keil supports - up to now - only the F-Types in full and high speed.
The ones I find are:
usbd_STM32F103.c usbd_STM32F10x_cl.c usbd_STM32F2xx_FS.c usbd_STM32F2xx_HS.c usbd_STM32F4xx_FS.c usbd_STM32F4xx_HS.c
thanks in advance, Uli
Hi, here is a port of KEIL RL-USB HID to STM32L-DISCOVERY board.
homepage2.nifty.com/.../STM32L_DISC_KEIL_RL_HID.zip
A couple of notes of porting,
A) Hardware - USB connector STM32L-DISCOVERY doesn't have USB receptacle. A USB B type receptacle is connected as follows. Also, an external 1k5 D+ pull-up resistor is placed across PC12 and D+. As mentioned on above post, the on-chip pull-up is not recommended.
STM32L USB DISCOVERY receptacle PA11 --------------- D- PA12 -----------+--- D+ | PC12 --- 1k5 ---+ GND --------------- GND
B) Hardware - Crystal STM32L-DISCOVERY board has pads for a crystal, but not populated. These components are added. - X3: 8 MHz crystal - C21, C22: 22pF - R30: 220 Ohm
The external crystal is required, because the tolerance of HSI OSC (+/-1%) is not enough for USB operation.
C) Firmware - porting steps 1) Start on MCBSTM32 RL-USB HID example C:\Keil\ARM\Boards\Keil\MCBSTM32\RL\USB\Device\HID
2) Replace "startup" and "system" file with those of STM32L, on Blinky example. (C:\Keil\ARM\Boards\ST\STM32L-Discovery\Blinky) - startup_stm32f10x_md.s --> startup_stm32l1xx_md.s - system_stm32f10x.c --> system_stm32l1xx.c
Fortunately, Blinky "system" file has been already tuned for USB operation (8MHz crystal - HSE OSC and 96MHz PLL), without any change.
3) Modify usbd_STM32F103.c for STM32L differences. USB Interrupt - USBD_IntrEna() Replace USB_LP_CAN1_RX0_IRQn with USB_LP_IRQn - USB_LP_CAN1_RX0_IRQHandler() Rename this function name with USB_LP_IRQHandler()
USB Connection port (PC12) - USBD_Init() Enable GPIO C - USBD_Connect() Switch PC12 between floating input and push-pull output, to emulate high-side open-drain switch.
4) Change port assignment of LEDs and a switch on usbd_user_hid.c - usbd_hid_init() - usbd_hid_get_report() - usbd_hid_set_report()
5) Replace #include of stm32f10x.h with stm32l1xx.h on USBD_Demo.c, usbd_user_hid.c and usbd_STM32F103.c
6) Delete LCD support - LCD_4bit.c - USBD_Demo.c, main()
7) On uVision, Project menu > Options dialog - Device tab: select STM32L152RB - C/C++ tab: enter STM32L1XX_MD on Define box - Debug tab: Use "ST-Link debugger", Setting > Port: JTAG -> SW - Utilities tab: Use "ST-Link debugger", Setting > Programming algorithm: STM32L15x Low Power Flash
I believe I've listed up all of changes, but to make it sure, compare the source files with a "diff" utility ;-)
Enjoy!
Tsuneo
Tsuneo,
for now many thanks. Your assistance is really invaluable. I will check the project shortly and return here with results.
Uli
Has anyone already done it or have any guidence on what I may have to do to take the stm32F2xx HS USB port driver and remove the external Phy from it
Curerntly I am using the ST code and ETFS and thopuhgj I have no problems at the moment with it I would prefer eventually move to just one FS.
thanks in advance
Thanks Tsuneo!
I'm totally a newbie with microcontroller and currently trying to play with the USB function on STM32L-Discovery. I got stuck on how to port the STM USB library to the discovery board for a couple days and found your post a very helpful guide!
I wonder if you used the licensed version of Keil toolchain? I downloaded your code and ran it with Keil, it showed the following error:
.\Test.axf: Error: L9937E: RL-ARM is not allowed with this license
Thanks a lot!
Vicki
Hello!
I'm trying to get my STM32L USB device to communicate with PC. Actually i'm stuck at just building the project files for Tsuneo's example HID project and I've come across a problem already.
.\Flash\HID.axf: Error: L9937E: RL-ARM is not allowed with this license
I have MDK-ARM Standard license. So, does that mean I can't use USB device if I dont have pro license? I don't use RTX (BTW: it is possible to use USBd without RTOS/RTX, right?)
Thanks for answers.
J