Encoder and Arduino Uno R2

Hello Everyone,

I am working with Encoder AMT203-V and Arduino Uno R2.

My question might be so simple to you guys but i am confused about clock speed.

I check arduino Uno and it say it has 16Mhz.
http://www.mouser.com/new/arduino/arduinouno/?gclid=CICigYrm7rgCFYuk4AodpgkAfw
I tried checking AMT203-V, it says it uses a PIC16F690. I looked at the PIC datasheet http://ww1.microchip.com/downloads/en/devicedoc/41262a.pdf
I get confused where to look, somewhere in the datasheet it says 20Mhz other it says 4Mhz or 8Mhz.

Anyone can help know what is the Mhz that is used in PIC16F690?

I am trying to do SPI connection between them, but before doing it. I want to understand what is SPI clock and how the above information will help me. SPI.setClockDivider(SPI_CLOCK_DIV32);

Wow! You've set yourself a fair task there!

Perhaps not.

OK, the SPI clock is not related to the CPU clock except that the CPU must be sufficiently fast to handle data at whatever rate is defined by the protocol. The trick here is that firstly, it is the master which generates the clock, so the master may do so at whatever speed it can handle, while the slave must be able to deal with that clock speed. The second "trick" is that the SPI may either be handled (fast) by hardware to a certain extent, as apparently the PIC16F690 implements, or "bit-banged" in software as the Arduino libraries generally do which is much slower but never matters for the "master" because it is after all, controlling (generating) the clock.

So in this case, it does not matter much what the clock speeds of the relative devices (microcontrollers) are, as long as you restrict the speed of the master (the Arduino) implementation of the SPI to whatever (upper) limit is defined in the specs of the AMT203-V and noting the warnings in the app-note that it is not buffered so that there are certain necessary delays between issuing a "command" and extracting a data response.

To the extent that the PIC is (slightly) faster than the Atmel chip, this should give you some leeway.

Study the data-sheets and app-note, figure out just how fast the Arduino libraries are actually going to drive the SPI (I don't know), and see if there is any need to restrict this. I suspect there is not.

NOT what you asked, but you may gleam some insight from an Arduino SPI to Arduino SPI communication, the same logic should apply to the master/slave between AVR and PIC, generally speaking.

http://forum.arduino.cc/index.php/topic,43241.0.html

Ray

This is another very comprehensive web page on SPI: Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino...

Doc

Paul__B:
The second "trick" is that the SPI may either be handled (fast) by hardware to a certain extent, as apparently the PIC16F690 implements, or "bit-banged" in software as the Arduino libraries generally do

AFAIK, the Arduino SPI library uses the AVR's hardware interface. ShiftIn and ShiftOut are a software (bit-banging) implementation though.

As for the SPI clock speed, it's the CPU clock divided by whatever you set with the SPI.setClockDivider() call. Given a 16MHz crystal and SPI_CLOCK_DIV32, you'll get a 500KHz SPI clock.