# A few question on systick

## Recommended Posts

Hello,

I have the EK-TM4C123GXL launchpad and I'm learning to use the systick counter. I have a few questions.

The internal oscillator is 16.0 MHz, so the smallest time unit is 1/16e6 = 62.5 ns.

I have written a program that toggles a the red LED at 5s intervals. The problem is that the values I used do not match the frequency of the internal oscillator :

Number of loops : 15

Theoretical time delay = 15 * 0x00FFFFFF * 62.5ns = 15 * 16777215 * 62.5e-9 = 15.728s

That theoretical time delay is 3 times larger than what I really get !!

More over, when I setup the PLL with different frequencies, I still get the same value !

Where (in a program)  does one change the OSCSRC2 value of RCC2 register (p260 of the datasheet) ? I would like to try PIOSC / 4.

Thanks

main.c

##### Share on other sites

Hi,

The frequency of the internal oscillator doesn't yet determine the actual clock frequency of the CPU - the PLL gets in the mix, too.

From your observation of a 5s interval, I bet your CPU is running at 50 MHz.

Suggest you download TI's TivaWare, then take a look at the source of the SysCtlClockSet function and the documentation as well.

##### Share on other sites

Hello,

I have the EK-TM4C123GXL launchpad and I'm learning to use the systick counter. I have a few questions.

The internal oscillator is 16.0 MHz, so the smallest time unit is 1/16e6 = 62.5 ns.

I have written a program that toggles a the red LED at 5s intervals. The problem is that the values I used do not match the frequency of the internal oscillator :

Number of loops : 15

Theoretical time delay = 15 * 0x00FFFFFF * 62.5ns = 15 * 16777215 * 62.5e-9 = 15.728s

That theoretical time delay is 3 times larger than what I really get !!

More over, when I setup the PLL with different frequencies, I still get the same value !

Where (in a program)  does one change the OSCSRC2 value of RCC2 register (p260 of the datasheet) ? I would like to try PIOSC / 4.

Thanks

You don't use the 16Mhz of the internal oscilator for the math. The SysTick clock is supplied by the system clock.

I have here a code that i use every time i start a project that sets the system tick to interrupt every 1mS, i didn't use the SysCtlClockGet because i think there was a bug with it and i don't know if it's already fixed.

##### Share on other sites

Suggest you either adapt TivaWare, or CMSIS, or some other standard interface/set of names to make it easier for people to help you.

If not going to do either of those, at least document your code really really well (i.e. explain EVERY magic number).

##### Share on other sites

Thank you for your answers. I've finally decided to use library, instead of writing my own code and banging my head to the wall. Much easier and faster ! ;-)

##### Share on other sites

Banging your head against the wall has a very good side effect, you learn a lot and probably you will never forget that.

Simao

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×
• Blog

• #### Activity

×
• Create New...