- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an I2C slave and an I2C master instantiated on a CY8C42 processor. I have the SDA/SCL pins tied together with a 2200 ohm pullups to 3.3v. externally.
The pins that are being used are P3.0-P4.0 and P3.1-P4.1. I have set up the slave for an address of 0x58 and using the same address in a send start command, I can visually see the address go out but the slave does not acknowledge the transmission.
Code snippets are as follows:
Slave initialization:
// initialize the TX/RX buffer
I2CSlave_I2CSlaveInitReadBuf( anTxBuffer, MAX_XMT_BUFFER_SIZE );
I2CSlave_I2CSlaveInitWriteBuf( anRxBuffer, MAX_RCV_BUFFER_SIZE );
// initialize the SBC_I2C
I2CSlave_Start( );
// set the interrupt handler
I2CSlave_SetCustomInterruptHandler( LocalIrqHandler );
// force an address ( added just in case )
I2CSlave_I2CSlaveSetAddress( 0x58 );
// enable the interrupts
I2CSlave_SetSlaveInterruptMode( I2CSlave_INTR_SLAVE_I2C_ARB_LOST |
I2CSlave_INTR_SLAVE_I2C_NACK |
I2CSlave_INTR_SLAVE_I2C_ACK |
I2CSlave_INTR_SLAVE_I2C_WRITE_STOP |
I2CSlave_INTR_SLAVE_I2C_STOP |
I2CSlave_INTR_SLAVE_I2C_START |
I2CSlave_INTR_SLAVE_I2C_ADDR_MATCH |
I2CSlave_INTR_SLAVE_I2C_BUS_ERROR );
// enable the intrrupt
I2CSlave_EnableInt( );
Master initialization and transmission:
// start the I2C
I2CMaster_Start( );
// for debug only
uStatus = I2CMaster_I2CMasterClearStatus( );
uStatus = I2CMaster_I2CMasterSendStart( 0x58, I2CMaster_I2C_WRITE_XFER_MODE );
if ( uStatus == I2CMaster_I2C_MSTR_NO_ERROR )
{
// now send a byte
uStatus = I2CMaster_I2CMasterWriteByte( 0x1E );
if ( uStatus == I2CMaster_I2C_MSTR_NO_ERROR )
{
}
}
The first usuable status on send start returns a 0x0002.
Any ideas would be appreicated.
Solved! Go to Solution.
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have a good look at you oscilloscope diagram. Before starting i2c communication, SDA and SCL must be high. START condition just means SDA goes low while SCL stays high. I dont see that in your diagram.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum!
Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Additional question: What board do you use? Self made?? Cypress Kit?? Which one???
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You do not sent an I2CMaster_I2CMasterSendStop(), so your
else if ( uIrqSource & I2CSlave_INTR_SLAVE_I2C_WRITE_STOP )
is never executed.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I understand I2C, there should have been an ACK received on the start command. This returned an error of 0x0002 which means the address byte was not nacked. sending the stop afterward is redundant. I have scope pictures which indicate that the bus was idle, a start was issued the address byte was sent out but was not acked by the slave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Check the p3_1 connection, the slave is not pulling low the line. Check the pin with a separate program if it can pull the resistor low.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As a generic GPIO pin, it can pull the 2200 resistor to ground.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, of course, but what I wanted to say is: Has P3_1 a defect and is no longer able to work as required or toes the pin act normally in the same environment? Make a new project, set the pin to "Open Drain, drives low", toggle the pin with a PWM and see if the levels are correct. Use the same board as before with your resistors applied.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have a good look at you oscilloscope diagram. Before starting i2c communication, SDA and SCL must be high. START condition just means SDA goes low while SCL stays high. I dont see that in your diagram.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Paddy, what do you think may be the reason for the missing start (except bad trigger)
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The start is not missing, just the way it was triggered.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have verified the operation of the Master instantiated in the design with another slave device. I have also tested the instantiated slave with an external master. The problem remains that the slave does not acknowledge it's address. The pin is capable of being pulled low when set as general purpose pin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, I got it to work, I found a bent pin on the header that takes the plug in board.
I have another question, according to the documentation, I can write a custom interrupt handler and process the interrupts that I am interested in and the normal interrupt handler is then processes it as well such as buffer commands. I am only interested in knowing when a full buffer has been received. If I use the poll method, I get the message into the buffer and everything works okay.
However, if I use the interrupt method, I get the interrupt on complete, however, there is no data in the buffer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not able to deduct what exactly you are doing and what not works as expected. Can you please post a complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Wouldn't be too bad also, when you start a new thread in a PSoC4 forum with a new heading. More forum members will look at it.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>> Paddy, what do you think may be the reason for the missing start (except bad trigger)
I dont know, I dont have a crystal ball. It could be as you suggested, could also be a hardware problem around the microprocessor which is overlooked.
Edit : (Sorry I didnt see the thread was allready continued on page 2)