AnsweredAssumed Answered

STM32F103 I2C interrupt driven method 2

Question asked by blaxter.laurence.001 on Jan 16, 2012
Latest reply on Jul 8, 2013 by krie.maxi
I am having issues with interrupt driven I2C using method 2 from the reference manual. I am trying to read from the magnetometer on an lsm303dlh. The least significant bit of the most significant byte seems to be taking a fixed value.
  I have taken a look with an oscilloscope and the data on the bus is correct, for example when the data on the X axis appears as 0xFF04 from my code, it is 0xFE04 on the bus. I don't think the problem concerns the entire most significant byte, as i have seen the other bits flipping.
The accelerometer does not appear to have the same issue, but the data is differently aligned, so this issue may be occuring, but buried in the noise. I have tried using a Bosch barometer and the data seems fine, but the transactions are only 3 bytes in length.
  I have attached my code - it is built around an array of 'job structures'. When a job is requested using the request function the i2c will pass the data in the array associated with the job too or from the i2c bus. I am using EXTI interrupts off the data ready lines from the sensor, these have the same pre-emption priority as the i2c interrupts, but the i2c interrupts have the highest priority in the group (maybe im using the wrong wording there - the i2c interrupt service routines cannot themselves be interrupted, but they may have to wait a short while for the EXTI irq to complete before running - i can see this lag on the scope, but its 1us or so at worst).
 Can anyone offer advice on where I may have gone wrong? I have read the errata but I cant find anything directly relevant to my issue.

Regards,

Laurence

Attachments

Outcomes