The I2CInit function has overloaded parameters. You should just be able to call I2CInit(); and the speed divide parameter will be set to 0x16. This is just under 100KHz. The slave device on the bus should be able to slow the clock down if needed so I doubt this would be a problem. You definitely need to call the init function, you have it commented out in your code.
A good first step in debugging would also be to scan through all the addresses on the bus. There was a recent post where code was posted showing how to do this: http://forum.embeddedethernet.com/viewt ... ?f=5&t=730. You should copy the code that scans through all I2C addresses and see if your device is detected.
-Larry
I2C 5720
-
- Posts: 8
- Joined: Thu May 27, 2010 10:00 am
Re: I2C 5720
Larry,
I implemented the code to scan through all my address. I did not find my address. I have just bread boarded a LM75 and have attached it to my net burner programing board. So I should have seen 0x47 or 78 respond back. I have attached my scope and I can see the data and the clock. But I am still getting error number 4.
I did changed my code to I2CMaster, because all my device are slaves.
#ifdef _I2CMASTER_H
address = 0x1001111;
float i;
for( int x =0; x<128; x++)
{
if( I2CStart( x, I2C_START_READ ) < I2C_TIMEOUT )
iprintf("We have a %X on the bus\r\n", x );
I2CStop();
}
/* I2CInit( address ); */
I2CStat = ( I2CReadBuf(address, buffer, 3));
if( I2CStat == I2C_OK )
{
printf("Master RX: %x, %x\r\n", buffer[0], buffer[1]);
printf( "Receive successfully\r\n" );
}
else
iprintf( "Failed to read due to error: %d\r\n", I2CStat);
#endif
Here is my out put.
Failed to read due to error: 4
Waiting 2sec to start 'A' to abort
Configured IP = 192.168.1.75
Configured Mask = 0.0.0.0
MAC Address= 00:03:f4:03:fb:c2
Failed to read due to error: 4
Waiting 2sec to start 'A' to abort
Configured IP = 192.168.1.75
Configured Mask = 0.0.0.0
MAC Address= 00:03:f4:03:fb:c2
Failed to read due to error: 4
Waiting 2sec to start 'A' to abort
Configured IP = 192.168.1.75
Configured Mask = 0.0.0.0
MAC Address= 00:03:f4:03:fb:c2
Failed to read due to error: 4
Waiting 2sec to start 'A' to abort
Configured IP = 192.168.1.75
Configured Mask = 0.0.0.0
MAC Address= 00:03:f4:03:fb:c2
Value of X 0
Value of X 1
Value of X 2
Value of X 3
Value of X 4
Value of X 5
Value of X 6
Value of X 7
Value of X 8
Value of X 9
Value of X 10
Value of X 11
Value of X 12
Value of X 13
Value of X 14
Value of X 15
Value of X 16
Value of X 17
Value of X 18
Value of X 19
Value of X 20
Value of X 21
Value of X 22
Value of X 23
Value of X 24
Value of X 25
Value of X 26
Value of X 27
Value of X 28
Value of X 29
Value of X 30
Value of X 31
Value of X 32
Value of X 33
Value of X 34
Value of X 35
Value of X 36
Value of X 37
Value of X 38
Value of X 39
Value of X 40
Value of X 41
Value of X 42
Value of X 43
Value of X 44
Value of X 45
Value of X 46
Value of X 47
Value of X 48
Value of X 49
Value of X 50
Value of X 51
Value of X 52
Value of X 53
Value of X 54
Value of X 55
Value of X 56
Value of X 57
Value of X 58
Value of X 59
Value of X 60
Value of X 61
Value of X 62
Value of X 63
Value of X 64
Value of X 65
Value of X 66
Value of X 67
Value of X 68
Value of X 69
Value of X 70
Value of X 71
Value of X 72
Value of X 73
Value of X 74
Value of X 75
Value of X 76
Value of X 77
Value of X 78
Value of X 79
Value of X 80
Value of X 81
Value of X 82
Value of X 83
Value of X 84
Value of X 85
Value of X 86
Value of X 87
Value of X 88
Value of X 89
Value of X 90
Value of X 91
Value of X 92
Value of X 93
Value of X 94
Value of X 95
Value of X 96
Value of X 97
Value of X 98
Value of X 99
Value of X 100
Value of X 101
Value of X 102
Value of X 103
Value of X 104
Value of X 105
Value of X 106
Value of X 107
Value of X 108
Value of X 109
Value of X 110
Value of X 111
Value of X 112
Value of X 113
Value of X 114
Value of X 115
Value of X 116
Value of X 117
Value of X 118
Value of X 119
Value of X 120
Value of X 121
Value of X 122
Value of X 123
Value of X 124
Value of X 125
Value of X 126
Value of X 127
Failed to read due to error: 4
Bob
I implemented the code to scan through all my address. I did not find my address. I have just bread boarded a LM75 and have attached it to my net burner programing board. So I should have seen 0x47 or 78 respond back. I have attached my scope and I can see the data and the clock. But I am still getting error number 4.
I did changed my code to I2CMaster, because all my device are slaves.
#ifdef _I2CMASTER_H
address = 0x1001111;
float i;
for( int x =0; x<128; x++)
{
if( I2CStart( x, I2C_START_READ ) < I2C_TIMEOUT )
iprintf("We have a %X on the bus\r\n", x );
I2CStop();
}
/* I2CInit( address ); */
I2CStat = ( I2CReadBuf(address, buffer, 3));
if( I2CStat == I2C_OK )
{
printf("Master RX: %x, %x\r\n", buffer[0], buffer[1]);
printf( "Receive successfully\r\n" );
}
else
iprintf( "Failed to read due to error: %d\r\n", I2CStat);
#endif
Here is my out put.
Failed to read due to error: 4
Waiting 2sec to start 'A' to abort
Configured IP = 192.168.1.75
Configured Mask = 0.0.0.0
MAC Address= 00:03:f4:03:fb:c2
Failed to read due to error: 4
Waiting 2sec to start 'A' to abort
Configured IP = 192.168.1.75
Configured Mask = 0.0.0.0
MAC Address= 00:03:f4:03:fb:c2
Failed to read due to error: 4
Waiting 2sec to start 'A' to abort
Configured IP = 192.168.1.75
Configured Mask = 0.0.0.0
MAC Address= 00:03:f4:03:fb:c2
Failed to read due to error: 4
Waiting 2sec to start 'A' to abort
Configured IP = 192.168.1.75
Configured Mask = 0.0.0.0
MAC Address= 00:03:f4:03:fb:c2
Value of X 0
Value of X 1
Value of X 2
Value of X 3
Value of X 4
Value of X 5
Value of X 6
Value of X 7
Value of X 8
Value of X 9
Value of X 10
Value of X 11
Value of X 12
Value of X 13
Value of X 14
Value of X 15
Value of X 16
Value of X 17
Value of X 18
Value of X 19
Value of X 20
Value of X 21
Value of X 22
Value of X 23
Value of X 24
Value of X 25
Value of X 26
Value of X 27
Value of X 28
Value of X 29
Value of X 30
Value of X 31
Value of X 32
Value of X 33
Value of X 34
Value of X 35
Value of X 36
Value of X 37
Value of X 38
Value of X 39
Value of X 40
Value of X 41
Value of X 42
Value of X 43
Value of X 44
Value of X 45
Value of X 46
Value of X 47
Value of X 48
Value of X 49
Value of X 50
Value of X 51
Value of X 52
Value of X 53
Value of X 54
Value of X 55
Value of X 56
Value of X 57
Value of X 58
Value of X 59
Value of X 60
Value of X 61
Value of X 62
Value of X 63
Value of X 64
Value of X 65
Value of X 66
Value of X 67
Value of X 68
Value of X 69
Value of X 70
Value of X 71
Value of X 72
Value of X 73
Value of X 74
Value of X 75
Value of X 76
Value of X 77
Value of X 78
Value of X 79
Value of X 80
Value of X 81
Value of X 82
Value of X 83
Value of X 84
Value of X 85
Value of X 86
Value of X 87
Value of X 88
Value of X 89
Value of X 90
Value of X 91
Value of X 92
Value of X 93
Value of X 94
Value of X 95
Value of X 96
Value of X 97
Value of X 98
Value of X 99
Value of X 100
Value of X 101
Value of X 102
Value of X 103
Value of X 104
Value of X 105
Value of X 106
Value of X 107
Value of X 108
Value of X 109
Value of X 110
Value of X 111
Value of X 112
Value of X 113
Value of X 114
Value of X 115
Value of X 116
Value of X 117
Value of X 118
Value of X 119
Value of X 120
Value of X 121
Value of X 122
Value of X 123
Value of X 124
Value of X 125
Value of X 126
Value of X 127
Failed to read due to error: 4
Bob
Re: I2C 5720
There is something wrong with the code, your device is resetting.
show all your code.
show all your code.
-
- Posts: 6
- Joined: Tue Dec 01, 2009 10:21 am
Re: I2C 5720
That is my code except where I do my includes.
Larry, I just spoke with a friend and I was not using the correct pins on the 5270 module. when I saw data. When I am conecetd to J2 pins 39 and 42 I do not see any data on the buss. All I have connected is my lm75 on a bread board where A0 A1 A2 are tied to vcc which is 3.3v. Pin 1 and 2 SCL and SDA both tied to there own 10k resistor to vcc. An I do not see any thing on the out put.
Here are my questions.
1. If I disconnect my LM75 from the module and run the loop Larry recommended I should see at least device 8 respond correct?
2. Do I have to initialize the I2C Port?
Sorry for asking such basic questions
Bob
Larry, I just spoke with a friend and I was not using the correct pins on the 5270 module. when I saw data. When I am conecetd to J2 pins 39 and 42 I do not see any data on the buss. All I have connected is my lm75 on a bread board where A0 A1 A2 are tied to vcc which is 3.3v. Pin 1 and 2 SCL and SDA both tied to there own 10k resistor to vcc. An I do not see any thing on the out put.
Here are my questions.
1. If I disconnect my LM75 from the module and run the loop Larry recommended I should see at least device 8 respond correct?
2. Do I have to initialize the I2C Port?
Sorry for asking such basic questions
Bob
Re: I2C 5720
you still have not commented out the I2CInit( );
you need that for it to work.
you need that for it to work.
-
- Posts: 6
- Joined: Tue Dec 01, 2009 10:21 am
Re: I2C 5720
So you need to inable the buss with I2CInit( );
Bob
Bob