CMM2: minor Nunchuk/Classic controller "bug"


Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3659
Posted: 11:29am 21 Nov 2022      

Hi Peter,

It appears to be currently possible from MMBasic to open a Wii controller and then read from it before the firmware has performed the first (16 mSec) poll of the controller resulting in the "initial values" being returned (these appear to be zeroes, but I think I saw "garbage" on one occasion that I can't now reproduce.)

It's easy enough to workaround (add a short PAUSE), but you might want to consider updating the firmware to force a poll immediately after the controller has opened, or equivalently add a pause at the end of the OPEN routine; assuming that won't block the poll.

Best wishes,

Tom
Edited 2022-11-21 21:29 by thwill

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8090
Posted: 01:15pm 21 Nov 2022      

Try this (untested)


CMM2.zip

thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3659
Posted: 01:27pm 21 Nov 2022      

Thanks Peter,

  matherp said  Try this (untested)


Bill (@Turbo46) would you test this on your Nunchuck, don't forget to remove the PAUSE that you added. I'll test it with the Classic.

Best wishes,

Tom

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1419
Posted: 01:05am 22 Nov 2022      

Sorry, that didn't work for me. I still get zeros for the first readings of JX and JY.

Bill

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1419
Posted: 06:16am 22 Nov 2022      

I had some problems with this firmware. A couple of times the keyboard would not work. Because I had the wrong keyboard option set (UK not US), I changed the keyboard option.

After that the keyboard only worked very occasionally after powering down and up. No console to teraterm either. I tried another keyboard and power supply and got no improvement.

Eventually I re-flashed the CMM2 with 5.07.02b6 and all is good again.

It was a bit flaky before I changed the keyboard.

Bill

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8090
Posted: 10:13am 22 Nov 2022      

Try again. I've reverted to an older version of the IDE. It is the only change that could affect USB since RC6


CMM2.zip

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1419
Posted: 11:06am 22 Nov 2022      

Thanks Peter I'll try it out tomorrow for the USB problem but it didn't help with the initial problem before I tried to change the keyboard.

Bill

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8090
Posted: 11:07am 22 Nov 2022      

I have made a further change to the controller check in the latest. Somehow I think you found a 2mSec window

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1419
Posted: 11:27am 22 Nov 2022      

Thanks again Peter, Murphy's law always works against me. I will try again tomorrow.

Bill

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1419
Posted: 09:10pm 22 Nov 2022      

Sorry again, while I can change the keyboard back and forth with no problems now, JX and JY still read zero for the first time. There is a 250mS delay in my test program before I read it again to give me time to see that first reading.

Bill

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8090
Posted: 10:44pm 22 Nov 2022      

The controller has been polled multiple times in 250mSec so there is nothing more I can do. My "fix" was just to make sure one poll happens before the OPEN command completes.

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1419
Posted: 11:04pm 22 Nov 2022      

Thanks for trying Peter, I guess a pause 16mS or more before polling the Nunchuk will work. Or a do - loop waiting for a non zero value. (and they do)

Bill

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8090
Posted: 09:30am 23 Nov 2022      

One more try

I found a variable that wasn't labelled volatile that is changed in the interrupt routine so it is possible the issue was a caching/optimisation issue


CMM2.zip

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1419
Posted: 10:12am 23 Nov 2022      

SUCCESS! Thanks Peter, there are no zero readings on jx and jy on my first reading of the Nunchuk. No PAUSE or DO...LOOP needed.

I hope that fixes any issues for Tom with his Classic.

Thanks again.
Bill

thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3659
Posted: 10:20am 23 Nov 2022      

Lovely, I'll give it a thrash with the Wii Classic Controller at the weekend.

Thanks for your dogged determination Peter.

Best wishes,

Tom

toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 318
Posted: 09:50am 26 Nov 2022      

  matherp said  One more try

I found a variable that wasn't labelled volatile that is changed in the interrupt routine so it is possible the issue was a caching/optimisation issue


CMM2.zip


Does this have all the features of the beta CMM2V5.07.02b6? If not what's the latest version?

thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3659
Posted: 04:38pm 28 Nov 2022      

  thwill said  Lovely, I'll give it a thrash with the Wii Classic Controller at the weekend.


I've briefly tested it (better late than never) and as far as I can tell it is now behaving itself. Thanks again Peter.

  toml_12953 said  Does this have all the features of the beta CMM2V5.07.02b6? If not what's the latest version?


I assume so. It reports itself to be 5.07.02b8 but I don't know if Peter has "officially blessed" this as beta 8 or that is an "accident".

Best wishes,

Tom
Edited 2022-11-29 03:06 by thwill