I2C on PSOC 4 BLE pioneer board

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable


I'm trying to use an SCB I2C on the 4200 BLE pioneer board and after doing I2C_Start() it doesn't appear as though the I2C bus becomes "non-busy".  As a result, the first write never succeeds or completes.  The check for bus state below always comes back as busy (I2C_I2C_MSTR_BUS_BUSY).  I've hardwired a sensor onto the pioneer board at P3[0]:sda and P3[1]:scl pins and have those pulled up with external pullups.  I never see those signals driven low on a scope.  It's almost as though an internal status register is keeping the I2C component busy.  Thoughts?

   

 

   


uint32 I2C_I2CMasterWriteBuf(uint32 slaveAddress, uint8 * wrData, uint32 cnt, uint32 mode)
{
    uint32 errStatus;
    errStatus = I2C_I2C_MSTR_NOT_READY;
    if(NULL != wrData)  /* Check buffer pointer */
    {
        /* Check FSM state and bus before generating Start/ReStart condition */
        if(I2C_CHECK_I2C_FSM_IDLE)
        {
            I2C_DisableInt();  /* Lock from interruption */
            /* Check bus state */
            errStatus = I2C_CHECK_I2C_STATUS(I2C_I2C_STATUS_BUS_BUSY) ?
                            I2C_I2C_MSTR_BUS_BUSY : I2C_I2C_MSTR_NO_ERROR;

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

It would be more informative when you post your code instead of the Creator generated code which has proven to be correct. Best is to use Creator->File->Create workspace bundle and then attach the resulting file. Helpful would be a link to your sensor's datasheet.

   

 

   

Bob

View solution in original post

0 Likes
5 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

It would be more informative when you post your code instead of the Creator generated code which has proven to be correct. Best is to use Creator->File->Create workspace bundle and then attach the resulting file. Helpful would be a link to your sensor's datasheet.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Excellent point 🙂

   

Here is the link to the datasheet and the bundle.  Let me know if I didn't send the proper option when bundling.  I appreciate your time.

   

 

   

MPU9150

   

http://www.datasheet4u.com/datasheet/M/P/U/MPU-9150-1_InvenSense.pdf.html

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You make an error when reading data. a complete I2C transaction needs one (and only one!) start and stop.

   

When reading from an I2C register you need to set when writing the register number the MODE_NO_STOP flag, then a read with the MODE_REPEAT_START set.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Bob,  Thanks. I see now that my code trying to build up some functionality for the I2C is incorrect.  Is there a call/library already in the API that reads/writes a register from an I2C device?  It seems strange that I (and everyone else) would have to make our own.  I see in the Datasheet that there is a I2CMasterReadBuf function but that does not seem to comprehend addressing which register would be read (ie. to your earlier point of needing a write transaction with MODE_NO_STOP being performed.

   

uint32 SCB_I2CMasterReadBuf(uint32 slaveAddress, uint8 * rdData, uint32 cnt, uint32 mode);

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

No, there isn't an API that writes to a register and then reads n bytes from a slave. Some of the fun has to be left for us designers.

   

 

   

Bob