|
|
View previous topic :: View next topic |
Author |
Message |
danji25 Guest
|
PIC - NXT Sensor |
Posted: Wed Mar 04, 2009 5:01 pm |
|
|
Hi !!!!
Please help me ! I have a big problem with the
communication between a pic18f4550 and a nxt rfid sensor.
The jave programm with lejos run absolut well with the nxt. But the c programm doesn't run on the pic!!! The iC2 frequency is 10kHz.
The part of the read method of java:
the slave address of the sensor is 0x04
Code: | public int read0() {
buf1[0] = 0x01;
this.sendData(0x41, buf1, 1); //Single mode for read
try {
Thread.sleep(250);
} catch (InterruptedException e) {
}
getData(0x42, buf2, 1); //read 1byte date of the address 0x42
return (buf2[0]);
}
And this is the part my c programm for the pic:
#use I2C(master,FAST=1000, sda=PIN_B0, scl=PIN_B1) // 10KHz for i2c
I2C_Start();
I2C_Write( 0x04 ); // Slave Adress
I2C_Write( 0x41 ); // set pointer to control status
I2C_Write(1); //Single read
I2C_Start();
I2C_Write( 0x04 ); // Slave Adress
I2C_Write( 0x42 ); // set pointer to control status
read0 = I2C_Read();
i2c_stop(); |
Is the c programm correct ???? The sensor works but i become not the correct ID. The value of read0 is always ff hex. The pegel of SCL and SDA is 3 Volt. Is this enough for the pic. The pull ups of the rfid sensor are 86k7.
Please help me !!! Thank you |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 04, 2009 5:17 pm |
|
|
If you need help on a driver for a chip, post the part number of the chip
and a link to the data sheet for the chip. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Mar 05, 2009 1:32 am |
|
|
I don't know about the particular device, but your I2C handling involves more than one fault.
Basically, I2C transactions can be either read or write. The lowest bit of address byte determines the data direction, you have only a write address (0x04). After this first byte, all succeding actions can be either write or read, but not both, as in your code. Review the CCS provided I2C examples (in driver directory) and the description of I2C built-in functions. |
|
|
|
|
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
|