cancel
Showing results for 
Search instead for 
Did you mean: 

HAL or SPL for USB

shingadaddy
Senior
Posted on November 28, 2016 at 18:40

First of all I suspect someone somewhere has an L476 running the USB peripheral using HAL. Maybe?

From the HAL libraries -

I've got several aspects of peripheral running on my Nucleo-L476RG development board.

I/O, Uart, Uart IrDA modes, Encoders. A/D's...etc.. 

So I figured I had a fairly decent handle on the basics of what it took to get things going

MSI comes up first at 4MHZ

Set up clock sources/frequencies until they are how you need them

Enable the clock sources to the buses/peripherals as you need them

Configure the pins how you need them (In/Out/ALTF/ADDF)

Make any peripheral initializations and you are good to go. Usually.

Using TrueStudio 6 and the the HAL 1.6 (Black Friday updated) version of the EVAL\Project\Application\USB_Device\CDC_Standalone pretty much has me fried.

I have a Nucleo board which does NOT have any USB example stuff for it. The EVAL board however DOES have it - code folders/path listed above.

Since

1. The nucleo board only has 1 LED (PA5) and 1 SWITCH (PC13) to worry about,

2. and since the EVAL project mentioned above has no conflict with either of those pins as is

3. and the above mentioned EVAL project doesn't seem to have any pins configured in that project that would cause heartburn to the Nulceo board hardware,

A code portover would seem a near no brainer to get running on a Nucleo using this Eval project.

After all, the CDC project doesn't seem to ENGAGE any I/O that would cause the magic smoke to exit the STM32L476RG and its present wired state on the Nucleo board.

So compile it up -

Drop it on the board

Wire DP to PA12

Wire DM to PA11

Wire GROUND to GROUND

Wire VBus (+5V_usb) from host to PA9 (Code apparently has VBUS SENSE enabled.

They seem to have the ID pin (PA10 for OTG functioality as I understand it) configure. WHY I don't know

in a DEVICE MODE setting.

They have some LED inits that I have commented out.

I'm going to look at it again, around the ''ID'' thing and maybe something that tells it it's a 476 build.

Other than that - I get NOTHING when it gets plugged into a PC usb host hole. (Yes the hole works fine for OTHER stuff)

And I've got NOTHJING after LOTS of tinkering.

I've submitted to ST for help. So far only the AUTO REPLY kind of help

I fear I'm having a forest for the trees thing going on.

AM I off track obviously (Other than the first line maybe s/b ''From the SPL Libraries....  ''
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on December 07, 2016 at 22:43

Hm..... Seems now I can give you points maybe.

@@

   .>

  -

View solution in original post

6 REPLIES 6
joemccarr
Senior
Posted on November 30, 2016 at 01:21

Sorry, as I am not much help as i am not as far along.

Would it be to any advantage to try and get the USB running on the eval board first then port over?

Posted on November 30, 2016 at 09:05

The usual debug steps apply - formulate a hypothesis and prove it, repeat until done. The debugger is your friend, as is the LED and/or a serial port; also an oscilloscope and/or a LA.

> Set up clock sources/frequencies until they are how you need them

This is the easiest part to check. Start here.

JW
shingadaddy
Senior
Posted on November 30, 2016 at 16:29

No eval board here. Just a Nucleo. Intentional because

A: it is CHEAP

B: It has nearly all the pins free except 1 LED and 1 Switch. MY favorite DEBUG tools..

With a nudge from ST. (I asked for help when I changed course) I have it working on Nucleo. Just as the EVAL demo sits *with* the commenting out of the LED inits and the call to toggle the LED in systick handler. SO - IT WAS ME...But I knew that. However getting NO response from anyone who might have this already runnable on Nucleo was disappointing. I don't mind doing the digging but encouragement helps. And seeing the CubeL4 go from 1.2 - 1.4 - 1.5 - 1.6(latest, for now) and seeing massive changes in the USB area in these made me a worry wart. But I don't quit.. I do get interrupted a lot with reality though.

By CHANGE COURSE I mean that I bit off more than I could chew . I have a rather large collection of Cra...uh CODE already up and going with a bunch of other peripherals active in it. And I tried to port over the NOT SO SMALL application of USB CDC into that existing sh... stuff. Needless to say- I backed off and just started from scratch to see if I could get the eval ported over AS IS, all by itself, to run on Nucleo. By then I was so frustrated that I immediately yelled for help when I hit the first 'IT DONT WORK' moment.

I no doubt butchered something else in my ALL IN ONE code collection because I already had those LED inits and calls to them ( in the error handlers too) commented out. But it still fell over itself but somehow made it to the while loop. And I mean the GOOD one at the bottom of main.

So Yeah - It works. After the drivers are installed. Another snipe hunt complete.

shingadaddy
Senior
Posted on November 30, 2016 at 17:09

OH!

And HAL or SPL

Well NOW I know that the HAL libray example works. And clive1 says the SPL examples are ''working'' while we labour away getting the new HAL stuff to do the same. So either one is okay I guess. I don't want clive1 to become *comfortably numb* though so we must make a convert out of him! :) He and jan have both helped me before but I think they lean to the SPL side.

I'm pretty sure I understand how folks see the SPL / HAL thing. SPL already works. Why change? And HAL obviously has some growing pains. Makes perfect sense to me since I think I am in a similar boat of HIGHLY ENCOURAGED to ''go for WORKING approach'' instead of ''GO FOR THE NICE and SHINEY''. I still have that *EMPLOYMENT / WORK* thing going on. But I've been given an opportunity. And I'm thankful for that.

I didn't use code from CubeMX. Just the HAL LIBRARY example as it was. I did run it thought just to see what happened and compare it to what I had. Near identical but for some reason the MX generated code that seemed to want to enable a GPIOH clock ?? On a 64 pin there is NO GPOIH port. Right. Anyway-

Another tidbit is the Nucleo comes with the 32.768 crystal. So it can ( in theory) run

the USB peripheral

1. From MSI trimmed with the 32.768

Or

2. From the HSE if you jump over the STLINK 8Mhz MCO clock to the HSE OSC in pin. ( Thanks clive1 ! )

Yes the EVAL example program shows exactly THAT as a selectable option in the RCC setup.

So there. The SPL/HAL debate AND USB/CDC on NUcleo L476RG. It works. With CubeL4 1.6 and Atollic Truestudio 6.0 

   --    (Dang they just updated it to 7.0!)

.

shingadaddy
Senior
Posted on December 02, 2016 at 00:34

Meant to drop a THANK YOU to jan and clive1 for the nudges. Appreciate it much. If I could give you points I would but this is sort of like ''Who's line is it anyway''.  The points don't matter.   :\

Posted on December 07, 2016 at 22:43

Hm..... Seems now I can give you points maybe.

@@

   .>

  -