title: PIC 18F46K22 SPI speed
body: <p>I am using PIC 18F46K22 in SPI master mode to communicate with an ADC chip. The FOSC frequency is 64MHz(external 16MHz crystal with PLL on) so based on the PIC manual the maximum SPI speed should be FOSC/4 = 16MHz. But when I use SPI to send 8-bit data it takes around 1.6us to be sent. That means the SPI speed is only around 5MHz. My compiler is MicroC PRO for PIC and I have engaged SPI library functions for initializing and reading data via SPI. Can anyone help me with this issue please?</p>
  
  <p>This is how I initialized SPI1:</p>
  
  <pre><code>SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_END, _SPI_CLK_IDLE_HIGH, _SPI_HIGH_2_LOW);
  </code></pre>
  
  <p>and these are the code lines to read data via SPI:</p>
  
  <pre><code>Take1 = SPI1_Read(0);  // MSB of ADC shift register
  Take2 = SPI1_Read(0);
  Take3 = SPI1_Read(0);  // LSB of ADC shift register
  </code></pre>
  
  <p>I used external crystal(HS oscillator). I did the corresponding settings in "Edit Project" section of the MikroC PRO sotfware(Oscillator Selection:HS oscillator(high power>16 MHz), 4X PLL Enable: Enabled).</p>