tajiknomi
New Member
So i am working on Synchronous transmission of PIC16fxx to another PIC16fxx in proteus. One PIC act as a master and another as a slave.
Now when the IOC (interrupt on change) RB5 is active, the master will transfer the status of PORTA to Slave-Pic PORT-B.
Now the issue is, when i connect both the PIC MCU (shown in snapshot), the proteus below warns me the (Logic-Contention detect) & program doesn't execute on slave as expected.
I have read the datasheet but i am making some mistake which i don't see now. Kindly help me to determine where am i making a mistake.
Transmitter code (Master PIC)
Receiver Code
**broken link removed**
Thanks
Now when the IOC (interrupt on change) RB5 is active, the master will transfer the status of PORTA to Slave-Pic PORT-B.
Now the issue is, when i connect both the PIC MCU (shown in snapshot), the proteus below warns me the (Logic-Contention detect) & program doesn't execute on slave as expected.
I have read the datasheet but i am making some mistake which i don't see now. Kindly help me to determine where am i making a mistake.
Transmitter code (Master PIC)
Code:
char dummy = 0x00;
void interrupt(){
if (INTCON.RBIF == 1){ // Change interrupt
dummy = PORTA; // MUST Read PORTB, otherwise flag will not clear
TXREG = dummy;
INTCON.RBIF = 0;
}
}
void main()
{
TRISA = 0x0F; // [RA0-RA3] = Inputs , PORTC = Output
TRISB.f5 = 1; // RA5 = Input (Used as IOC (interrupt on change))
ADCON1 = 0x06; // PORTA I/O as Digital I/O
SPBRG = 0x67; // decimal = 103, Baud-rate = 9600 , BRGH = 0
TXSTA.CSRC=1; TXSTA.SYNC=1; TXSTA.TXEN=1; // Master clock from BRG, Synchronous mode, Transmission Enable
RCSTA.SPEN=1; // Enable Serial ports
INTCON=0xC8; // {Global interrupts , PORTB Change interrupt} = Enable
while(1);
}
Receiver Code
Code:
char dummy;
void interrupt(){
if (INTCON.RCIF == 1){ // Recieve interrupt
dummy = RCREG;
PORTB=dummy;
INTCON.RCIF = 0;
}
}
void main()
{
TRISB = 0x00; TRISC=0x03; // PORTB = Output, PORTC [RC6-RC7] = Input
//SPBRG = 0x67; // decimal = 103, Baud-rate = 9600 , BRGH = 0
TXSTA.CSRC=0; TXSTA.SYNC=1; // Slave clock from BRG, Enable Synchronous mode
PIE1.RCIE=1; // Recieve interrupt Enable
RCSTA.SPEN=1;RCSTA.CREN=1; // Enable Serial ports
INTCON.GIE=1; INTCON.PEIE=1; // Global and Peripheral interrupts Enable
PORTB = 0x00; PORTC=0x00;
while(1);
}
**broken link removed**
Thanks
Last edited: