EmbeddedRelated.com
Forums

About sending data from I2C

Started by orhan October 28, 2012
Hello Everybody, I am from Turkey and I am working on a school project about object tracking. I have a big problem that I have couldn't solve. If you can help me, I would be very appreciated.

My problem is about connecting my MSP430 emulation board with a CMOS camera. My emuation board is EM430F6137RF900. The camera is TCM8240MD. The problem is when I connect the MSP430's SDA and SCL pins to the camera, Suddenly clock and data signals disappear. Initially I had connected pull up resistors to SDA and SCL pins. But it didn't change anything. Then I have tried Using an inverting buffer for two times. By doing this, I could keep the SDA and SCL signals. But because of inverting buffer, when a data comes from camera, the buffer disorders the signal on SDA. I have pasted my code here. I have used Port1 to initialize and open the PVDD, DVDD, EXTCLK and RESET. Datasheet links for CC430F6137 and TCM8240MD are below.

http://www.ti.com/lit/ds/symlink/cc430f6137.pdf

http://www.sparkfun.com/datasheets/Sensors/Imaging/TCM8240MD_E150405_REV13.pdf

#include "cc430x613x.h"

unsigned char *PTxData; // Pointer to TX data
unsigned char TXByteCtr;

const unsigned char TxData[] = // Table of data to transmit
{
0x02,
0x00
};

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT

P1DIR |= BIT0+BIT1+BIT2+BIT3;

P1OUT&=~BIT0; //to initialize PVDD
P1OUT&=~BIT1; //to initialize DVDD
P1OUT&=~BIT2; //to initialize EXTCLK
P1OUT&=~BIT3; //to initialize RESET

PMAPPWD = 0x02D52; // Get write-access to port mapping regs
P2MAP6 = PM_UCB0SDA; // Map UCB0SDA output to P2.6
P2MAP7 = PM_UCB0SCL; // Map UCB0SCL output to P2.7 //Map SMCLK output to P2.3
PMAPPWD = 0; // Lock port mapping registers;

P2SEL |= BIT6 + BIT7; // Select P2.6 & P2.7 to I2C function

UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
UCB0BR0 = 15; // fSCL = SMCLK/12 = ~100kHz
UCB0BR1 = 0;
UCB0I2CSA = 0x3D; // Slave Address is 048h
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
UCB0IE |= UCTXIE; // Enable TX interrupt

P1OUT |= BIT0; // Open PVDD
P1OUT |= BIT1; // open DVDD
P1OUT |= BIT2; // open EXTCLK

__delay_cycles(1000);
P1OUT |= BIT3; // Enable RESET

while (1)
{
__delay_cycles(50); // Delay required between transaction
PTxData = (unsigned char *)TxData; // TX array start address
// Place breakpoint here to see each
// transmit operation.
TXByteCtr = sizeof TxData; // Load TX byte counter

UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition

while (UCB0CTL1 & UCTXSTP);

//__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts
__no_operation(); // Remain in LPM0 until all data
// is TX'd
while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
}
}

//------
// The USCIAB0TX_ISR is structured such that it can be used to transmit any
// number of bytes by pre-loading TXByteCtr with the byte count. Also, TXData
// points to the next byte to transmit.
//------
#pragma vector = USCI_B0_VECTOR
__interrupt void USCI_B0_ISR(void)
{
switch(__even_in_range(UCB0IV,12))
{
case 0: break; // Vector 0: No interrupts
case 2: break; // Vector 2: ALIFG
case 4: break; // Vector 4: NACKIFG
case 6: break; // Vector 6: STTIFG
case 8: break; // Vector 8: STPIFG
case 10: break; // Vector 10: RXIFG
case 12: // Vector 12: TXIFG
if (TXByteCtr) // Check TX byte counter
{
UCB0TXBUF = *PTxData++; // Load TX buffer
TXByteCtr--; // Decrement TX byte counter
}
else
{
UCB0CTL1 |= UCTXSTP; // I2C stop condition
UCB0IFG &= ~UCTXIFG; // Clear USCI_B0 TX int flag
//__bic_SR_register_on_exit(LPM0_bits); // Exit LPM0
}
default: break;
}
}

Beginning Microcontrollers with the MSP430

Hi,

