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.

Data transfer between 2 pic microcontrollers using SPI

Status
Not open for further replies.

gravi

Full Member level 2
Full Member level 2
Joined
May 30, 2006
Messages
128
Helped
10
Reputation
20
Reaction score
10
Trophy points
1,298
Location
Hyderabad, India
Activity points
2,452
spi pic

Hi,
I am trying to transfer data between 2 pic micro controllers Microchip PIC18lf8722 and PIClf2525 in which PIC18lf8722 acts as Master and PIClf2525 as Slave. so we have configured them as master and slave and sent some data to slave but data was not received in slave. can any one help me to complete this data transfer.

Thanking you,
Ravi Kumar.
 

pic to pic spi

what are the hardware connections
please send the circuit diagram

and did you ground the SS pin at slave side
 
spi pic to pic

try sending same byte twice because its a type of problem i faced in a circuit where we have to move the data twice so on first the byte will stored in the buffer and the previous ( for first time the garbage) will be transfered ans secondly the data will be transfered

I am not so sure whether it will work for you or not but it works for me
 

pic spi

Hi sau_sol,

I have transmitted data successfully to slave and Thanks for your kind co-operation

Thanking you,
Ravi Kumar Gangumolu
 
spi between microcontroller

can you please tell us the problem so the next person to read this will not repeat the same
 

pic microcontroller spi

hi,
I have used MCC18 compiler library specified spi functions and any way i will shortly post my code and schematic.
 
pic spi slave

Hi,
I have attached my circuit which i have used, Slave select is controlled by master before starting my communication. This is my master and slave spi initiallisations



SPI Initialization with respect to Master (Pic 18F8722)
void InitSPI_Master(void)
{
TRISDbits.TRISD6 = 0; // Define clock pin as output
TRISDbits.TRISD5 = 1; // Define SDI as Input
TRISDbits.TRISD4 = 0; // Define SDO as Output
TRISDbits.TRISD7 = 0; // Define chip select as output

SSP2STATbits.SMP = 0; // Sampled at the Middle
SSP2STATbits.CKE = 1; // Data Transmitted on Falling Edge

SSP2CON1 = 0x22; /* Configures SDo, SDI,SCK and SS pins as serial port pins. Clock idle state Low and FOSC/64 */

INTCONbits.INT0IE = 0; // INT0 External Interrupt Disable bit
INTCONbits.INT0IF = 0;

INTCON2bits.RBPU =1 ; // Disable Pullups
INTCON2bits.INTEDG0 =1; // Interrupt on Rising Edge
}




SPI Initialization with respect to Slave (Pic 18F2525)

void InitSPI_S(void)
{
TRISCbits.TRISC5 = 0; // Define SDO pin as output
TRISCbits.TRISC4 = 1; // Define SDI as Input
TRISCbits.TRISC3 = 1; // Define SCK as Input
TRISAbits.TRISA5 = 1; // Define chip select as Input

SSPSTATbits.SMP = 0; // Cleared in Slave Mode
SSPSTATbits.CKE = 1; // Data Transmitted on Falling Edge

SSPCON1 = 0x24; /* Configures SDo, SDI,SCK and SS pins as serial port pins. Slave mode and SS controlled */

INTCONbits.INT0IE = 0; // INT0 External Interrupt Disable bit
INTCONbits.INT0IF = 0;

INTCON2bits.RBPU =1 ; // Disable Pullups
INTCON2bits.INTEDG0 =1; // Interrupt on Rising Edge
}

 
spi between pic

Hi all!
I have the same problem too.
In my project,dsPIC33F is the Master and PIC18F4550 is the Slave.
I use the oscilloscope to make sure that Master can transmit data correctly.
But the Slave can't recieve data and goto the interrupt.

Then i write a simple timer1 interrupt code to test the interrupt.
My Timer1 still can not goto the interrupt sequence.
I paste the test code.
Plz help me!
===================================================
#include <p18f4520.h>
#include <timers.h>

#pragma config OSC=HS, BOREN=OFF, BORV = 2, PWRT=ON, WDT=OFF, LVP=OFF

#define TMR1_VAL 65536-16384

void Init_TMR1(void);
void timer1_isr (void);

#pragma code high_vector=0x08
void high_interrupt (void)
{
_asm GOTO timer1_isr _endasm
}
#pragma code

#pragma interrupt timer1_isr

void timer1_isr (void)
{
PIR1bits.TMR1IF = 0;
WriteTimer1(TMR1_VAL);
PORTD++;
}

void main (void) {

PORTD = 0x00;
TRISD = 0;
Init_TMR1();
RCONbits.IPEN = 1;
IPR1bits.TMR1IP = 1;
INTCONbits.GIEH = 1;
while (1);
}

void Init_TMR1 (void){

OpenTimer1( TIMER_INT_ON &
T1_16BIT_RW &
T1_SOURCE_EXT &
T1_PS_1_1 &
T1_OSC1EN_ON &
T1_SYNC_EXT_ON );
WriteTimer1(TMR1_VAL);
PIR1bits.TMR1IF = 0;

}
 

Hello,

I'm new to this forum, and I want to make a connection between a SPI PIC18F4520 and a PIC18F2520, and I can not get a correct result.

Have you an example of correct exchange?

Thank you in advance
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top