Alternative controller experiments
- Oobly
- Location: Finland
- Main keyboard: GON NerD60, Vortex case
- Main mouse: Cyborg R.A.T 3
- Favorite switch: Trampoline modded 62g ErgoClears
- DT Pro Member: -
I believe the Freescale Kinetis MKL range can do USB fine without a crystal, you just have to initialise it to use the internal 48MHz clock and enable the USB clock recovery feature: cache.freescale.com/files/microcontrollers/doc/app_note/AN4905.pdf
"3.1 USB device mode clocking initialization using 48 MHz IRC
Follow the steps below to configure the USB module to use the 48 MHz IRC as its clock source and enable the clock
recovery feature.
1. Enable the peripheral clock to the USB module by setting the SIM_SCGC4[USBOTG] bit.
2. Select the 48 MHz IRC as the optional peripheral clock by setting the SIM_SOPT2[PLLFLLSEL] field to 0x3.
3. Configure the USB clock source to use the clock selected by the PLLFLLSEL field instead of the USB_CLKIN pin by
setting the SIM_SOPT2[USBSRC] bit.
4. The USB clock passes through a programmable fraction divider controlled by the SIM_CLKDIV2 register. The default
value of this divider is the desired divide by one, so this register should not need to be modified.
5. Enable the 48 MHz IRC clock (set USB_CLK_RECOVER_IRC_EN[IRC_EN]).
6. Enable the USB clock recovery feature by setting USB_CLK_RECOVER_CTRL[CLOCK_RECOVER_EN].
7. Continue with regular USB device mode initialization."
For this and other reasons I've been designing a board using the MKL26z chips like the TeensyLC uses, but I haven't got very far yet. I will be following this thread closely and hopefully be able to add info now and then as my design progresses. I'd rather not have to use an external chip like the Teensy does for the bootloader.
"3.1 USB device mode clocking initialization using 48 MHz IRC
Follow the steps below to configure the USB module to use the 48 MHz IRC as its clock source and enable the clock
recovery feature.
1. Enable the peripheral clock to the USB module by setting the SIM_SCGC4[USBOTG] bit.
2. Select the 48 MHz IRC as the optional peripheral clock by setting the SIM_SOPT2[PLLFLLSEL] field to 0x3.
3. Configure the USB clock source to use the clock selected by the PLLFLLSEL field instead of the USB_CLKIN pin by
setting the SIM_SOPT2[USBSRC] bit.
4. The USB clock passes through a programmable fraction divider controlled by the SIM_CLKDIV2 register. The default
value of this divider is the desired divide by one, so this register should not need to be modified.
5. Enable the 48 MHz IRC clock (set USB_CLK_RECOVER_IRC_EN[IRC_EN]).
6. Enable the USB clock recovery feature by setting USB_CLK_RECOVER_CTRL[CLOCK_RECOVER_EN].
7. Continue with regular USB device mode initialization."
For this and other reasons I've been designing a board using the MKL26z chips like the TeensyLC uses, but I haven't got very far yet. I will be following this thread closely and hopefully be able to add info now and then as my design progresses. I'd rather not have to use an external chip like the Teensy does for the bootloader.
- flabbergast
- Location: Southampton, UK
- DT Pro Member: 0120
- Contact:
Yes, Freescale KL2x chips can do crystal-less USB just fine (I have been just playing with a FRDM-KL25Z board). They're pretty much the same (to use) as K20x chips (e.g. Teensy 3.*, infinity keyboard, mchck); the USB peripheral is actually the same. So, you're going to either have to write your own bootloader, or adapt either the mchck or kiibohd bootloader to KL26Z. (Or buy one of the KL02Z "bootloader chips" from Paul.)
-
- Main keyboard: Shine 3 TLK MX Brown
- Main mouse: Sensei
- Favorite switch: MX Blue
- DT Pro Member: -
For what it's worth, here's a list of the Kinetis devices with a bootloader preinstalled, either in flash for one-time use or in ROM:
http://www.freescale.com/products/arm-p ... ader:KBOOT
http://www.freescale.com/products/arm-p ... ader:KBOOT
- flabbergast
- Location: Southampton, UK
- DT Pro Member: 0120
- Contact:
Thanks, I didn't know about this page. It seems that KL27Z does have a bootloader in ROM - Good! Finally, Freescale. If it works reasonably, it might end up being the ideal chip for keyboards. Also using it should be an easy upgrade from KL26Z/Teensy LC. (Hopefully there'll be a LQFP-48 version of the KL27Z line, LQFP-64 are getting too big for my taste
- Oobly
- Location: Finland
- Main keyboard: GON NerD60, Vortex case
- Main mouse: Cyborg R.A.T 3
- Favorite switch: Trampoline modded 62g ErgoClears
- DT Pro Member: -
Wow! Awesome find. I'm probably going to switch to the 27 then, too. Another requirement for me (and the reason I switched away from ATMega32U4) is I need 2 hardware I2C/SPI lines. Lovely. They have QFN 32 and 48 pin versions, but I think only 64 pin LQFP. Or if you really want to have fun, 36 and 64 pin BGA.flabbergast wrote: ↑Thanks, I didn't know about this page. It seems that KL27Z does have a bootloader in ROM - Good! Finally, Freescale. If it works reasonably, it might end up being the ideal chip for keyboards. Also using it should be an easy upgrade from KL26Z/Teensy LC. (Hopefully there'll be a LQFP-48 version of the KL27Z line, LQFP-64 are getting too big for my taste
- Oobly
- Location: Finland
- Main keyboard: GON NerD60, Vortex case
- Main mouse: Cyborg R.A.T 3
- Favorite switch: Trampoline modded 62g ErgoClears
- DT Pro Member: -
Ah, bollocks! Seems the MKL27z doesn't have the voltage regulator built in like the 26z does. So it needs external 3.3v power supply. I may stick with the 26z if I can get a good bootloader working.
-
- Main keyboard: Shine 3 TLK MX Brown
- Main mouse: Sensei
- Favorite switch: MX Blue
- DT Pro Member: -
Hey Oobly, check http://cache.freescale.com/files/32bit/ ... leExt=.pdf - thats the MKL27 I've successfully prototyped using its inbuilt regulator.
Not sure where you're looking but the datasheet I'm linking clearly shows a VREGIN pin which takes the 5V USB power rail.
Not sure where you're looking but the datasheet I'm linking clearly shows a VREGIN pin which takes the 5V USB power rail.
- Oobly
- Location: Finland
- Main keyboard: GON NerD60, Vortex case
- Main mouse: Cyborg R.A.T 3
- Favorite switch: Trampoline modded 62g ErgoClears
- DT Pro Member: -
Beautiful! I think this is the perfect chip for my use case! Thank you for the info.twiddle wrote: ↑Hey Oobly, check http://cache.freescale.com/files/32bit/ ... leExt=.pdf - thats the MKL27 I've successfully prototyped using its inbuilt regulator.
Not sure where you're looking but the datasheet I'm linking clearly shows a VREGIN pin which takes the 5V USB power rail.
- flabbergast
- Location: Southampton, UK
- DT Pro Member: 0120
- Contact:
I have to correct myself... Contrary to what I thought I've actually not been playing with KL25Z crystal-less. I'll try later today and report.flabbergast wrote: ↑Yes, Freescale KL2x chips can do crystal-less USB just fine (I have been just playing with a FRDM-KL25Z board).
By the way, Freescale is slightly misinforming about the crystal-less USB. That application note does *not* actually apply to K20x or KL2x chips (these do not have the recover-clock-from-USB capability as far as I can tell). However, people have been successfully running USB on MK20DX* chips (mchck, infinity keyboard) without a crystal, just using the internal clock. I've been looking through the reference manuals, and this seems to be officially "out-of-spec". I'm going to try this also on the KL25Z; it should work, but again, it's not quite "officially" allowed.
EDIT: Yes, it does seem the work on KL25Z in the same way as on MK20DX*.
-
- Main keyboard: Shine 3 TLK MX Brown
- Main mouse: Sensei
- Favorite switch: MX Blue
- DT Pro Member: -
It most definitely is out of spec from what I have heard. the IRC (internal oscillator) has too much drift to meet the USB spec, which is what the recover-clock-from-usb functionality is designed to compensate for.
- flabbergast
- Location: Southampton, UK
- DT Pro Member: 0120
- Contact:
Actually checking all the reference manuals (KL25Z, KL26Z, KL27Z) it seems that 25 and 26 do *not* have the recover-clock-from-USB, but KL27Z does! (I've got some samples on the way.)
-
- Main keyboard: Shine 3 TLK MX Brown
- Main mouse: Sensei
- Favorite switch: MX Blue
- DT Pro Member: -
No need to even check there. Go to : http://www.freescale.com/products/arm-p ... T-SELECTOR and put under USB features "USB Crystal-less(FS)". Filter based on RAM/FLASH/Pin count.
-
- Main keyboard: Shine 3 TLK MX Brown
- Main mouse: Sensei
- Favorite switch: MX Blue
- DT Pro Member: -
So the boards arrived from Smart Prototyping:
Here it is fully assembled:
Now to just test that everything is working. Good news though, the USB/Battery portion of the circuit behaves as expected for sure so that is one big chunk of the BTLE design sorted.
Here it is fully assembled:
Now to just test that everything is working. Good news though, the USB/Battery portion of the circuit behaves as expected for sure so that is one big chunk of the BTLE design sorted.
- DiodeHead
- Location: Spain
- Favorite switch: Gateron white
- DT Pro Member: -
hi guys
flabber did u have time to play with your kl27 breakuot board ?? i ordered a couple of MKL27Z256VLH4 when the post started and when it arrived i wasnt feeling very confident on making a breakout board by myself, now that i saw yours, i think ill be better off if i order yours than making my own.
do u have the schematic on hand so my ic and your pcbs can be friends forever ??
are u using the kinetis ide for this breakuot board or u have your own toolchain ??
sorry if the question where already anwsered
thanks for the hard work as always guys.
flabber did u have time to play with your kl27 breakuot board ?? i ordered a couple of MKL27Z256VLH4 when the post started and when it arrived i wasnt feeling very confident on making a breakout board by myself, now that i saw yours, i think ill be better off if i order yours than making my own.
do u have the schematic on hand so my ic and your pcbs can be friends forever ??
are u using the kinetis ide for this breakuot board or u have your own toolchain ??
sorry if the question where already anwsered
thanks for the hard work as always guys.
- flabbergast
- Location: Southampton, UK
- DT Pro Member: 0120
- Contact:
I didn't actually have a KL27Z breakout board until yesterday (the previous pics were STM32F0xx breakouts). But yesterday I received a package from OSH Park, and here we go, MKL27ZxxxVLH4 breakout (warning: can't be used with 32k and 64k versions of KL27 chips, those don't have an internal regulator). OSH Park orderable PCB here.
I haven't played with it much yet (didn't have the time), just checked that the bootloader enumerates correctly and responds to the communication from the freescale PC-side tool.
I'm not using kinetis IDE, just a text editor and the open source GNU ARM toolchain. Mainly ChibiOS these days, but I'm still just implementing KL27 support for it.
I haven't played with it much yet (didn't have the time), just checked that the bootloader enumerates correctly and responds to the communication from the freescale PC-side tool.
I'm not using kinetis IDE, just a text editor and the open source GNU ARM toolchain. Mainly ChibiOS these days, but I'm still just implementing KL27 support for it.
- flabbergast
- Location: Southampton, UK
- DT Pro Member: 0120
- Contact:
Just a quick warning - be careful when soldering this: I hand-solder, and apparently it's possible that during soldering the flash becomes corrupted. There are four particular bits in the flash, which when in a particular state, can irrevocably brick the chip ("flash secure" and "mass erase disabled"). This happened to me on one of these KL27Z boards.
-
- Main keyboard: Shine 3 TLK MX Brown
- Main mouse: Sensei
- Favorite switch: MX Blue
- DT Pro Member: -
Are you sure this is the cause? It should probably be reported to freescale if so... I've hand soldered 10 or so kinetis qfps and never had that happen.flabbergast wrote: ↑Just a quick warning - be careful when soldering this: I hand-solder, and apparently it's possible that during soldering the flash becomes corrupted. There are four particular bits in the flash, which when in a particular state, can irrevocably brick the chip ("flash secure" and "mass erase disabled"). This happened to me on one of these KL27Z boards.
- flabbergast
- Location: Southampton, UK
- DT Pro Member: 0120
- Contact:
I had exactly the same happening to me as in this thread (just with KL27Z). I also tried 2 different SWD debuggers for "mass erase" which would un-secure the chip. Didn't succeed. Then soldered another chip and that one was fine. I got both chips for free from Freescale as samples, so I don't think I should complain too much
I think I fiddled with the non-working one a bit too much. Certainly when I solder a SMT diode, it lights up slightly for a short amount of time, so I think there can be some slight current flow during soldering. There's a reference to an app note in that thread, which explains Kinetis chips might try to start up when they detect some electricity, and during the inevitable fail the flash might be corrupted.
I think I fiddled with the non-working one a bit too much. Certainly when I solder a SMT diode, it lights up slightly for a short amount of time, so I think there can be some slight current flow during soldering. There's a reference to an app note in that thread, which explains Kinetis chips might try to start up when they detect some electricity, and during the inevitable fail the flash might be corrupted.
- flabbergast
- Location: Southampton, UK
- DT Pro Member: 0120
- Contact:
Yea, I'm too cheap for that One "generic" CMSIS-DAP and one cheap STM32-based from ebay (it enumerates as "jlink", but I don't believe for a moment that it has anything to do with an actual jlink).
-
- Main keyboard: Shine 3 TLK MX Brown
- Main mouse: Sensei
- Favorite switch: MX Blue
- DT Pro Member: -
There are two main issues with using a raspberry pi: firstly, the size (about 4-5x the 2d area of a teensy or similar, at least) and the software that it runs.
The Raspberry pi is a SoC (system on chip) based device, I believe, and it runs a complete operating system. It isn't really designed, or cost effective, to use a $40 computer as a controller - it would be like me getting a mac mini and using that. It's way overkill.
The Raspberry pi is a SoC (system on chip) based device, I believe, and it runs a complete operating system. It isn't really designed, or cost effective, to use a $40 computer as a controller - it would be like me getting a mac mini and using that. It's way overkill.
-
- Main keyboard: CM Storm Quick Fire Rapid-I
- DT Pro Member: -
i mean maybe it can double up and be a board or a board with multiple hard drivestwiddle wrote: ↑There are two main issues with using a raspberry pi: firstly, the size (about 4-5x the 2d area of a teensy or similar, at least) and the software that it runs.
The Raspberry pi is a SoC (system on chip) based device, I believe, and it runs a complete operating system. It isn't really designed, or cost effective, to use a $40 computer as a controller - it would be like me getting a mac mini and using that. It's way overkill.
- DiodeHead
- Location: Spain
- Favorite switch: Gateron white
- DT Pro Member: -
well, now that the orange pi has dropped the price a bit i still dont see as a controller, but as a developer enviroment i do, i think theres a avrdude version for the pi and his clones that u can use the pinout to programa an avr and the compiler is also aviable i think, also the io pinout could be use to experiment with diferent matrix escaning algorithms and so on before porting to a microcontroller.
at least thats my intent in the future, i dont know i would be able to install an arm toolchain for the k27 but i think is posible with the gcc-arm embedded.
https://launchpad.net/gcc-arm-embedded
at least thats my intent in the future, i dont know i would be able to install an arm toolchain for the k27 but i think is posible with the gcc-arm embedded.
https://launchpad.net/gcc-arm-embedded
- hbar
- Location: Germany
- Main keyboard: ħα
- Main mouse: ħα
- Favorite switch: Campagnolo Ergopower
- DT Pro Member: -
Raspberry Pi as a controller -- maybe not such a stupid idea if the goal is to make a keyboard with a built-in computer (in true Atari ST and Commodore Amiga style). It must be said, however, that even the Atari ST (not sure about the Amiga) had their own dedicated keyboard controllers. The keyboard would essentially be a "bus keyboard" on the Raspberry Pi, and we all remember those "bus mice" of the 1980s, so I wouldn't expect a "bus keyboard" to have a reputation any better.
Seriously, leave the keyboard to the keyboard controller that's small and cheap and energy-efficient enough for the job (the quad-core Raspberry PI isn't). You don't put FPGAs into wristwatches either.
Seriously, leave the keyboard to the keyboard controller that's small and cheap and energy-efficient enough for the job (the quad-core Raspberry PI isn't). You don't put FPGAs into wristwatches either.
- hbar
- Location: Germany
- Main keyboard: ħα
- Main mouse: ħα
- Favorite switch: Campagnolo Ergopower
- DT Pro Member: -
Flabbergast, maybe it's time to replace your soldering iron? I've never ever had a LED flash at me when soldering. My iron has a 4mm socket in its base than I can connect the ESD mat (and even wrist strap, for the really paranoid) to. Still, it never applies any voltage to the circuit, whether the ESD stuff is connected or not (usually it isn't).
- flabbergast
- Location: Southampton, UK
- DT Pro Member: 0120
- Contact:
I guess that might be it - I need to look into this. I wondered what's going on with the LEDs...
-
- Location: Canada
- Main keyboard: DIY
- Favorite switch: Stiff Linear
- DT Pro Member: -
Does anyone have any advice, tutorials, or example code for getting the STM32f072 running as a keyboard?
I've been messing around for weeks trying to get the code generated by stm32cubemx converted from its mouse-centric starting point into a keyboard. I followed an example on ST's youtube channel and can move the mouse pointer around, but whenever I've tried to make it into a keyboard, windows just gives me an error 10.
I've been messing around for weeks trying to get the code generated by stm32cubemx converted from its mouse-centric starting point into a keyboard. I followed an example on ST's youtube channel and can move the mouse pointer around, but whenever I've tried to make it into a keyboard, windows just gives me an error 10.
- flabbergast
- Location: Southampton, UK
- DT Pro Member: 0120
- Contact: