Wanna some tutorials on spi

Status
Not open for further replies.

hayee

New Member
Hi everyone,
i want some tutorials on spi in C.i am using two pic16f877a controllers.any simple tutorials like blinking leds.i have no concept of spi.please help me out if u guys have any information.
Thanx
 
This is a Micorchip reference. It's in assembler but it's a good overview on the SPI interface of PICs. If you understand how SPI works, it should be trivial to re-write the routines in C.
 
Last edited:
Thankx eng1.
I have already seen that file but i cant understand this.plz give me other links that r in C.i have no knowledge of assembly
 
Here's the Master asm code (page 32 of this) in C18.
Code:
void main(){
unsigned char Count=0;
unsigned char Dummy;
    TRISA=0;
    ADCON1=0x06;
    TRISC=0x10;
    SSPSTAT=0x40;
    SSPCON=0x31;
    while(1){
        LATAbits.LATA2=1;
        SSPBUF=Count++;
        while(!SSPSTATbits.BF);
        Dummy=SSPBUF;
        LATAbits.LATA2=0;
        DelaymS(100);
    }
}

By comparing the two, you should be able to convert the slave code as well.

Mike.
 
hayee said:
Hi everyone,
i want some tutorials on spi in C.i am using two pic16f877a controllers.any simple tutorials like blinking leds.i have no concept of spi.please help me out if u guys have any information.
Thanx
Here is a link for **broken link removed**.. It covers nearly everything to do with PIC programming, from turning ON and OFF LED to UART to SPI to LCD and others..

Hope that helps..
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…