After much futzing, I did get all my 20.3 projects to compile with 21.11 (the updater tool helped, but needed a bit of learning); however,
what is not working is USB. I use USB with CRS on boards with the F042 and L432 parts. I previously imported some STM hal code to use CRS, but I'd like to avoid that. Are there any examples floating about that use ChibiOS libraries directly for CRS. Also, did anything significant change in USB hal support between 20.3 and 21.11? While I was able to compile my existing USB code, the interface didn't start up so I'm guessing the problem is either with the USB clock or some structural change in the USB code.
Geoffrey
USB with CRS is there an example?
Moderator: RoccoMarco
-
geoffrey.brown
- Posts: 122
- Joined: Thu May 07, 2015 9:47 pm
- Has thanked: 3 times
- Been thanked: 18 times
-
geoffrey.brown
- Posts: 122
- Joined: Thu May 07, 2015 9:47 pm
- Has thanked: 3 times
- Been thanked: 18 times
Re: USB with CRS is there an example?
As it happens, everything works. In the process of porting I messed up one of the config files. So CRS/USB works fine. On the other hand, it would be terrific to have a higher level for CRS in the hal -- possibly as a config option.
Geoffrey
Geoffrey
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: USB with CRS is there an example?
Hi,
CRS is not yet supported, it is in the todo list for several devices.
Giovanni
CRS is not yet supported, it is in the todo list for several devices.
Giovanni
-
geoffrey.brown
- Posts: 122
- Joined: Thu May 07, 2015 9:47 pm
- Has thanked: 3 times
- Been thanked: 18 times
Re: USB with CRS is there an example?
While the CRS has multiple features including the source of the synchronization signal and various status interrupts, the simple case is just locking the USB48 clock to the USB signal. For future reference, here's what the initialization looks like for the F042 synchronizing from the USB signal. This use case is similar across the various families supporting CRS.
// Enable CRS clock in APB1[/code][/code]
RCC->APB1ENR |= RCC_APB1ENR_CRSEN;
// Configure CRS: Source = USB SOF (10), Sync polarity = Rising, update rate = 48M/48K = 1khz
CRS->CFGR = (2 << CRS_CFGR_SYNCSRC_Pos) | (34 << CRS_CFGR_FELIM_Pos) | 48000;
// Enable Automatic Trimming and the Counter
CRS->CR |= CRS_CR_AUTOTRIMEN | CRS_CR_CEN;
I imagine a Hal component would need to support the interrupts and allow other synchronization sources.
// Enable CRS clock in APB1[/code][/code]
RCC->APB1ENR |= RCC_APB1ENR_CRSEN;
// Configure CRS: Source = USB SOF (10), Sync polarity = Rising, update rate = 48M/48K = 1khz
CRS->CFGR = (2 << CRS_CFGR_SYNCSRC_Pos) | (34 << CRS_CFGR_FELIM_Pos) | 48000;
// Enable Automatic Trimming and the Counter
CRS->CR |= CRS_CR_AUTOTRIMEN | CRS_CR_CEN;
I imagine a Hal component would need to support the interrupts and allow other synchronization sources.
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: USB with CRS is there an example?
It does not need a component, just a single setting in mcuconf.h in the clocks section.
Giovanni
Giovanni