AnsweredAssumed Answered

Combining Input Capture, One-Pulse Mode, and Reset Mode

Question asked by naphtali on Oct 7, 2014
I am using an STM32F407xx.

My setup is that I have TIMa triggering TIMb. Here is a description of the behavior that I want:

TIMa:
Don't care. This part looks to be working in my application.

TIMb:
       
  1. When we get a Trig:   
             
    1. Capture the current value of TIMb->CNT into CCR1
    2.        
    3. Reset TIMb->CNT to 0.
    4.        
    5. TIMb should start counting again from 0.
    6.    
       
  2.    
  3. If TIMb->CNT == TIMb->ARR,   
             
    1. Stop Counting
    2.        
    3. Fire an interrupt
    4.        
    5. When we get another Trig:       
                   
      1. Capture TIMb->ARR into TIMb->CCR1
      2.            
      3. Reset TIMb->CNT to 0
      4.            
      5. TIMb should start counting again from 0.
      6.        
             
    6.    
       
How can I accomplish this?

Here is what I have found so far:
       
  1. Setting the TIMb trig source will allow it to react to TIMa
  2.    
  3. Setting up CC1 as an input capture will allow the trigger to capture the current timer value
  4.    
  5. Setting the TIMb in Reset slave mode will set TIMb->CNT = 0 every trigger
  6.    
  7. I have been unable to get the stopping at TIMb->CNT == TIMb->ARR part to work   
             
    1. My initial plan was to use the timer one-pulse mode       
                   
      1. I wanted this to do the timer stopping
      2.            
      3. This does not appear to let the CC1 channel function properly
      4.            
      5. I experimented with the URS and UDIS bits to no avail.
      6.        
             
    2.    
       
Any pointers here?

Outcomes