cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up a 18 MHz timer

jdcowpland
Associate II
Posted on September 05, 2013 at 17:43

Hi guys,

I've got a stm32f10zg eval board and am trying to set up a timer on it to generate an interrupt at a frequency of 8MHz. I've got the PLL set up a a x9 so that the timer is getting a 72 MHz input clock. I've got my prescaler set to 1, and the arr register set to 8, but the frequency I get out seems to have a maximum of ~800KHz no matter what I try. If i increase the prescaler to 10, I get out an expected 800KHz, and a prescaler of 100 gives me an expected 80KHz and so on. Just can't seem to get past that 800KHz though. Any ideas why? Is it possible that the interrupt is just slowing things down too much?

Ideally I want to be able to set off a DMA transfer at a 8MHz frequency, but just concentrating on the timer just now. If it is the interrupt causing too much lag, is there any way to trigger a DMA transfer from a timer without using an interrupt?

#stm32 #timer #interrupts #wtf
2 REPLIES 2
Posted on September 05, 2013 at 17:53

You can't possibly interrupt at 8 MHz, with a CPU running at 72 MHz you'd have 9 CPU cycles, just stacking CPU context takes 12 or so. Seems to be a lack of grasp about how microcontrollers can function.

I don't think you'd want to interrupt above a couple hundred KHz. At some point you saturate the processor with busy work, and can do nothing useful with it.

You could get a TIM unit to trigger DMA, but again 8 MHz does seem at tad high. To/from what?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jdcowpland
Associate II
Posted on September 06, 2013 at 09:40

Ok yeah see what you mean. Still kind of new to microcontrollers. Basically I'm trying to drive a TFT-LCD display without a controller, so I'm using SRAM as a buffer and then using DMA to transfer the data from the SRAM to the screen. I have all my other signals working fine, but I need a 9MHz clock for the screen. My plan was to have a timer which interrupted on each clock cycle, and which in turn set off dma.