Shop OBEX P1 Docs P2 Docs Learn Events
OBEX P1 Nunchuck & Classic Controller code working with P2 — Parallax Forums

OBEX P1 Nunchuck & Classic Controller code working with P2

RaymanRayman Posts: 14,646
edited 2021-01-20 20:51 in Propeller 2
I've adapted @JonnyMac's P1 Nunchuck driver to work on P2.

Only issue is that I had to set the I2C frequency down to 20 kHz to make it work.
Think it should be at 100 kHz.

Not exactly sure what's going on... Might have to break out a scope later if can't figure it out...


All better now after some slight changes to the i2c driver.

Got this classic controller code working on P2 too.

Comments

  • Wuerfel_21Wuerfel_21 Posts: 5,053
    edited 2021-01-19 21:11
    Haven't messed with hooking Wii stuff into propellers, but looking at that code as someone with a degree in Wiiology, two things stand out:
    - I think you can safely remove the whole NC_NINTENDO codepath and type selection, the other one should work with genuine controllers, too
    - Might be useful to have a check that a nunchuk is actually connected (after initialization, registers FE/FF should read $0000 - if they don't, something else is connected, if it's $FFFF there's nothing connected or it failed to init)
  • RaymanRayman Posts: 14,646
    The nunchuk is giving good data... It responds correctly to button pushes, etc. Probably need the scope to figure out what's wrong...
  • RaymanRayman Posts: 14,646
    edited 2021-01-20 20:14
    All better now, fixed by adding a few waits to the beginning of the I2C read routine.
    Now works at 100 kHz.

    Shoot. Spoke too soon. Had P2 clock at 40 MHz for this... Doesn't work at 160 MHz...

    Added one extra delay and now works at up to 300 MHz P2 clock.
Sign In or Register to comment.