This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Stellaris Skips Commands - I2CMasterDataPut



Hi All,

I'm using Code Composer Studio v5.5, with the stellaris board LM4F120. 

I've been developing a project since before Christmas on this board, and have not had any issues previously (other than minor human mistakes and the standard beginner compiler/linker mistakes). 

The part of the project I'm now developing involves using the I2C interface on I2C1, with several different chips. I'm using a driver, found in these forums (http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/236184.aspx), which I've had to modify a bit to get to work with my versions of the I2C.h file. I have tested this with an MPU6050 tri-axi accelerometer and gyroscope, and have found I can read values(what they are isnt important, but they change when I move the sensor in a repeatable fashion), which suggests to me that I am using I2C correctly. I then proceeded to add an extra API to handle 16-bit addressing to an EEPROM device (24AA64). 

I then successfully wrote and read to the addresses: 0x0000 and 0x0001. However, upon trying to write to 0x0002, the write method returns no errors, but a read to that same address returns 0xFF - the initial state of the EEPROM. On closer inspection of the registers in debug mode, I find that the 'I2C_0_MDR' register is not being modified by the write function. I had not altered the API or I2C.c file in any way between trying to write to 0x0001 and 0x0002. I have power cycled, flash erased the LM4F, and each time I read 0xFF. One theory I had was that the EEPROM, with an internal address pointer was responding to these blank reads by sending the value of the next address - as per the datasheet, though I not sure if this is possible after a power cycle. I disconnected the I2C wires from the bus, and tried simply to function call I2CMasterDataPut(), with my own values. These had no affect on the I2C_0_MDR register. 

I tried using the HWREG() command, found within the I2C.c driver and again no luck. I then initialised I2C2, but found I could not alter the MDR register there either.

Furthermore, I've noticed that when setting breakpoints in the code, and running, it will now often simply skip those breakpoints. I re-upload, delete all breakpoints and try adding them again, but nothing I do can force the program to stop at these breakpoints. I am really at a loss to explain all of these happenings. The only alteration I can think that I have made recently is unsuccessfully trying to add the UARTStudio.h file in, though not sure why this would break everything.

Any ideas as to things to try to fix this would be appreciated. I am convinced that the code is simply skipping the functions calls to "HWREG(I2C2_BASE + I2C_O_MDR) = ui8Data;" - why would it do that? Why do my breakpoints not attach?

Cheers

  • Update to this:

    Found that closing CCS, then cleaning the project and reprogramming fixes the skipping issue. I added in the code which worked on the mpu6050, works as it used to. I figure my 16-bit addressing code is incorrect in its use of the I2CMasterControl function somehow, though I find it odd how I can access 0x0000 and 0x0001, but no other address. That seems weird. Also seems weird that I2CMasterDataPut is linked to I2CMasterControl and I cant manipulate the MDR register out of a sequence? 

  • Hello Peter

    After doing a I2CMasterDataPut, the user has to write to the MCS register to tell the I2C Controller on what action to do. As an example if the current write to MDR is the last write and the user has to put a STOP condition on the bus, then MCS has to be written to transmit the data and then put a STOP which is achieved by setting RUN and STOP bits in the MCS

    Regards

    Amit