I have a problem with my MT9V135 sensor. Apparently, when I run the program for interfacing Micron sensors to the BF537 EZ-Kit Lite, the sensor does not recognize the slave address or TWI address that the program designates; an "Address Not Acknowledge" (ANAK) bit occurs in the
TWI_MASTER_STAT register. As a result, the master mode transmit operation does not push through; and register values are not programmed into the sensor registers. Thus, the sensor does not operate.
Although, I've considered other possible TWI addresses that are specified on the sensor datasheet and the configuration settings for MI354 revision 2 sensors, the problem still persists leaving me with no choice but to ask help from you guys. I just would like to ask two questions: (1) What are the possible problems that make the sensor 'not acknowledge' the TWI address?; and (2) Do you have data for MI354 revision 4 sensor configuration settings? Again, any help will do and will be greatly appreciated.
Regards,
Allan
Hi Allan,
The address you have in TWI_MASTER_ADDR is 8-bits.
Is this because the address already contains the read/write bit? If so, you need to omit that bit when writing the address.
One thing you might want to try is to only use the 7 most significant bits of the ID (i.e. 0x5D instead of 0xBA)
Regards,
-Wassim
Hi Wassim,
Thanks for the reply! I've actually tried using 5D or BA>>1 as the address, but to no avail - the sensor still could not acknowledge the slave address. I now am thinking about skipping the register addressing part since I have a demo board and a development software. These two, when used, are capable of loading sensor register default values. Thus, instead of using the TWI to load sensor register values, I plan to use the demo board along with its software. Do you think that would be okay? Oh and by the way, can you be so kind as to guide me on how I could check the contents of the SDRAM? The program that I have places the pixel data from the sensor into the SDRAM. I really have no idea as to how I could check its content.
I know I'm asking too much, but I really would appreciate it if you could help me. ![]()
Regards,
Allan
Hi Allen,
You may have already tried this too, but it's still worth noting that the sensor seems to use a different address depending on the polarity of a particular pin.
Did you try 0x90>1 as well? If that didn't work either, then my suspicion is that there's something wrong other than TWI communication.
Are you using an emulator to debug the Blackfin? If so, the tools that you're using (VisualDSP, GDB, etc) should allow you to read the contents of SDRAM. Information on how to read memory can be found in the documentation of those tools. Of course, you need to start out by figuring out the address of the buffer in SDRAM where the program is placing the pixel data.
Hope this helps.
Regards,
-Wassim
Hi Wassim,
Thanks for the help! I really appreciate it.
I've actually tried the 0x90>>1 address. However, it still did not work. I tried using a logic analyzer to check the SCL of the TWI. Apparently, the SCL only had high transitions. Hence, leaving me with the conclusion that the SCL is the problem. With the SCL not working properly, data transfer would also not work properly. I think that this is the the reason as to why the sensor did not acknowledge the slave address.
The program that I have is the sample program for interfacing the Blackfin 537 to the MT9V022 sensor, which is found in the VDSP 4.5 folder. I've modified the program in such a way that it would work for the MT9V135 sensor, considering sensor datasheet and Blackfin manuals. Now my questions are: (1) What could be the possible reasons as to why the SCL did not seem to work properly?; and (2) Would the BF537 settings (system clock settings, core clock settings, TWI clock prescale settings, clock division settings and duty cycles) be entirely different for the MT9V135 sensor as compared to the MT9V022 sensor? Again, any help will do and will be greatly appreciated. ![]()
Regards,
Allan
Hi Allan,
What do you mean by "only high transitions"? Does it stay high?
Notice that the SDA (serial data) and SCL (serial clock) pins are open drain and therefore require a pull-up resistor.
The example program is based on a system clock of 120MHz.If your system clock is running at a different frequency then you need to change the PRESCALE value in TWI_CONTROL.
Hope this helps.
Regards,
-Wassim
Hi Wassim,
There has been a mistake. Apparently, there is a working SCL. I've also checked the PLL settings. The VCO of the system is set at 0x3000 or 600MHz with a clock in of 25MHz. System clock is set at 120MHz (VCO/5) and core clock is 600MHz (VCO/1). Prescale is 12 (120MHz/10MHz). TWI_DIV hi and low are 50 each considering a duty cycle of 50%. Below are screenshots of the TWI register values considering 0xBA and 0x90 addresses.
As you can see, the problem still persists - the sensor still does not acknowledge the slave address designated by the TWI. Thus, I still can't write the default sensor register values into their respective registers. Does it have something to do with the TWI slave register not set? Because according to the hardware reference manual, specifically, the programming model of the master mode, one has to 'WRITE TO TWI_SLAVE_CTL TO ENABLE SLAVE FUNCTIONALITY'. Do I really need to do this? Apparently, I've read a contrasting statement that says slave mode does not affect master mode operation. Thus, I really am confused.
However, I've still modified the program considering the programming model and enabling the slave register. What happened was the master mode operation did happen. However, instead of a master transmit happening, a master receive event occured. Still, no sensor register write had occurred.
I know I've troubled you enough, Wassim; and for all your help, I thank you. However, if you could at least somehow tell me the other possible reasons as to why the problem still persists, then I would appreciate it. I badly need your help since I really can't tell where the problem comes from.
Regards,
Allan
Hi Allan,
Since you're not getting past the addressing stage, my suspicion is that the problem isn't the TWI communication.
You may want to double-check the circuit connections around the sensor. Verify that the sensor is appropriately powered, that it is not in standby mode, and that the TWI lines have an appropriate pull-up resistor.
Regards,
-Wassim
Hi Wassim,
I've checked the sensor schematic. The sensor has pull-up resistors that are 10k Ohms each. Actually, the sensor works fine when interfaced with a micron demo board. In addition, when it is interfaced to the AV-Extender of the BF board and its output is tapped and projected onto an LCD, there are no problems at all. The sensor works fine and is able to diplay images at 30fps. Therefore, I think that there are no problems at all with the sensor.
Now, could it be possible that the problem is with the program code? I really and honestly think that there is something missing with the program code. I've attached the program code here. If you have time, then please take a look at it. Wassim, thank you very much for your patience and for all your help. I really am grateful to you.
Regards,
Allan
Hi Allan,
are you using one of those Aptina head boards?
I can't tell about your sensor model, but most of those boards have an extra i2c switch in between, mostly at address 0x70 or 0x73 (7 bit address without R/W bit). You need to write some value (mostly a '1') to this chip in order to be able to access the sensor. But probably you already checked the headboard schematics..
There's some sample TWI code to scan for existing i2c devices on the bus:
http://www.section5.ch/forum/viewtopic.php?f=2&t=118
Unfortunately, it won't run from the box on VDSP, it's rather GNUware. But you could copy the TWI snippets over.
Greetings,
- Martin
Hi Allan,
There is a PPT from NXP (who are the original I2C architects) about I2C protocol hardware level debugging (Blackfin TWI port confirms to the I2C standard)
http://www.standardics.nxp.com/literature/presentations/i2c/pdf/debug.i2c.oscilloscope.pdf
They have explained a number h/w factors to be considered, including the affect of pull-up resistance on the Clock. Take a look at that, and see if you are missing something.
Regards
Prasanth.
Hi Prasanth,
Thank you very much for the pieces of information!
I'll study the presentations right away.
Regards,
Allan
Hi guys,
Great news! The sensor is now working fine. We've already captured images. However, the problem with the TWI still persists. I still am working on it. Thanks for all your help. I really appreciate it. ![]()
Regards,
Allan
Hi Martin,
Thank you for all the pieces of information! I actually have the MT9V135 sensor. It is a descendant of the MT9V125 sensor and uses the exact same architecture as the MT9V125 sensor. Like you said, the sensor board indeed has an I2C switch. Specifically, it has the PCA9543APW-T I2C switch.
I'll try doing the things you have suggested me. I'll let you know if there are any progress with my TWI problems.
Regards,
Allan
Hi Allan,
I actually found the schematics for the headboard, so this sequence (according to the twi.c from the sample shell code) should allow you to access the sensor:
i2c_init(SWITCH_I2C_ID, 0); i2c_write(0x01, 0x01);
// Then we can talk to the sensor
error = i2c_init(SENSOR_I2C_ID, 0);
if (error < 0) {
printf("Sensor not responding\n");
return ERR_COMM_TIMEOUT;
}
where SWITCH_I2C_ID is 0x73.
Don't knock yourself on the forehead :-) -- if that was the problem.
It wasn't obvious to me either, the Aptina docs didn't explicitely mention.
Cheers,
- Martin