Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18f4220

Status
Not open for further replies.

BUSHRATARIQ

New Member
hey i am a beginner in embedded programming. i am trying to make a master slave spi link between two pics, pic18f4220. but i am facing alot of problem.
i am configuring everything fine but there is nothing on my SCK pin of master pic. also there is nothing on my SDO of master pic. and another problem i am facing is that i have connected an led to port b configured as output port. to blink at the start and end of code. its blinking is not visible unless i put a probe on some other pin of port b.
i dont understand why.
Can anyone please help!
 
Hi,

You need to post your program code for both master and slave plus the circuit diagram, otherwise its difficult to see where you have gone wrong
 
Post the inizialization code as well.
 
hey
i am trying to configure only master pic first and separately. the code i am using is

#include<p18f4220.h>
#include<spi.h>
#pragma config WDT=OFF

void main()

{
unsigned char a,m;

TRISB=0;
PORTB=0;

TRISA=0;
PORTA=0x03;

m=0xFF;

PORTAbits.RA0=1;
SSPCON1bits.SSPEN=1;
SSPCON1bits.SSPM0=0;
SSPCON1bits.SSPM1=0;
SSPCON1bits.SSPM2=0;
SSPCON1bits.SSPM3=0;
SSPCON1bits.SSPOV=0;
SSPCON1bits.WCOL=0;

TRISC=0;
SSPCON1bits.CKP=0;
SSPSTATbits.CKE=0;
SSPSTATbits.SMP=0;

while(1)
{
PORTB=0xFF;
PORTAbits.RA0=0;
a=1000;
while(a--);
SSPBUF=m;
PORTAbits.RA0=1;
PORTB=0;

a=1000;
while(a--);

}

The problem with this code is that i dont get anything on the SDO pin and SCK.
 
Status
Not open for further replies.

Latest threads

Back
Top