Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

I2C issue

Status
Not open for further replies.

Salgat

New Member
Currently trying to setup I2C on an ARM (LM3S8962) and running into some issues. I'm pretty confident in my code, but for some reason when I reach the receive part I get completely random information from a source that should always be sending a constant value. Hooking it up to the oscilloscope shows that it does recognize my transmit, as it only responds to its address and also replies with an acknowledge after its address is output. However, when it responds to a receive request it is somewhat random (although sometimes repeats values). In addition, the Acknowledge goes to about 2.5V although since it's between a clock cycle I don't think that is an issue. What also bothers me is that even though it even acknowledges my micro, an error will still be flagged even on a single transmit with no receive, even though on the oscilloscope there seems to be no issue.

Code:
    uint32_t status = I2C0_MASTER_MCS_R;

    if ( txpos < txlen )
    {
        I2C0_MASTER_MDR_R = txbuf[txpos++];
        I2C0_MASTER_MCS_R = (1<<1) | (1<<0);
    }
    else if ( rxpos < rxlen )
    {
        I2C0_MASTER_MSA_R |= (1<<0);
        I2C0_MASTER_MCS_R = (1<<2) | (1<<1) | (1<<0);
        ++rxpos;
    }
    else if ( rxpos == rxlen)
        rxbuf[(rxpos++-1)] = I2C0_MASTER_MDR_R;
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top