DiodeHead wrote: In that pdf i found something that may answer :
it seems that the D+/D- pins are dedicated to USB and can't be assigned any other function. Correct? If so, how should I switch to PS/2 mode?
For a low speed USB interface, D+ pin will not be continuously high for more than 4µs because of the bit
stuffing mechanism. The PS/2 interface is determined by 1ms continuously high at D+ pin while the USB
interface is determined by receiving a SETUP token.
Yes, but I can't see (yet) how to do this on an ATmega32U4.
DiodeHead wrote: Well that´s the software part of the recognition, but if you take a look at the schematic you would see that they impement the conectors same way you propouse, in the freescale they have wired the usb dedicated hardware and two pins for ps/2.
When I look at the schematic in the .pdf, I see
two connectors - one for a PS/2 mouse (described in the text as "J2 is used for PS/2 mouse connection (for future development)") , one for USB. There's no sign of any connection between the USB D+/D- lines and the PS/2 Clock/Data lines, which are presumably reserved for the PS/2 mouse attached to connector J2.
The MC68HC908JB8 can obviously do this in hardware. Quoting its datasheet: "D– and D+ are the differential data lines used by the USB module. The USB module enable bit, USBEN, in the USB address register (UADDR) controls the pin options for PTE4/D– and PTE3/D+. When the USB module is enabled, PTE4/D– and PTE3/D+ function as USB data pins D– and D+. When the USB module is disabled, PTE4/D–and PTE3/D+ function as 10mA open-drain pins for PS/2 clock and data use."
I.e., this little fellow has the capability to use the 2 pins either for PS/2 or for USB. Judging from the datasheet, this is not possible with the ATmega16/32U4, since it has dedicated D+/D- lines.
Unfortunately, apart from this clever little design trick, the MC68HC908JB8 is a rather limited device (8K flash, 256 Bytes RAM, no EEPROM) and also "not recommended for new designs", otherwise I'd be tempted to go with that. I got plenty of 6809 assembler programming practice, adapting to the 6808 format should be easy.
That's possibly working with one of the mentioned keyboard encoder chips that can automatically detect the type of interface they're connected to. Just wiring up a cable doesn't change the hardware/software protocol that's dancing around on these wires
![Smile :-)](./images/smilies/icon_e_smile.gif)