+ Post New Thread
Page 3 of 3 FirstFirst 1 2 3
Results 41 to 49 of 49
  1. #41
    Advanced Member level 1
    Points: 2,389, Level: 11

    Join Date
    Jan 2019
    Posts
    442
    Helped
    111 / 111
    Points
    2,389
    Level
    11

    Re: 1MHz Timer Settings at STM32F767

    i am not very familiar with STM32F767

    Quote Originally Posted by uranyumx View Post
    Hello,

    I want to setup a 1MHz timer with STM32F767. I picked TIM4 (APB1 Timer Clock=108MHz; APB1 Peripheral Clock=54MHz) for this purpose, based on my calculation prescaler should be 108-1, and a counter period 2-1. But I get maximum 113.64kHz. So, does anyone have an idea to set as 1MHz?
    please explain notation 108-1 and 2-1 in
    calculation prescaler should be 108-1, and a counter period 2-1.

    please explain your calculation that got you to these values from wherever you started (108MHz or 54MHz ?)



  2. #42
    Newbie level 5
    Points: 1,656, Level: 9
    Achievements:
    7 years registered

    Join Date
    Mar 2011
    Posts
    10
    Helped
    0 / 0
    Points
    1,656
    Level
    9

    Re: 1MHz Timer Settings at STM32F767

    Quote Originally Posted by wwfeldman View Post
    i am not very familiar with STM32F767



    please explain notation 108-1 and 2-1 in
    calculation prescaler should be 108-1, and a counter period 2-1.

    please explain your calculation that got you to these values from wherever you started (108MHz or 54MHz ?)
    fclock_cnt=108MHz/107+1=1MHz
    Counting period=(1+1)*(1/1MHz)=0.2us period

    * I get the formulas from a source book (Embedded Systems by Yifeng Zhu)



  3. #43
    Advanced Member level 1
    Points: 2,389, Level: 11

    Join Date
    Jan 2019
    Posts
    442
    Helped
    111 / 111
    Points
    2,389
    Level
    11

    Re: 1MHz Timer Settings at STM32F767

    Quote Originally Posted by uranyumx View Post
    fclock_cnt=108MHz/107+1=1MHz
    Counting period=(1+1)*(1/1MHz)=0.2us period

    * I get the formulas from a source book (Embedded Systems by Yifeng Zhu)
    so 108MHz/107+1 translates to 108MHz/108 ?
    if so, just use 108, not 107 + 1

    if it isn't 108MHz/108, then it looks like (108/107) + 1 = 1.00934 +1 = 2.00934 ?

    108 MHz / 2.00934 = 53.7488 MHz which could be 54 MHz ?

    counting period = 2/1MHz
    1/ 1Mhz is a period of 1 us
    2 times that is 2 us, not 0.2 us ?

    as i asked before. please explain the notation
    if might be explained in the source book you mentioned.



  4. #44
    Super Moderator
    Points: 8,575, Level: 22

    Join Date
    Jun 2009
    Location
    Japan
    Posts
    1,068
    Helped
    282 / 282
    Points
    8,575
    Level
    22

    Re: 1MHz Timer Settings at STM32F767

    Hello!

    I'm using a F767 right now.
    Are you using STM32 cubeMX? It's close to ideal for your setups, without having to
    calculate everything yourself.

    Now there is something else you might want to take care about. It depends on what you
    want to do with your timer. If you want to DMA data to a slower processor or get for
    example data from ST's MEMS, then it may work fine (I did it for the sampling of 16 parallel
    microphones into memory by using a 3MHz clock).

    BUT: suppose you want to fire an interrupt and do some processing: in this case, be aware,
    that your software has to fit into 108 clocks which is the ratio between the chip clock
    and your timer. And be aware that the interrupt call itself will eat some clocks, so you will
    not have time to do a lot of things.
    If you disable interrupts when entering the interrupt call, and reenable them when leaving,
    then everything will be fine, although probably slower than you want.
    If you don't disable interrupts, then some brownish substances may hit the fan and the processor
    will step on its shoe laces.

    Dora.



    •   AltAdvertisement

        
       

  5. #45
    Newbie level 5
    Points: 1,656, Level: 9
    Achievements:
    7 years registered

    Join Date
    Mar 2011
    Posts
    10
    Helped
    0 / 0
    Points
    1,656
    Level
    9

    Re: 1MHz Timer Settings at STM32F767

    Thank you for your responses!

    Are you using STM32 cubeMX?
    Yes, I am using CubeMX. After configuring the pins and interface, I type the codes in Keil IDE.

    Actually, some of them also recommends the DMA mode of the SPI. But I don't know how I can implement it.

    I use the timer for creating interrupt to control sampling time of an external ADC. Maximum I get 83.3kHz sampling time based on the timer interrupt. My ADC allows maximum 1MSPS rate but I never reach even 100kHz sampling rate.



  6. #46
    Newbie level 5
    Points: 1,656, Level: 9
    Achievements:
    7 years registered

    Join Date
    Mar 2011
    Posts
    10
    Helped
    0 / 0
    Points
    1,656
    Level
    9

    Re: 12 Bit ADC with interfacing SPI in STM32

    Thank you for your responses!

    I did the ADC conversion with timer interrupt control. I get the true values with 50kHz sampling frequency when I compare the results with input signal.

    Now the problem is that I can get maximum sampling rate 83.3kHz. So how can I adjust it 1MSPS rate with in the timer interrupt mode? If I couldn't with timer interrupt, what else can I try?



  7. #47
    Super Moderator
    Points: 262,101, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,804
    Helped
    13926 / 13926
    Points
    262,101
    Level
    100

    Re: 12 Bit ADC with interfacing SPI in STM32

    DMA should work, if you manage to make the SPI interface control the ADC completely (e.g. using no or automatic nCS signal).

    - - - Updated - - -

    P.S. I just noticed that you were maintaining two closely related STM32 threads. You started with a specific question about "1MHz Timer Settings at STM32F767" but ended up asking the same questions in both threads. Thus I merged both threads.

    Forum rules generally suggest to ask related questions in one thread. You see why.



    •   AltAdvertisement

        
       

  8. #48
    Newbie level 5
    Points: 1,656, Level: 9
    Achievements:
    7 years registered

    Join Date
    Mar 2011
    Posts
    10
    Helped
    0 / 0
    Points
    1,656
    Level
    9

    Re: 12 Bit ADC with interfacing SPI in STM32

    In DMA mode,
    *CS should control with hardware output or software control?
    *For controlling sampling frequency, should I again use timer IRQ?



  9. #49
    Newbie level 5
    Points: 1,656, Level: 9
    Achievements:
    7 years registered

    Join Date
    Mar 2011
    Posts
    10
    Helped
    0 / 0
    Points
    1,656
    Level
    9

    Re: 12 Bit ADC with interfacing SPI in STM32

    When I enable the DMA for SPI4, I loose the timer control of the switch. Does anyone have an idea for generating 1MHz sampling rate?



    •   AltAdvertisement

        
       

--[[ ]]--