|
|
View previous topic :: View next topic |
Author |
Message |
mbyes
Joined: 14 Aug 2006 Posts: 4
|
I2C Slave mode with START, STOP Interrupt enable |
Posted: Mon Aug 14, 2006 1:56 am |
|
|
The Microchip PIC16F87XA has got a MSSP module. Bits SSPM(3 downto 0) in
SSPCON register configure the mode of the module. For I2C operation the
following options are available:
1111 = I2C slave, 10bit addressing, with START/STOP interrupts
1110 = I2C slave, 7bit addressing, with START/STOP interrupts
1011 = I2C firmware controlled master mode (Slave idle)
1000 = I2C master mode
0111 = I2C slave, 10bit addressing
0110 = I2C slave, 7bit addressing
I am troubled, whith the "I2C Slave mode, 7-bit address with START and
STOP bit interrupts enabled".
What does this mode do?
Where can I find some helpful documentation about it?
And show me the "I2C SLAVE MODE TIMING (TRANSMISSION, 7-BIT ADDRESS
with START and STOP bit interrupts enabled)"
How to use I2C Start, Stop Interrupt mode?
pls help me.
thank you. |
|
|
Ttelmah Guest
|
|
Posted: Mon Aug 14, 2006 8:13 am |
|
|
The option is whether an interrupt is generated only for the 'data' transaction, or for the two control transactions as well (start/stop).
The latter is useful, if the slave needs to initialise something, when the transaction starts.
Look at the Microchip application notes, which give a lot about using the I2C peripheral, and the Phillips data about the I2C protocol itself.
Best Wishes |
|
|
mbyes
Joined: 14 Aug 2006 Posts: 4
|
answer one's own question |
Posted: Thu Aug 24, 2006 6:01 pm |
|
|
#include <18F452.h>
#fuses H4,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT // High Speed Clock for PLL, No Watch Dog Timer, No Code Protection, No Low Voltage P?, No Power Up Timer
#use delay(clock=40000000)
#use RS232(baud=57600,parity=N,xmit=PIN_C6,rcv=PIN_C7)
#use i2c(slave,sda=PIN_C4,scl=PIN_C3, address=0x30, FORCE_HW)
#byte SSPSTAT = 0xFC7
#bit SMP = SSPSTAT.7
#bit CKE = SSPSTAT.6
#bit D_A = SSPSTAT.5
#bit P = SSPSTAT.4
#bit S = SSPSTAT.3
#bit R_W = SSPSTAT.2
#bit UA = SSPSTAT.1
#bit BF = SSPSTAT.0
#byte SSPCON1 = 0xFC6
#byte PIR1 = 0xF9E
#bit SSPIF = PIR1.3
#priority ext, ssp
BYTE buffer[1490];
BYTE Clkcnt = 0;
BYTE datas;
BYTE I2C_Parsing_Data = 0;
int16 i = 0;
#zero_ram
#int_rda
rda_isr(){
int16 j = 0;
datas = getc();
if (datas == 0xFF){
putc(0xAA);
i = 0;
return;
}
else if(datas == 0xF0)
putc(SSPSTAT);
else if(datas == 0xFA)
{
for(j=0; j<i; j++)
putc(buffer[j]);
for(j=0; j<i; j++)
buffer[j] = 0x00;
Clkcnt = 0;
i = 0;
}
else if(datas == 0xAA)
for(j=0; j<i>= 1489) break;
buffer[i++] = I2C_Parsing_Data;
break;
}
case 9:
{
Clkcnt = 0;
break;
}
default : break;
}
I2C_Parsing_Data <<= 1;
}
#INT_SSP
void ssp_isr(){
SSPIF = 0;
if(S){ // Checking to the Start Condition or Restart Condition
Clkcnt = 0;
return;
}
}
void main(){
SSPCON1 = 0x3E;
enable_interrupts(INT_RDA);
set_tris_b(0xff);
port_b_pullups(true);
ext_int_edge(0,L_TO_H);
enable_interrupts(INT_EXT);
enable_interrupts(INT_SSP);
enable_interrupts(global);
while(1){
}
} |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|