ie.: 100 Hz we need
168 Mhz is the chip
168 000 000 / 100 = 1 680 000
it means every 1 680 000 cpu cycles the SysTick interrupt is generated.
for audio, try to generate interrupt for a C8 notewhich is 4186.009Hz.
ie.: 4186.009 * 2 = 8372,018; interrupt is generated for each change in the cycle, there are two changes, from HIGH to LOW or LOW to HIGH.
168 000 000 / 8372 = ~20067
each 20067 cycles the cycle toggle is invoked.
what would be the most optimal irq frequency up to C9 which is 8372, resp. 16744? the count for this note is 10033 cyces the interrupt is invoked. what is the optimal count of cycles between the interrupt, taking into account the interupt routine also takes cycles?
rough quess: arm does single ol half of the instruction per cycle. cpu needs to run the user program as well at least for the same as it spends with the intr. also we need some spare time to make sure we will not be missing an interrupt.
1000 * x = 168 000 000
x = 168 000
168 000 times per second we will generate the interrupt. for that number the uint16_t type for the counter var is too small, uint32_t with 4,294,967,295 is enough.
168 000 / 16 744 = 10.003
but the glitch is, the higher frequency we generate, the more it will be inaccurate because of division error. that's why Juno 106 has 1 Mhz / 1 000 000 timer. such precision we can't reach that way.
to have 1 000 000 interrupts (better would be 2 000 000) per sec we wil need the interrupt to be generated each 168 (better 84) cycles. irq routine then has to be cleared out in 84 (42) cycles which obviously will not until rewritten in asm.
a better way how to solve this is to use the independent irq with pulse modulation on a chip.
some reading:
http://www-micrel.deis.unibo.it/LABARCH ... 2/lab4.pdf
http://amarkham.com/?p=29
https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FWhat%20difference%20between%20setting%20TIM_TimeBaseStructure.TIM_Prescaler%20and%20%20TIM_PrescalerConfig&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=256
http://visualgdb.com/tutorials/arm/stm32/timers/
http://myembeddedtutorial.blogspot.cz/2 ... imers.html
http://code.google.com/p/andrei-develop ... ain.c?r=34
[ add comment ] ( 4 views ) | [ 0 trackbacks ] | permalink | related link