mscherer / the-bus-pirate

Automatically exported from code.google.com/p/the-bus-pirate
0 stars 0 forks source link

Incorrect SPI1CON1 prescaler values for SPI binary mode with freq >= 2.6MHz #72

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

  1. Start SPI binary mode
  2. Send "set speed command" (0x60) with speed values 5 (2.6MHz) or 6 (4MHz) or 7 (8Mhz)
  3. Send SPI data, measure SPI clock frequency using e.g. oscilloscope

What is the expected output? What do you see instead?
  speed 5 (expected 2.6MHz) -> observed 41kHz
  speed 6 (exp. 4MHz) -> 62kHz
  speed 7 (exp. 8MHz) -> 125kHz

What version of the product are you using? On what operating system?

  Bus Pirate v3.6/v3.5 firmware 5.10
  I'm using libbuspirate to setup SPI speed and send bytes

Please provide any additional information below.

  The reason is the last 3 values of the binSPISpeed array in SPI.c are incorrect
  static unsigned char binSPIspeed[]={0b00000,0b11000,0b11100,0b11101,0b00011,0b01000,0b10000,0b11000};//00=30,01=125,10=250,11=1000khz, 100=2mhz,101=2.667mhz,  110=4mhz, 111=8mhz;

  Those values are 0b01000, 0b10000, 0b11000
  but should be 0b01011, 0b10011, 0b11011

  The last 2 bits select the primary prescaler 0b11 = prescale 1:1 while 0b00 = prescale 1:64

Original issue reported on code.google.com by Bruno.Qu...@gmail.com on 18 Jun 2014 at 3:10