Hi all,
I'm trying to port the USB code from https://github.com/PaulStoffregen/cores/tree/master/teensy3 from the MKL26Z to the MKL27Z.
Other than using USB0_CLK_RECOVER_CTRL and USB0_CLK_RECOVER_IRC_EN to use the 48 MHz clock, would there be any other changes necessary?
Is the USB core otherwise the same?
I'm using the keyboard descriptors, I'm trying to send a key. That works.. but then it just repeatedly sends the same character over and over again.
I call usb_keyboard_send() https://github.com/PaulStoffregen/cores/blob/master/teensy3/usb_keyboard.c#L470
Which calls usb_tx() cores/usb_dev.c at master · PaulStoffregen/cores · GitHub
After that, I get a USB interrupt with TOKDNE set in ISTAT, endpoint 1 (the keyboard enpdoint)
I don't get any other USB interrupts after that (apart from SOFTOK only, which I don't print because there are so many of them).
Yet, the same character prints to my screen forever.
Anyone got any ideas?
Solved! Go to Solution.
Hello Joey
I run essentially identical USB keyboard code on KL26 and KL27s (the only difference being - as you already know - that the KL27 can use crystal-less clocking as an option).
Does your code otherwise operate normally on a KL26 (such as the TEENSY LC?).
Note that after sending a key scan code you may need to release it (send a 0 key scan code) otherwise it is like someone holding down a key, which may be your basic problem (not processor related in any way).
As far as I have been able to make out, the Freescale community doesn't have much involvement with the Arduino software as used by the Teensy community so you may have more luck asking there.
If you are flexible and can use other development environments such as GCC, KDS, CW, Atollic, IAR, Keil, Crossworks etc. there are ready made USB keyboard solutions at the links below. They also allow keboard to be used at the same time as USB-CDC and USB-MSD (composite), which the Arduino code sources can't do (at the moment). The keyboard sequences achieve 1kBytes/sec. (twice the Ardunino speed).
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
KL26: http://www.utasker.com/kinetis/FRDM-KL26Z.html / http://www.utasker.com/kinetis/TEENSY_LC.html
KL27: http://www.utasker.com/kinetis/FRDM-KL27Z.html / http://www.utasker.com/kinetis/Capuccino-KL27/Capuccino-KL27.html
Composite device and keyboard testing: http://www.utasker.com/kinetis/USB_Device.html
For the complete "out-of-the-box" Kinetis experience and faster time to market
Hello Joey
I run essentially identical USB keyboard code on KL26 and KL27s (the only difference being - as you already know - that the KL27 can use crystal-less clocking as an option).
Does your code otherwise operate normally on a KL26 (such as the TEENSY LC?).
Note that after sending a key scan code you may need to release it (send a 0 key scan code) otherwise it is like someone holding down a key, which may be your basic problem (not processor related in any way).
As far as I have been able to make out, the Freescale community doesn't have much involvement with the Arduino software as used by the Teensy community so you may have more luck asking there.
If you are flexible and can use other development environments such as GCC, KDS, CW, Atollic, IAR, Keil, Crossworks etc. there are ready made USB keyboard solutions at the links below. They also allow keboard to be used at the same time as USB-CDC and USB-MSD (composite), which the Arduino code sources can't do (at the moment). The keyboard sequences achieve 1kBytes/sec. (twice the Ardunino speed).
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
KL26: http://www.utasker.com/kinetis/FRDM-KL26Z.html / http://www.utasker.com/kinetis/TEENSY_LC.html
KL27: http://www.utasker.com/kinetis/FRDM-KL27Z.html / http://www.utasker.com/kinetis/Capuccino-KL27/Capuccino-KL27.html
Composite device and keyboard testing: http://www.utasker.com/kinetis/USB_Device.html
For the complete "out-of-the-box" Kinetis experience and faster time to market
Hi Mark,
Thanks a lot!
I forgot to sending a packet releasing the key, everything is working now! Silly mistake by me.
The uTasker code seems more difficult to bring into another project, I just copied the usb_*.c files from Teensy and I'm using them without the rest of the Teensy code. I'd be interested in knowing how you achieve higher rates for keyboard input, but while I'm bringing up the rest of my project I think I'll stick with what is now working!
Thanks,
Joey
Joey
Good to hear that it was a simple mistake.
1000 Keys/s is possible if you just send one (changed) stroke a ms, rather than sending a stroke, key release, stroke (which I think the Arduino code does).
The uTasker keyboard interface uses a SW queue so code can send pre-defined 'strings' (eg. from a file defining such sequences) using
CHAR keySequence[] "Send this key sequence to the PC\nNow send another one, etc. etc. etc.";
fnWrite(keboard, buffer, (sizeof() - 1));
whereby the queue handles also key stroke code conversion and only sends key releases when two identical characters are sent in a row. It is interrupt driven and non-blocking for the application so - depending on your environment - it may or may not give additional general performance advantages.
The uTasker code may become more efficient once you needed to do futher development since it allows the USB and all processor operations to be simulated (removing HW debgging requirements), includes various other USB classes that can be instantly used as composites (such as USB-MSD, which Arduino can't do yet) plus USB host operation (if your HW were to support it).
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
KL27: http://www.utasker.com/kinetis/FRDM-KL27Z.html / http://www.utasker.com/kinetis/Capuccino-KL27/Capuccino-KL27.html
For the complete "out-of-the-box" Kinetis experience and faster time to market