I2C, Mt9d111, and Hardware Registers.

Our weekly LIVE video chat. Every Wednesday at 8pm ET!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
abalducci
 
Posts: 14
Joined: Wed Aug 20, 2014 10:17 am

I2C, Mt9d111, and Hardware Registers.

Post by abalducci »

I feel a little bit 'bad' asking this question here, as a few weeks ago I posted this question over on the Teensy forums and got no response. Further, while there are a few open source codes in this area (i.e Mr_Arduino), I also tried contacting them directly and got no response. The code, I don't doubt, is effective (written for the Mega), but also the whole 'process' seems a bit less clearly documented than I would like. So, my goal in this is to both eventually 'open source' as well as through Hackaday.io

Code: Select all

https://hackaday.io/project/3878-digital-holga
, more clearly explain the 'thought process' on communicating with 'higher res' cameras such as these. I imagine in the community there probably is an interest in this, seeing as Ada/Spark only carry 'lower res' models (understandably as these things would overwhelm your basic Uno, but I feel the Teensy is just fit for it, but no one has done the implementation yet), there just isn't a really good 'tutorial' yet as to 'how to do it', which is in the end what I aim to make. I'm also trying to make this project into a gift for a friend.

However, in the meantime, there is an 'initial' point on which 'conceptually', I am a little bit stuck. So the 'gist' of the question/description below is that I 'get' hardware registers when they are 'on-chip', like on a PIC or an Uno or something... But when they are 'off chip', on a peripheral... ? Just how do you talk/address them ?

I'm not sure if the suggested 'procedure' I have laid out is at least 'somewhat' conceptually correct? Or if not, I think I would be just banging my head against a wall for a long time (as a mistaken register or 'code on a processor' will typically spit out an error, either at compile or run-time... But a 'distant peripheral', will 'just sit there' staring back at you on the desk, frustratingly mute and not doing what you want).
I am trying to work on an open-source project using the Teensy 3.1 and the Micron Mt9d111 imaging module. Completed, I hope this will be a resource to the Teensy community especially as I have not seen many camera adaptations for the Teensy, though it is definitely the right speed/size and thus much more appropriate than the Arduino..

However, there are a few points from the datasheet I am slightly uncertain as to how to address.

For one, general communication and control to the module is established via I2C.

From the datasheet, an example of a 16-bit hardware register read:

Example: 16-Bit Register Read
This is an example of a 16-bit register read from Chip Version register (R0x00:0),
expected value = 0x1519
1. Send Start
2. Send Device Address
a. 0xBA
3. Wait for ack
4. Send register address (8-bit)
a. 0x00
5. Wait for ack
6. Send Stop
7. Send Start
8. Send device address for read
a. 0xBB
9. Wait for ack
10. Slave device sends 8-bit data (MSB byte)
a. 0x15
11. Master send ack
12. Slave device sends another 8-bit data (LSB byte)
a. 0x19
13. Master send nack
14. Send Stop

Using the 'Wire' library to start (I understand there is an 'enhanced' I2C library, but I just want to get the basics down first), I believe this would be accomplished by the following:

Wire.beginTransmission(0xBA)
Wire.send(0x00)
Wire.beginTransmission(0xBB)
Wire.requestFrom(0x15, 1)
Wire.requestFrom(0x19, 1)

[or, would the last two lines instead be just the following:]

Wire.receive()
Wire.receive()

?

The one other question I had is that sometimes the hardware registers on the module are listed not just as '0xBA', say, but rather something like, just as a randomly selected example, "R198:1[7:0]". It is the ":1[7:0]" part I don't quite get. Or if I was looking at Verilog I would think it might be describing some sort of port or something, but obviously this is communication over two wire serial... So I am not quite sure I understand that part, or what it is referencing.

In any case, any help would be appreciated, and in the end I look forward to 'giving back'.

Best,
- Anthony

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: I2C, Mt9d111, and Hardware Registers.

Post by adafruit_support_rick »

Like this:

Code: Select all

Wire.beginTransmission(0xBA)
Wire.send(0x00)
Wire.endTransmission()
Wire.requestFrom(0xBB, 2)
int16_t result = ((Wire.read() << 8) | Wire.read());
abalducci wrote: "R198:1[7:0]". It is the ":1[7:0]" part I don't quite get.
Not sure about the :1 - I assume that is referring to one byte of the register R198. The [7:0] refers to bits 7 through 0.

User avatar
abalducci
 
Posts: 14
Joined: Wed Aug 20, 2014 10:17 am

Re: I2C, Mt9d111, and Hardware Registers.

Post by abalducci »

Dear Rick,

Thanks much for the clarification/general confirmation as to hardware registers as now I have a start. I will try to go into more depth of an explanation on my Hackaday page once I have done some testing.

Best,
- Anthony

Locked
Please be positive and constructive with your questions and comments.

Return to “Ask an Engineer! VIDEO CHAT (closed)”