Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12687 Discussions

Increasing SPI Clock Speed via Software

Altera_Forum
Honored Contributor II
1,258 Views

Hi, 

 

the SPI core I integrated in my SoPC is set to 400kHz. Now I would like to increase the speed up to 20 MHz. I had to set the clock speed to 400kHz because SD-Cards only support clock speed up to 400kHz during the intialization process. 

 

Anyway, is it possible to chance the speed of the SPI? In the system.h file I found the value of the target clock speed. However, attempting to change the value didn't work for me. 

 

#define ALT_MODULE_CLASS_xSD_SPI altera_avalon_spi#define XSD_SPI_BASE 0x40000000# define XSD_SPI_CLOCKMULT 1# define XSD_SPI_CLOCKPHASE 0# define XSD_SPI_CLOCKPOLARITY 0# define XSD_SPI_CLOCKUNITS "Hz"# define XSD_SPI_DATABITS 8# define XSD_SPI_DATAWIDTH 16# define XSD_SPI_DELAYMULT "1.0E-9"# define XSD_SPI_DELAYUNITS "ns"# define XSD_SPI_EXTRADELAY 0# define XSD_SPI_INSERT_SYNC 0# define XSD_SPI_IRQ 11# define XSD_SPI_IRQ_INTERRUPT_CONTROLLER_ID 0# define XSD_SPI_ISMASTER 1# define XSD_SPI_LSBFIRST 0# define XSD_SPI_NAME "/dev/xSD_SPI"# define XSD_SPI_NUMSLAVES 2# define XSD_SPI_PREFIX "spi_"# define XSD_SPI_SPAN 32# define XSD_SPI_SYNC_REG_DEPTH 2 #define XSD_SPI_TARGETCLOCK 400000u# define XSD_SPI_TARGETSSDELAY "0.0"# define XSD_SPI_TYPE "altera_avalon_spi"
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
524 Views

AFAIK the clock speed in the SPI device is fixed at generation time and can't be changed. You can either make your own SPI master hardware component, or generate two SPI masters with different clock frequencies and connect them to muxes so that you can choose which one to use at run time.

0 Kudos
Reply