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 Help Needed

Status
Not open for further replies.

YAN-1

New Member
Hi everyone. I have a couple of questions regarding the SPI module in the 16F877.

1- In the datasheets, I read that in the master mode, the SPI clock rate (bit rate) is user programmable to one of the following:
Fosc/4
Fosc/16
Fosc/64
TMR2 output.
This allows a maximum data rate (at 20 MHz) of 8.25 Mbps.
Can someone please explain to me how did they get the 8.25Mbps?!

2- I also intend to connect the PIC to an electronic compass that communicates through the SPI bus. In the datasheets of the compass, it says that the clock signal (SCK) should be such that the high time is 16us and the low time is 22 us. How can I do that?! I thought the clock signal generated by the PIC has a square wave shape with a 50% duty cycle and that it has one of the frequencies listed in the first question above.

Please help. Thanks.
 
1. The Timer2 option is actually Timer2/2. And the timing diagrams show some lead time for putting data in the buffer. So I would guess that it's some fraction of 10MHz.

2. If your device uses the SPI protocol I really doubt that it has strict timing requirements like you suggested. Check the datasheet again...Perhaps those are average, or minimum or maximum values. Yes, the PIC would have a 50% duty cycle.

Mike
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top