Rendon
Newbie level 4
- Joined
- Jun 23, 2012
- Messages
- 7
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- South Africa
- Activity points
- 1,340
I cannot seem to write to this device. I am using library protocols in MikroC to address this device. I am able to address the smaller 24C02 without any difficulty. I have a small veroboard with 3 I^2C devices + dip switch arrays to preset device addresses.
I know that the 24C32 is addressed correctly because it returns a value of 255 only when its address corresponds to my variable set in code. If I remove the device or change its address, it does not return the value of 255. I am using the identical protocol as I do with the 24C02. There is no change in code. I am prefixing the device address with 1010 ****. The ONLY difference is the chip. Below is my code. I am using eeprom data address #9. Initially, I thought the device might be faulty, so I swapped it out, but to no avail. The value in variable "test" is what I am trying to write to the 24C32. Again, this code works perfectly on the 24C02. Any idea as to why that is? I'm stumped. (These are both Atmel devices.)
I know that the 24C32 is addressed correctly because it returns a value of 255 only when its address corresponds to my variable set in code. If I remove the device or change its address, it does not return the value of 255. I am using the identical protocol as I do with the 24C02. There is no change in code. I am prefixing the device address with 1010 ****. The ONLY difference is the chip. Below is my code. I am using eeprom data address #9. Initially, I thought the device might be faulty, so I swapped it out, but to no avail. The value in variable "test" is what I am trying to write to the 24C32. Again, this code works perfectly on the 24C02. Any idea as to why that is? I'm stumped. (These are both Atmel devices.)
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 char atmel4 = 0xa6, test=0x77, void main(){ PORTB = 0; TRISB = 0; // Configure PORTB as output I2C1_Init(100000); // initialize I2C communication //write protocol I2C1_Start(); // issue I2C start signal I2C1_Wr(atmel4); // send byte via I2C (device address + W) I2C1_Wr(9); // send byte (address of EEPROM location) I2C1_Wr(test); // send data (data to be written) I2C1_Stop(); // issue I2C stop signal //Read protocol Delay_100ms(); I2C1_Start(); // issue I2C start signal I2C1_Wr(atmel4); // send byte via I2C (device address + W) I2C1_Wr(9); // send byte (data address) I2C1_Repeated_Start(); // issue I2C signal repeated start I2C1_Wr(atmel4+1); // send byte (device address + R) PORTB = I2C1_Rd(0u); // Read the data (NO acknowledge) I2C1_Stop(); // issue I2C stop signal }
Last edited by a moderator: