electroman2000
Member level 2
- Joined
- Feb 3, 2015
- Messages
- 44
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 8
- Activity points
- 496
Hi, I have a problem with SPI speed on PIC32. I'm using a PIC32MX795F512, mounted on testing board "EasyPIC Fusion v7" from mikroelettronica. So I can execute a physical debug, with timer and pheripherals response ecc. So, of course, I use mikroC for programming this PIC.
I write a series of byte in the SD card using the MMC library of mikroC. For a maximum speed, I'm writing on sector.
The problem is that the SPI doesn't reach the max speed allowed. In the data sheet the max speed is 25 Mbps, so about 3 MBps (the SD is a SDHC with a min speed of 10 MBps ). In mikroC, I set PBCLK=SYSCLK, and divider=8, where SPI_clock=PBCLK/divider. So, because SYSCLK is 80 Mhz, the calculated speed is 80/8=10 Mbps = 1,25 MBps.
If I count, with a timer, the time for writing a given package of byte, I obtain the actual speed is 156 kBps. You can notice that 156 kBps*8=1,25 Mbps. So I have a divisor factor 8, but I don't know when it come from.
In the debug mode I check every register involving the PBCLK speed, the divisor to obtain the SPI clock and all values are ok. Also I check if the timer counter is right, confronting it with the chronometrous of my smarthpone, and it is.
Can you help me?
I write a series of byte in the SD card using the MMC library of mikroC. For a maximum speed, I'm writing on sector.
The problem is that the SPI doesn't reach the max speed allowed. In the data sheet the max speed is 25 Mbps, so about 3 MBps (the SD is a SDHC with a min speed of 10 MBps ). In mikroC, I set PBCLK=SYSCLK, and divider=8, where SPI_clock=PBCLK/divider. So, because SYSCLK is 80 Mhz, the calculated speed is 80/8=10 Mbps = 1,25 MBps.
If I count, with a timer, the time for writing a given package of byte, I obtain the actual speed is 156 kBps. You can notice that 156 kBps*8=1,25 Mbps. So I have a divisor factor 8, but I don't know when it come from.
In the debug mode I check every register involving the PBCLK speed, the divisor to obtain the SPI clock and all values are ok. Also I check if the timer counter is right, confronting it with the chronometrous of my smarthpone, and it is.
Can you help me?