> Hello Everybody, I am from Turkey and I am working on a school project
> about object tracking. I have a big problem that I have couldn't solve. If
> you can help me, I would be very appreciated.
>
> My problem is about connecting my MSP430 emulation board with a CMOS
> camera. My emuation board is EM430F6137RF900. The camera is TCM8240MD. The
> problem is when I connect the MSP430's SDA and SCL pins to the camera,
> Suddenly clock and data signals disappear. Initially I had connected pull
> up resistors to SDA and SCL pins. But it didn't change anything. Then I
> have tried Using an inverting buffer for two times. By doing this, I could
> keep the SDA and SCL signals. But because of inverting buffer, when a data
> comes from camera, the buffer disorders the signal on SDA. I have pasted
> my code here. I have used Port1 to initialize and open the PVDD, DVDD,
> EXTCLK and RESET. Datasheet links for CC430F6137 and TCM8240MD are below.
>
> http://www.ti.com/lit/ds/symlink/cc430f6137.pdf
>
> http://www.sparkfun.com/datasheets/Sensors/Imaging/TCM8240MD_E150405_REV13
> .pdf

If you intend to do object tracking with this, I think you're going to be
using an underpowered microprocessor. I have that camera and hooked it up
to an XMOS XCore device for fun.

I2C communication is only used for the control interface, i.e. to put the
camera into certain modes. The colour data (frame) is presented over a
parallel bus, and even at 25MHz, I don't think your MSP430 will have the
memory to store, performance to acquire, or performance to analyse the
incoming image.

Just my thoughts.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore Development Platform http://www.soldercore.com

--- In m..., "Paul Curtis" wrote:
>
> Hi,
>
> > Hello Everybody, I am from Turkey and I am working on a school project
> > about object tracking. I have a big problem that I have couldn't solve. If
> > you can help me, I would be very appreciated.
> >
> > My problem is about connecting my MSP430 emulation board with a CMOS
> > camera. My emuation board is EM430F6137RF900. The camera is TCM8240MD. The
> > problem is when I connect the MSP430's SDA and SCL pins to the camera,
> > Suddenly clock and data signals disappear. Initially I had connected pull
> > up resistors to SDA and SCL pins. But it didn't change anything. Then I
> > have tried Using an inverting buffer for two times. By doing this, I could
> > keep the SDA and SCL signals. But because of inverting buffer, when a data
> > comes from camera, the buffer disorders the signal on SDA. I have pasted
> > my code here. I have used Port1 to initialize and open the PVDD, DVDD,
> > EXTCLK and RESET. Datasheet links for CC430F6137 and TCM8240MD are below.
> >
> > http://www.ti.com/lit/ds/symlink/cc430f6137.pdf
> >
> > http://www.sparkfun.com/datasheets/Sensors/Imaging/TCM8240MD_E150405_REV13
> > .pdf
>
> If you intend to do object tracking with this, I think you're going to be
> using an underpowered microprocessor. I have that camera and hooked it up
> to an XMOS XCore device for fun.
>
> I2C communication is only used for the control interface, i.e. to put the
> camera into certain modes. The colour data (frame) is presented over a
> parallel bus, and even at 25MHz, I don't think your MSP430 will have the
> memory to store, performance to acquire, or performance to analyse the
> incoming image.
>
> Just my thoughts.
>
> --
> Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> SolderCore Development Platform http://www.soldercore.com
>

Thank you Paul for your answer. But we have divided the project into 3 parts. First of all we will get the image of the data and keep it in the MSP430's flash. The second stage is to send the data via RF communication to data collection unit(DCU,it will be a computer). In the DCU we will gather all pictures and it will process the images. At the last stage DCU will send the related control comments to MSP430 via RF communication to control the servo control unit for turning camera to the object. As you said you are right about doing image processing in this type of MSP430 will be very hard due to its memory. But its memory will be sufficient for storing image data,I think. Because our image data will be about 10-15kb with the resolution of 240x320.

Hi,

> > If you intend to do object tracking with this, I think you're going to
> > be using an underpowered microprocessor. I have that camera and
> > hooked it up to an XMOS XCore device for fun.
> >
> > I2C communication is only used for the control interface, i.e. to put
> > the camera into certain modes. The colour data (frame) is presented
> > over a parallel bus, and even at 25MHz, I don't think your MSP430 will
> > have the memory to store, performance to acquire, or performance to
> > analyse the incoming image.
> >
> > Just my thoughts.
> >
> > --
> > Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> > SolderCore Development Platform http://www.soldercore.com
>
> Thank you Paul for your answer. But we have divided the project into 3
> parts. First of all we will get the image of the data and keep it in the
> MSP430's flash.

This is, umm, clearly difficult. The camera's interface is clocked fairly
quickly, without pause during a scan line. Perhaps you might be able to
store data in the flash at the end of the scan line.

