This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SW-EK-TM4C1294XL: SPI clock not running at specified frequency

Part Number: SW-EK-TM4C1294XL
Other Parts Discussed in Thread: EK-TM4C1294XL

Dear Sirs

I'm using the EK-TM4C1294XL as a master unit to communicate with a embedded pressure sensor that I'm developing.  To get started, I'm using the example project spi_master.  The EK-TM4C1294XL has a 25MHz crystal.  The system clock is set as follows using the TIVAWare peripheral driver library;  ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_OSC), 25000000);  The SOI clock is set as follows; SSIConfigSetExpClk(SSI0_BASE, ui32SysClock, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 8);  When I run the program in the debugger and look at the SSI_CR0 and SSI_CPSR registers, the following are their values; SSI_CR0 = 0x00000B07 and SSI_CPSR = 00000002.  According to the equation, this equates to 1.042MHZ.  However, when I look at the clock with the scope, I see a 675.7MHz clock.  To get a 1MHZ clock, I have to set the SSI_CR0 = 0x00000707.  This SSI_CR0 value equates to 1.56MHZ.  I read a similar post of this issue for a different uC.  He had a 40MHZ system clock and was trying to get a 16MHZ SPI clock.  I can see this was not going to work out.  However, in my configuration, it seems to me that I should get the frequency as calculated.  Could you please shed some light on this issue?  Thank you.

  • Hi,

    However, when I look at the clock with the scope, I see a 675.7MHz clock.

      Do you mean 675.7KHz or really 675.7MHz?  With your setting I see 666KHz on the scope rather than hundreds of MHz range. I do notice the same that in order to get to 1Mhz using MOSC as the clock source, I need to set SSI_CR0 to 0x707. I will need to do some investigation. I cannot find any errata that explains this behavior. But if I use the PLL as the source clock as follows then I can clearly see 1Mhz SPICLK. In the meantime, can you try using PLL as the clock source if you want to get to 1Mhz. 

    ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL), 120000000);

    SSIConfigSetExpClk(SSI0_BASE, ui32SysClock, SSI_FRF_MOTO_MODE_0,
    SSI_MODE_MASTER, 1000000, 8);

  • Charles

    Sorry for the typo.  Yes, I meant 675.7KHz.  I will try the PLL configuration and get back to you.  Thank you.  

  • Hi Dennis,

      Sorry, I meant the following code for using PLL as the source clock. 

    ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_240), 120000000);

  • Charles

    I get a compiler error "Description Resource Path Location Type
    #20 identifier "SYSCTL_CFG_VCO_240" is undefined Test1.c /Test1 line 181 C/C++ Problem".  What file is this parameter defined? 

  • Dennis,

      Are you using the latest TivaWare version 2.2.0.295? If you are using the previous version such as 2.1.4.178 then you need to use SYSCTL_CFG_VCO_480. 

  • Charles

    Thank you. that works.  I get a 1MHz SPI clock now.  I'm using version 2.1.4.178.  Are there any significant advantages going to the latest version of TIVAWare?  What are the backward compatibility issues?  

  • Hi Dennis,

      In the latest TivaWare version 2.2.0.295 we fixed a few bugs and added quite a few examples to the library. As far as SYSCTL_CFG_VCO_240 vs SYSCTL_CFG_VCO_480 they are identical in terms of their definition. There was actually an issue in the older version where SYSCTL_CFG_VCO_480 actually means 240Mhz for the VCO with the value of 0x F1000000. The later version tries to reflect the actual VCO frequency used. 

  • Charles

    I just received your post as I was writing this post.  I looked at the "TIVAWare Peripheral Driver Library User's Guide" and saw no "SYSCTL_CFG_VCO_240" reference.  I think the guide needs to be updated.  Do you think the latest version of the TIVAWare will address my original issue?

  • Hi Dennis,

    I looked at the "TIVAWare Peripheral Driver Library User's Guide" and saw no "SYSCTL_CFG_VCO_240" reference.  I think the guide needs to be updated.

      You are correct. The latest TivaWare Peripheral Driver Library User's Guide misses mentioning SYSCTL_CFG_VCO_240. I will update it in the future if a new release of TivaWare is warranted. 

    Do you think the latest version of the TIVAWare will address my original issue?

    No, I don't think so. I have gone though the  SSIConfigSetExpClk API source code and I don't see an issue. I tried using PLL, MOSC and PIOSC as the source clock to SSI module. Only when MOSC is used as the source clock to the SSI module will SPICLK produced in an unexpected baudrate. PLL and PIOSC are both fine. However, as I said earlier, I cannot find any errata that mentions this behavior. I will investigate a bit more next week. If you must use MOSC as the source clock, please use 0x707 as you have already tried for SSI_CR0 as a workaround. 

  • Charles

    Thank you for all your help.  I think using the PLL is the best approach.