Go Down

Topic: Keyboard.h Not working, compiling errors (Read 2306 times) previous topic - next topic

wltue

Using a Arduino M0 pro and compiling the sketch: examples-09.USB-Keyboard-KeyboardMessage.

I get the following error 1 time:


Code: [Select]

In file included from C:\Users\USER\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.16\cores\arduino/Arduino.h:129:0,

                 from C:\Users\USER\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.16\libraries\HID\HID.h:23,

                 from C:\Users\USER\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.16\libraries\HID\HID.cpp:20:

C:\Users\USER\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.16\libraries\HID\HID.cpp: In member function 'virtual int HID_::getInterface(uint8_t*)':

C:\Users\USER\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.16\cores\arduino/USB/USBCore.h:37:56: warning: narrowing conversion of '(int)(((HID_*)this)->HID_::<anonymous>.PluggableUSBModule::pluggedEndpoint | 128u)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

 #define USB_ENDPOINT_IN(addr)                  ((addr) | 0x80)

                                                        ^

C:\Users\USER\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.16\cores\arduino/USB/USBCore.h:273:10: note: in definition of macro 'D_ENDPOINT'

  { 7, 5, _addr,_attr,_packetSize, _interval }

          ^

C:\Users\USER\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.16\libraries\HID\HID.cpp:36:14: note: in expansion of macro 'USB_ENDPOINT_IN'

   D_ENDPOINT(USB_ENDPOINT_IN(pluggedEndpoint), USB_ENDPOINT_TYPE_INTERRUPT, 0x40, 0x01)

              ^


I dont get the example working.

On a Arduino micro (32u4) it works fine.

oqibidipo

I don't see an error there, just a harmless (but verbose) warning.

wltue

Thank you for your response. But basically the SAMD doesn't go in USB HID keyboard mode. The example doesn't work for me. I thought maybe the warning could be the issue.

Running this example works fine on a Micro / 32u4, but i want to use the SAMD processors.

Maybe anyone can verify the "the sketch: examples-09.USB-Keyboard-KeyboardMessage" works on there M0/M0 Pro/Zero?

Thanks.

wltue

Sorry forgot to post the versions:
Arduino IDE 1.8.5
Board version: 1.16.16

Updated the bootloader though EDBG.

acting Pin 4 -> the TX flashes but no keyboard response.

gdsports

Perhaps D2 and D4 are swapped?

https://forum.arduino.cc/index.php?topic=330370.0

wltue

Thank you for your response.
The TX led flashes when applying the D4. But i will check asap with an other board.

wltue

Same stuff on the other board M0 Pro.

New bootloader.
Same IDE.

Tried every pin. Only pin 4 responses with tx led.

No HID device added in Windows Computer Management.

Will try other PC.

gdsports

#7
Oct 26, 2017, 09:06 am Last Edit: Oct 26, 2017, 09:08 am by gdsports
Works fine on a Zero. There are 2 micro USB connectors. The USB keyboard emulation is on the other connector.

The one named Programming is used with the IDE. The other one named native USB will appear to be a USB keyboard.

Also try a different USB cable. Some cables do not have data wires.

wltue

Thank you for your response and thank you for testing on a Zero.

I am a professional electronics hardware engineer and develop custom boards for Arduino and i know the hardware structure of the SAMD thank you.

- I tried different 3 pc's.
- 2 USB cords (they work both on a 32u4 board with the keyboard HID).
- 2 Arduino M0 pro's.
- reburning the bootloaders.

I will buy a Zero, they are in backorder at Farnell.

When burning a Zero bootloader in the M0 Pro it just refuses to work anymore on the native usb port. Even the "blink" example refuses to blink. I dont get it. The only difference is the pin d4 and d2.

Will try 4th pc.


wltue

4th pc clean install. Same as all other reports. I give up, will use 32u4. Thank you all for response.

wltue

Well finally figured it out.

Because pinPeripheral(pinnumber, function) didnt work on the M0 Pro either and i could not find any reports on this i focussed on the zero. I cannot buy it (yet) so i burned the bootloader samd21_sam_ba.hex with Atmel studio and Atmel-ICE.

Now "pinPeripheral(pinnumber, function)" works and yeah the sketch: "examples-09.USB-Keyboard-KeyboardMessage" too.

I did burn the bootloader through Arduino IDE and EDBG but that didnt seem to work for me.

Only thing to remember is the PIN 4 <> PIN 2 issue?!

Hope this helps to anyone.

Thanks for reading.

Go Up