The second stage is to send the data via RF communication
> to data collection unit(DCU,it will be a computer). In the DCU we will
> gather all pictures and it will process the images. At the last stage DCU
> will send the related control comments to MSP430 via RF communication to
> control the servo control unit for turning camera to the object. As you
> said you are right about doing image processing in this type of MSP430
> will be very hard due to its memory. But its memory will be sufficient for
> storing image data,I think. Because our image data will be about 10-15kb
> with the resolution of 240x320.

240x320x2 bytes/pixel ~= 153k, so I suppose you're using JPEG mode?

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore Development Platform http://www.soldercore.com

In fact, We couldn't get the data yet. But when I connect MSP430 with camera via inverting buffer for twice, I see ACKs coming from camera at the SDA channel of camera. But due to buffer, we cannot make this ACK reach to MSP430.
For RGB565 you may be ok about 153kb but we will use the jpeg compression feature of the camera. So it will be about 10-15kb. If we cannot use jpeg compression of the camera, we will use FIFOs for storing the picture data with RGB565.

--- In m..., "Paul Curtis" wrote:
>
> Hi,
>
> > > If you intend to do object tracking with this, I think you're going to
> > > be using an underpowered microprocessor. I have that camera and
> > > hooked it up to an XMOS XCore device for fun.
> > >
> > > I2C communication is only used for the control interface, i.e. to put
> > > the camera into certain modes. The colour data (frame) is presented
> > > over a parallel bus, and even at 25MHz, I don't think your MSP430 will
> > > have the memory to store, performance to acquire, or performance to
> > > analyse the incoming image.
> > >
> > > Just my thoughts.
> > >
> > > --
> > > Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> > > SolderCore Development Platform http://www.soldercore.com
> >
> > Thank you Paul for your answer. But we have divided the project into 3
> > parts. First of all we will get the image of the data and keep it in the
> > MSP430's flash.
>
> This is, umm, clearly difficult. The camera's interface is clocked fairly
> quickly, without pause during a scan line. Perhaps you might be able to
> store data in the flash at the end of the scan line.
>
> The second stage is to send the data via RF communication
> > to data collection unit(DCU,it will be a computer). In the DCU we will
> > gather all pictures and it will process the images. At the last stage DCU
> > will send the related control comments to MSP430 via RF communication to
> > control the servo control unit for turning camera to the object. As you
> > said you are right about doing image processing in this type of MSP430
> > will be very hard due to its memory. But its memory will be sufficient for
> > storing image data,I think. Because our image data will be about 10-15kb
> > with the resolution of 240x320.
>
> 240x320x2 bytes/pixel ~= 153k, so I suppose you're using JPEG mode?
>
> --
> Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> SolderCore Development Platform http://www.soldercore.com
>

Hello!

Don't know if this will help, but, let's go:

1) Link to datasheet is broken. Use this instead:
http://www.sparkfun.com/datasheets/Sensors/Imaging/TCM8240MD_E150405_REV13.pdf

2) Usually, SDI and SDO is mainteined in high impedance if the supply
voltage of the device is not OK. As this device uses 3 diff. supply
voltages, try to check then all.

3) According to datasheet, to do a low-to-high transition you need a
minimum of 0.7 x IOVDD voltage to operate SDI correctly (pg 26). Do you
guarantee this voltage? Also, check if a high-to-low voltage is guaranteed.

4) Paul has a good point - I2C is slower than SPI. BUT! This camera
operates only with I2C mode. *Maybe *filtering/operating with DMAs you can
do what you intend to do..

Good luck!

Fero

On Mon, Oct 29, 2012 at 6:10 AM, Paul Curtis wrote:

> **
> Hi,
> > Hello Everybody, I am from Turkey and I am working on a school project
> > about object tracking. I have a big problem that I have couldn't solve.
> If
> > you can help me, I would be very appreciated.
> >
> > My problem is about connecting my MSP430 emulation board with a CMOS
> > camera. My emuation board is EM430F6137RF900. The camera is TCM8240MD.
> The
> > problem is when I connect the MSP430's SDA and SCL pins to the camera,
> > Suddenly clock and data signals disappear. Initially I had connected pull
> > up resistors to SDA and SCL pins. But it didn't change anything. Then I
> > have tried Using an inverting buffer for two times. By doing this, I
> could
> > keep the SDA and SCL signals. But because of inverting buffer, when a
> data
> > comes from camera, the buffer disorders the signal on SDA. I have pasted
> > my code here. I have used Port1 to initialize and open the PVDD, DVDD,
> > EXTCLK and RESET. Datasheet links for CC430F6137 and TCM8240MD are below.
> >
> > http://www.ti.com/lit/ds/symlink/cc430f6137.pdf
> >
> >
> http://www.sparkfun.com/datasheets/Sensors/Imaging/TCM8240MD_E150405_REV13
> > .pdf
>
> If you intend to do object tracking with this, I think you're going to be
> using an underpowered microprocessor. I have that camera and hooked it up
> to an XMOS XCore device for fun.
>
> I2C communication is only used for the control interface, i.e. to put the
> camera into certain modes. The colour data (frame) is presented over a
> parallel bus, and even at 25MHz, I don't think your MSP430 will have the
> memory to store, performance to acquire, or performance to analyse the
> incoming image.
>
> Just my thoughts.
>
> --
> Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> SolderCore Development Platform http://www.soldercore.com
>
>
>


