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 commuication using pic and mikroc

Status
Not open for further replies.

jaycec

Member level 2
Joined
Jul 22, 2010
Messages
51
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
india
Activity points
1,611
HI
PLEASE HELP ME
I am an engineering student trying to learn SPI communication using pic16f877a and mikroc compiler.I wrote 2 codes one for pic spi master that continuously sends digit 3 and another code for pic spi slave that listens to master and makes the RB0 pin high if digit 3 is received.When i simulated it on proteus7.1 i could see the state change of SCK pin and SD0 pin of spimaster but nothing happend at the slave side. i am giving my codes below,please point out the bug or give me some sample code for both master and slave in mikroc.please help me
project settings:(for both master and slave)
mikroc v 6.2.1.0
microcontroller:16f877a
configuration settings default
clock frequency 12mhz
// code for spi master
void main()
{
Spi_Init_Advanced(MASTER_OSC_DIV64,DATA_SAMPLE_MIDDLE,CLK_IDLE_LOW,HIGH_2_LOW);
while(1)
{
Spi_Write(3);
}
}
// code for spi slave
void main()
{
unsigned char buffer,gdata=0x00;
buffer=0x00;
TRISB=0X00;
portb=0x00;
Spi_Init_Advanced(SLAVE_SS_ENABLE,DATA_SAMPLE_MIDDLE,CLK_IDLE_LOW,HIGH_2_LOW);
while(1)
{
gdata=Spi_Read(buffer);
if(gdata==3)
{
portb.f0=1;
}
}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top