|
|
View previous topic :: View next topic |
Author |
Message |
joseph Guest
|
TMC222 not responding |
Posted: Wed Sep 02, 2009 3:27 am |
|
|
Hello, I am trying to talk with a tmc222 (trinamic) in i2c but I have got strange reponse.
Can you help me ???
Code: |
#fuses HS, NOWDT, NOPROTECT, BROWNOUT
#use delay(clock=40000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,BITS=8,PARITY=N,STOP=1)
#use i2c(master,sda=PIN_C4,scl=PIN_C5,fast=200000)
//----------------------------------------------------------------
int TMC_adresse=0xc0;
//----------------------------------------------------------------
void main ()
{
for(;;)
{
delay_ms(1000);
getfullstatus1();
}
}
//-----------------------------------------------------------------
void GetFullStatus1()
{
i2c_start();
i2c_write(TMC_adresse);
i2c_write(0x81);
i2c_stop();
i2c_start();
i2c_write(TMC_Adresse+1);
byte0=i2c_read();
byte1=i2c_read();
byte2=i2c_read();
byte3=i2c_read();
byte4=i2c_read();
byte5=i2c_read();
byte6=i2c_read();
byte7=i2c_read();
byte8=i2c_read();
i2c_stop();
printf("msg: TMC REPONSE: %u, %u , %u , %u \r\n", byte0,byte1,byte2,byte3);
}
|
The "printf function send me some strange value.... I don't understand. |
|
|
ECACE
Joined: 24 Jul 2006 Posts: 94
|
|
Posted: Wed Sep 02, 2009 8:35 am |
|
|
How are you giving the device the address of 0xC0? In the datasheet it states that all devices come from the factory with an address of 0x00, and must be programmed with their own address. I don't see anywhere in your code how you are setting the address. Unless you have a section that is correctly setting the address, then set the address to 0x00.
Otherwise, what is the data that you are getting back? _________________ A HW Engineer 'trying' to do SW !!! Run!!! |
|
|
joseph Guest
|
|
Posted: Wed Sep 02, 2009 9:53 am |
|
|
I have seen the data sheet and on page 30, we can see :
for "getfullstatus1 command", you must write:
byte0 : the slave adress " 1_1_OTP3_OTP2_OTP1_OTP0_HW_0"(0xC0 en hex).
byte1 : getfullstatus1 code.
And with a unprogrammed device, OTP X =0.
> It's for that, i use slave adress = 0xC0. |
|
|
Guest
|
|
Posted: Wed Sep 02, 2009 12:19 pm |
|
|
Hi,
Well your trouble report "The printf function send me some strange value.... I don't understand" is VERY ambiguous..... Do you mean that the whole line is printing weirdly (ie. no text preamble), or just the data values you are trying to print???
I would guess that this line of your code may be part of your problem:
Code: |
#use delay(clock=40000000)
|
Are you really using a 40 MHz clock?? What is your PIC? What is your compiler version?
Doug |
|
|
|
|
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
|