CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Reading multi-bytes from an i2c slave - Wii Nunchuck
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kd5uzz



Joined: 28 May 2006
Posts: 56

View user's profile Send private message

PostPosted: Mon Nov 26, 2007 11:36 am     Reply with quote

It works! Thanks PCM Programmer. I had in fact swapped the SCL and SDA lines just before break (and before you posted your code). Thanks again!
-Daniel
sodb



Joined: 30 Nov 2007
Posts: 1

View user's profile Send private message

PostPosted: Fri Nov 30, 2007 5:27 pm     Reply with quote

Thank guys. I was trying the same thing for a few weeks and just got all 0xff back from the nunchuck. I use a 18f242 running on 3V. Using the correct address 0xA4 it works like a dream. This is just an intermediate step in connecting the nunchuck g-sensor to a Lego Mindstorm NXT (internally using also i2c). Using the PIC I at least know that the nunchuck & I2C is working as it should.
joven



Joined: 30 Jan 2007
Posts: 56
Location: Viana do Castelo - Portugal

View user's profile Send private message

PostPosted: Mon Dec 22, 2008 10:13 am     Reply with quote

Did you need to decode the data received or not?
Code:
k=((x^0x17)+0x17);
Kova



Joined: 06 May 2007
Posts: 35

View user's profile Send private message

PostPosted: Fri May 29, 2009 11:58 pm     Reply with quote

PCM programmer wrote:
You've already gone through two units. I suggest you cut off the
connector and get it running.


Hi,
I have resumed this thread for a question.
I want to emulate the nunchuck or the classic wii controller.
I'm explaining better.

This is my goal:
I want to connect a interface with a PIC to Wiimote:

Wiimote <--> PIC interface (for example it emulates only the A key).

This interface will be able to emulate, for example, the A wii classic controller key.
I have readed all documentation about the protocol, but I don't understand very well how can I do that.
Many articles explain how to connect the wii-controllers (nunchuck-classic controll) to a PC or a MCU (for example arduino).

Somebody can help me?
What is the initial handshaking?
My interface will be a slave in the I2C communication, right?

After this:
The communication between the Wiimote and the Extension Controllers is 400kHz "fast" I2C, with the slave address 0x52.
What are the other packets/reports that I have to send?

A pseudo-code also will be great.

Thanks a lot for all.
Bye guys . Wink
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 30, 2009 1:25 am     Reply with quote

You have dreamed up a project, but then you propose that we should
research the protocol and write an outline of the code for you.
Shouldn't you be the one to do this ?




Mr. Green
Kova



Joined: 06 May 2007
Posts: 35

View user's profile Send private message

PostPosted: Sat May 30, 2009 2:14 am     Reply with quote

PCM programmer wrote:
Shouldn't you be the one to do this ?
Mr. Green


Naaa, It's not so.
I want only to know what are the "packets" that wiimote <--> interface have to send/receive.
The code is not a problem.

If you say me these:
Wiimote send 0xff at 0xA4 address
Interface send 0x01 at 0xA4.. etc.
for me will be enough Smile

I have readed the documentation but many docs say only the packet that wiimote sends when a controller is plugged, but I haven't readed nothing about the response given by the nunchuck/wii classic (the handshaking)
Am I blind?

;)
Bye
ricard0g0mes



Joined: 19 May 2009
Posts: 6

View user's profile Send private message

PostPosted: Tue Jul 21, 2009 1:57 am     Reply with quote

hello,

I'm trying to use this code but my project works at 20Mhz.
Do I need to change it to a lower value to work with i2c?
How can I define the speed of the i2c communication?
My pic is a 18f4550.

thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 21, 2009 11:00 am     Reply with quote

Just set the oscillator #fuses statement to HS (instead of XT) and set
the #use delay() statement to 20 MHz.

If you do that, CCS will automatically use the same speed for the i2c
clock (or as close as possible).
btklister



Joined: 16 Jul 2009
Posts: 14

View user's profile Send private message

PostPosted: Sat Jun 26, 2010 7:28 pm     Reply with quote

The code posted in the previous page works for a Chinese wireless nunchuk? The addresses are the same?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group