Hello Fero,
Thanks for your answer. Supply voltages and high-to-low voltage are OK. But I couldn't manage the order of supply voltages. In the datasheet, it says that we should apply firstly PVDD,then DVDD, then EXTCLK, then RESET and finally SDA data. I do this process in this order, but due to the unwritten of max time gap between steps, I do apply these steps manually(out of MSP430 with my hand). I don't know this max time makes any trouble through this process.

--- In m..., Fero Santos wrote:
>
> Hello!
>
> Don't know if this will help, but, let's go:
>
> 1) Link to datasheet is broken. Use this instead:
> http://www.sparkfun.com/datasheets/Sensors/Imaging/TCM8240MD_E150405_REV13.pdf
>
> 2) Usually, SDI and SDO is mainteined in high impedance if the supply
> voltage of the device is not OK. As this device uses 3 diff. supply
> voltages, try to check then all.
>
> 3) According to datasheet, to do a low-to-high transition you need a
> minimum of 0.7 x IOVDD voltage to operate SDI correctly (pg 26). Do you
> guarantee this voltage? Also, check if a high-to-low voltage is guaranteed.
>
> 4) Paul has a good point - I2C is slower than SPI. BUT! This camera
> operates only with I2C mode. *Maybe *filtering/operating with DMAs you can
> do what you intend to do..
>
> Good luck!
>
> Fero
>
> On Mon, Oct 29, 2012 at 6:10 AM, Paul Curtis wrote:
>
> > **
> >
> >
> > Hi,
> >
> >
> > > Hello Everybody, I am from Turkey and I am working on a school project
> > > about object tracking. I have a big problem that I have couldn't solve.
> > If
> > > you can help me, I would be very appreciated.
> > >
> > > My problem is about connecting my MSP430 emulation board with a CMOS
> > > camera. My emuation board is EM430F6137RF900. The camera is TCM8240MD.
> > The
> > > problem is when I connect the MSP430's SDA and SCL pins to the camera,
> > > Suddenly clock and data signals disappear. Initially I had connected pull
> > > up resistors to SDA and SCL pins. But it didn't change anything. Then I
> > > have tried Using an inverting buffer for two times. By doing this, I
> > could
> > > keep the SDA and SCL signals. But because of inverting buffer, when a
> > data
> > > comes from camera, the buffer disorders the signal on SDA. I have pasted
> > > my code here. I have used Port1 to initialize and open the PVDD, DVDD,
> > > EXTCLK and RESET. Datasheet links for CC430F6137 and TCM8240MD are below.
> > >
> > > http://www.ti.com/lit/ds/symlink/cc430f6137.pdf
> > >
> > >
> > http://www.sparkfun.com/datasheets/Sensors/Imaging/TCM8240MD_E150405_REV13
> > > .pdf
> >
> > If you intend to do object tracking with this, I think you're going to be
> > using an underpowered microprocessor. I have that camera and hooked it up
> > to an XMOS XCore device for fun.
> >
> > I2C communication is only used for the control interface, i.e. to put the
> > camera into certain modes. The colour data (frame) is presented over a
> > parallel bus, and even at 25MHz, I don't think your MSP430 will have the
> > memory to store, performance to acquire, or performance to analyse the
> > incoming image.
> >
> > Just my thoughts.
> >
> > --
> > Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> > SolderCore Development Platform http://www.soldercore.com
> >
> >
> >
>
>
>
>

Hello!

