cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 timing application question

jamesdavis9
Associate
Posted on February 05, 2015 at 19:44

The application is to use a STM32F4, but not allow the core to enter any level of ISR at the time it's supposed to service a TIMER interrupt. The application needs the TIMER events to be repeatable down to clock cycle.

S

o, will the following work?

- Have a list of ''things'' to do at certain time intervals (T1, T2, ...Tn).

- Have a main infinite loop running along, interpreting commands it may get in a buffer unrelated to the list. 

- A TIMER is setup to interrupt at T1. Then the INT handler sets a new T2 and restarts the timer. This operation would continue to Tn based on the list.

- The TIMER interrupt  must always have the same overhead, so it can have the same number of clock cycles. 

Is this possible?

28 REPLIES 28
Cristea.Catalin
Associate III
Posted on February 09, 2015 at 19:45

I'm getting confused now:

- What's 24MHz got to do with anything?

- F42x can run timer at 180MHz so I'd say that's a good improvement

- Clock is OCXO. PLL/VCO will introduce jitter but I'd think that should be less than a clock period.  Am I wrong?

- Where does ST have a low profile? On the ST communities forum?

Posted on February 09, 2015 at 22:08

24 MHz is the inflection point for the FLASH behaviour. It's the point where you've pulled enough legs off the spider to ensure it remains static.

I'm used to playing with clocks better than 5 ppb, I'd imagine the PLL/VCO have a whole mess of voltage/temperature/process issues you can't begin to compensate for. I'd suggest you output the internal clock via the MCO (PA8) pin and characterize it as your first order of business.

They have a low profile here, here on this forum, if you are a customer, contact your FAE, or push through your sales/rep contacts. Here you're just amongst the unwashed masses.

''To simplify, let's say I need a precise pulse on one GPIO pin:

 

I write 0x01 to a GPIO port; start the timer, and I need to write 0x00 to that GPIO port after 1000 clock cycles. Not 1001, nor 999.''

Let's not simplify, let's be specific, don't use interrupts to run code to toggle GPIO pins. Program the TIM peripheral to count off core ticks, and have it toggle the pins. Software is bad at this, who has time to cycle tune code, it's very fragile and dependent on things often out of your control. If the TIM peripheral is not capable of the task, consider an FPGA, and codify a synchronous solution in VHDL, and use a 100-200 OCXO directly into it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 10, 2015 at 17:37

Now if you were trying to accurately place a 1PPS signal, for instance, you'd use two timers, one course one to get you close to the event with an interrupt, and a second fine grain one (180 MHz, short duration, 16-bit) to place the edge, based on your understanding of the clock drift, and accumulating clock bias.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 10, 2015 at 18:45

me: I'd imagine the PLL/VCO have a whole mess of voltage/temperature/process issues you can't begin to compensate for.

I'm going to refine that in case it gets misinterpreted. You can measure some things, you can change some of the inputs, but the design is a black box, with very course setting, and a lot of in inaccessible internal states. And you have no die/wafer level parametrization.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Cristea.Catalin
Associate III
Posted on February 12, 2015 at 00:13

I would like to try to use a timer to trigger a DMA from RAM to GPIO.

It looks like only Timer 2 and 5 are 32 bits.

It also looks like they can't trigger DMA2 which is the only one that can do M2M.

Am I wrong or does this mean that I can't use a 32bit timer to trigger a DMA from RAM to GPIO?

Thanks,

Cat
Posted on February 12, 2015 at 00:22

Yes you are right, but you can chain 16-bit timers through their internal interconnect (master - TRGO -> TRGI - slave).

Also, what you want to do is NOT a memory-to-memory transfer, that term as used in the RM refers to the method of starting/triggering the transfer, not to the source-target of the transfer.

JW

Cristea.Catalin
Associate III
Posted on February 12, 2015 at 00:48

If I chain 2 timers: how do I trigger a DMA (or an int or whatever) after, say, 70,000 (>2^16) clocks?

RE: M2M I think that's what they call it; I found no reference to DMA and GPIO anywhere.
Posted on February 12, 2015 at 10:04

> If I chain 2 timers: how do I trigger a DMA (or an int or whatever) after, say, 70,000 (>2^16) clocks?

Have one divide by 1000 and the other count up to 70.

Btw you don't need two timers for this: you can use the prescaler.

> RE: M2M I think that's what they call it; I found no reference to DMA and GPIO anywhere.

From DMA's viewpoint, GPIO in 'F4 is just an AHB slave, but so are memories too, nothing less, nothing more. Read again my comment above and study thoroughly the DMA chapter in the UM. Clive has already posted examples on this forum.

JW
Cristea.Catalin
Associate III
Posted on February 12, 2015 at 17:30

Well Jan we're getting nowhere.

I can't use a prescaler because I want the full resolution.

I can't use the ''divide'' because I need to be able to do any numbers, including prime.

I think you're right about GPIO not being Memory but documentation is somewhat confusing.

Ref. manual says: ''only DMA2 streams are able to perform memory-to-memory transfers'' and in fact you state on another thread that ''GPIO is on AHB, and only DMA2 can perform memory-to-memory transfers'' AND I don't see GPIO listed in any documentation as a DMA anything (master or slave) so I assumed that it's considered a memory.

Posted on February 12, 2015 at 17:58

The prescaler can be changed un the fly, and with preload on, it changes upon update event, so you can change the timer's run from ''coarse'' to ''fine'' for the last ''round''. Or you can run the timer at full speed all the time, counting the rounds in software/interrupt, and switch on the DMA only for the last round. There might be other schemes how to achieve 32- or more-bit counting, but I am not going to explore all the possibilities and find out all the bumps, it's your project after all.

JW