View previous topic :: View next topic |
Author |
Message |
smart277
Joined: 18 Apr 2020 Posts: 1
|
Slave i2c over 128 byte times ? |
Posted: Sat Apr 18, 2020 4:55 am |
|
|
Hi. Sir,
I'm trying to processing slave i2c over 128 Byte times?
but, i have no idea..
Is the read/write limit to 0x7F(127) times at once?
How can i solve this?
Quote: |
#INT_SSP
void ssp_interupt (){
BYTE incoming, state;
state = i2c_isr_state();
if(state < 0x80) //Master is sending data
{
incoming = i2c_read();
if(state == 1) //First received byte is address
Address = incoming;
if(state == 2){ //Second received byte is adddress
Address = (incoming << 8 |Address);
WriteBufferCnt = 0;
if(state >= 3){
WriteBuffer[WriteBufferCnt] = incoming; // For Test
WriteBufferCnt++;
if(WriteBufferCnt > 90)
WriteBufferCnt = 90;
}
}
if(state >= 0x80) //Master is requesting data
i2c_write(buffer_0x94_0x0000_0x0084[Address]); // <===== 0x0080, 0x0081, 0x0082, 0x0083 can not access (wrong data)
Address++;
}
BYTE incoming, state;
state = i2c_isr_state();
if(state < 0x80) //Master is sending data
{
}
else{
}
} |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Sat Apr 18, 2020 4:57 am |
|
|
Please post what I2C device you're trying to use as the 'slave'. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Sat Apr 18, 2020 7:29 am |
|
|
I think he is trying to be the slave.
Yes, the I2C_ISR_State function only supports write or read counts up
to 127/128 bytes. This is common to a lot of hardware I2C devices as well.
For example EEPROM devices commonly support 8, 16, 32, 64 or 128 bytes
maximum in a single transfer.
The solution is the same as for these chips. Send 64bytes, then launch
a new transaction. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1355
|
|
Posted: Sat Apr 18, 2020 8:15 am |
|
|
Another option I have done in the past was make my own state function. I took a look at my chip's assembly code for the CCS state function and it essentially looked at a couple of bits in one of the I2C registers. Based on the value of those two bits, it returned specific value. I just duplicated that code but expanded the state values from 8bits to 16bits to give me more data.
It takes some work, but if you don't want to break up your packets (which has its own logistics problems sometimes), that is an alternative. If you go that route, you'll need to look at the assembly for your chip, try to understand what it is doing and create your own version of that logic, using a larger state type than the original. |
|
|
|