Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SPI Communication between two PIC microcontroller

Status
Not open for further replies.

vinothksr08

Member level 3
Member level 3
Joined
Jun 18, 2013
Messages
66
Helped
7
Reputation
14
Reaction score
7
Trophy points
8
Location
Tamilnadu, India
Visit site
Activity points
367
dear friends i have completed the program for SPI communication between two PIC IC's... but i didn't get output... i have attached my coding with Proteus design please help me to complete my code.
 

Attachments

  • untitled.JPG
    untitled.JPG
    130.3 KB · Views: 287
  • Slave.txt
    344 bytes · Views: 243
  • Master.txt
    605 bytes · Views: 206

Hello there,

Actually what is your project.? Are using master-master communication or master slave communication?

Best regards,
 

Hello there,

Actually what is your project.? Are using master-master communication or master slave communication?

Best regards,

sorry... actually am trying to do simple master to slave communication
am giving input in master and going to get that in slave....
thank u...
 

Hello there,

That is great. I hope master communication is fine in your code .but in your slave pic section you should use some receiver (spi ) interrupt.

Try these links and update me.

http://www.microchip.com/forums/m649226.aspx

http://www.microchip.com/forums/m505515.aspx

http://microchippiclessons.blogspot.in/2009/06/spi-tutorial.html

http://www.microchip.com/forums/m465519.aspx

http://www.ermicro.com/blog/?p=1846

http://embeddedcodesource.com/developer/microchip_technology_59/spi_slave


Best regards,

- - - Updated - - -

please check out this thread

https://www.edaboard.com/threads/293751/
 

hai

now am confused.!!!! i dont know what type of interrupt have to used in receiver side. and also i have to clear that my circuit is correct or not....
 

You can do like this. Use INT0 pin of slave to detect external interrupt. Let RD0 send a 1 to INT0 of slave. After slave detects 1 at INT0 then it will start sending or receiving data to/from master. implement SPI send or read code of slave inside ISR.
 

Attachments

  • pic18 global interrupt6.bmp
    1.3 MB · Views: 178
  • pic18 global interrupt.bmp
    1.4 MB · Views: 164
  • pic18 global interrupt2.bmp
    1.5 MB · Views: 152
  • pic18 global interrupt3.bmp
    1.3 MB · Views: 147
  • pic18 global interrupt4.bmp
    1.3 MB · Views: 158
  • pic18 global interrupt5.bmp
    1.6 MB · Views: 150
Hi there,
I attach for you SPI working example, one master and three slave mcu...
regards
 

Attachments

  • SPI working example.rar
    107.6 KB · Views: 241

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <p18f452.h>
void SSP_ISR();
#pragma interrupt chk_isr
void chk_isr()
{
    if(PIR1bits.SSPIF==1)
       SSP_ISR();
}
#pragma code MY_HiPrio_Int=0x08
 
void MY_HiPrio_Int()
{
    _asm
     GOTO chk_isr
     _endasm
}
#pragma code
void main()           
{
unsigned char input;
SSPSTAT =0x40;        
SSPCON1=0x25;  
IPR1bits.SSPIP=1;
PIE1bits.SSPIE=1;
TRISCbits.RC3=0;
TRISCbits.RC4=1;
TRISCbits.RC5=0;
PORTC=0;      
TRISB=0;
PORTB=0x0f;
TRISAbits.RA5=1;       
}
void SSP_ISR()
{
while(SSPSTATbits.BF); 
PORTB=SSPBUF;
SSPSTATbits.BF=0;
    }



Its my new receiver code.... till i have same problem..., i have searched for many example codes.. but all of them using the inbuilt SPI functions... but i want to do it using C18 Compiler without MicroC Functions.
 
Last edited by a moderator:

Hello there,

Instead of spi receiver interrupt you could use external interrupt module .So external interrupt would monitor the chip select pin from master and you could get data in external interrupt service routine .


Try and Update me.

Best regards,
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top