You're doing it right. Do the normal flow of inicialization (applying those
voltages). The timming between then is >= 0, this means you shouldn't power
all the lines in the same time (step by step as you're doing is ok). To
send an effective array of data, you must wait 353 ms secs after the power
up flow (as you're doing it by hand, you also guarantee this time).

As all voltages are OK, have in mind that:

When poweruping this type of component, *usually* you don't get a visual
answer, but the *output impedances* will be high* if you did it all OK*. To
check high output impedances, try to generate a DC voltage (with a power
supply) with the max voltage in the same order as the data's voltage you're
sending. Apply this signal to the output of camera's ic. When checking this
output with the scope, if the device properly powered up, you'll see a
voltage in scope lower than the voltage you've actually applied.

If this doesn't happens, device is not in operating mode (all powers are
nok). In this case, re-check all and do the step above.

Another thing: It will be really hard to send I2C data by your hand
(jumping to vcc or gnd)... I2C is a complex communication interface, you'll
have to send bits (data and addrs bits) and also to get bits (ack bits).
Maybe it would be a good idea to implement I2C bus in MSP, get it working
right (lots of examples in Texas page) and then interfacing MSP with the
smoothly working powered-up device.

Good luck!!!

Fero
On Mon, Oct 29, 2012 at 10:17 AM, orhan wrote:

> **
> Hello Fero,
> Thanks for your answer. Supply voltages and high-to-low voltage are OK.
> But I couldn't manage the order of supply voltages. In the datasheet, it
> says that we should apply firstly PVDD,then DVDD, then EXTCLK, then RESET
> and finally SDA data. I do this process in this order, but due to the
> unwritten of max time gap between steps, I do apply these steps
> manually(out of MSP430 with my hand). I don't know this max time makes any
> trouble through this process.
>
> --- In m..., Fero Santos wrote:
> >
> > Hello!
> >
> > Don't know if this will help, but, let's go:
> >
> > 1) Link to datasheet is broken. Use this instead:
> >
> http://www.sparkfun.com/datasheets/Sensors/Imaging/TCM8240MD_E150405_REV13.pdf
> >
> > 2) Usually, SDI and SDO is mainteined in high impedance if the supply
> > voltage of the device is not OK. As this device uses 3 diff. supply
> > voltages, try to check then all.
> >
> > 3) According to datasheet, to do a low-to-high transition you need a
> > minimum of 0.7 x IOVDD voltage to operate SDI correctly (pg 26). Do you
> > guarantee this voltage? Also, check if a high-to-low voltage is
> guaranteed.
> >
> > 4) Paul has a good point - I2C is slower than SPI. BUT! This camera
> > operates only with I2C mode. *Maybe *filtering/operating with DMAs you
> can
>
> > do what you intend to do..
> >
> > Good luck!
> >
> > Fero
> >
> > On Mon, Oct 29, 2012 at 6:10 AM, Paul Curtis wrote:
> >
> > > **
>
> > >
> > >
> > > Hi,
> > >
> > >
> > > > Hello Everybody, I am from Turkey and I am working on a school
> project
> > > > about object tracking. I have a big problem that I have couldn't
> solve.
> > > If
> > > > you can help me, I would be very appreciated.
> > > >
> > > > My problem is about connecting my MSP430 emulation board with a CMOS
> > > > camera. My emuation board is EM430F6137RF900. The camera is
> TCM8240MD.
> > > The
> > > > problem is when I connect the MSP430's SDA and SCL pins to the
> camera,
> > > > Suddenly clock and data signals disappear. Initially I had connected
> pull
> > > > up resistors to SDA and SCL pins. But it didn't change anything.
> Then I
> > > > have tried Using an inverting buffer for two times. By doing this, I
> > > could
> > > > keep the SDA and SCL signals. But because of inverting buffer, when a
> > > data
> > > > comes from camera, the buffer disorders the signal on SDA. I have
> pasted
> > > > my code here. I have used Port1 to initialize and open the PVDD,
> DVDD,
> > > > EXTCLK and RESET. Datasheet links for CC430F6137 and TCM8240MD are
> below.
> > > >
> > > > http://www.ti.com/lit/ds/symlink/cc430f6137.pdf
> > > >
> > > >
> > >
> http://www.sparkfun.com/datasheets/Sensors/Imaging/TCM8240MD_E150405_REV13
> > > > .pdf
> > >
> > > If you intend to do object tracking with this, I think you're going to
> be
> > > using an underpowered microprocessor. I have that camera and hooked it
> up
> > > to an XMOS XCore device for fun.
> > >
> > > I2C communication is only used for the control interface, i.e. to put
> the
> > > camera into certain modes. The colour data (frame) is presented over a
> > > parallel bus, and even at 25MHz, I don't think your MSP430 will have
> the
> > > memory to store, performance to acquire, or performance to analyse the
> > > incoming image.
> > >
> > > Just my thoughts.
> > >
> > > --
> > > Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> > > SolderCore Development Platform http://www.soldercore.com
> > >
> > >
> > >
> >
> >
> >
> >
>