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.

SPI Write Buffer Timing

Status
Not open for further replies.

Suraj143

Active Member
Want to know the time takes (Cycles) after loading the 1st SSP1BUF to the next SSP1BUF.....

Thanks

Code:
            ;SPI Clock = 1.5uS (Period)
                          ;Instruction Cycle = 250nS
              
                movwf     SSP1BUF         ;Previous Write to SPI
                ;
                ;From Here Needs the timing to next SSP1BUF
                ;
                movf     INDF0,W
                call     Table_2
                movlb     .0                 ;switch to Bank0
                btfss     PIR1,SSP1IF     ;Has the byte been sent
                goto     $-1             ;No
                bcf     PIR1,SSP1IF
                movlb     .4                 ;switch to Bank4
                movwf     SSP1BUF         ;Time ??             
              
Table_2         addwf    PCL,F
                retlw    00h
                retlw    .1
                retlw    .10
                retlw    .8
                retlw    .16
                retlw    .53
                retlw    .2
 
It will be the eight clock cycles... But multiply by which ever FOSC /? you have used in the SSPCON1 register.. Most of us just poll the SSPIF flag, that tells you when its done. ( clear it first before filling SSPBUF..)

edit** I see you have done that!!
 
Ok. For example for 8 bits if it takes 12uS time I have to wait 12uS time after I load it to SSPIBUF? In other words I have to poll until 12uS time?
 
Ok. For example for 8 bits if it takes 12uS time I have to wait 12uS time after I load it to SSPIBUF? In other words I have to poll until 12uS time?
no.. just wait for the flag.. You're code snippet has this already..
 
Ya I know I have to wait until Flag Occurs.What I mean was the flag will occur after 12uS time after I loaded to SSP1BUF!!
 
what have you set SSPCON1 to.. FOSC / what?

The way you have it is :-

Is the last byte gone?
Yes. Send next one
No. wait a bit

I do it the other way round as I want what has come:-

clear flag
Put byte in buff
wait for flag
return whats come back...

Then you get full duplex..
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top