Search
 
SCRIPT & CODE EXAMPLE
 

ASSEMBLY

smt32f429 timer free running

TIM_TimeBaseInitTypeDef SetupTimer;
/* Enable timer 2, using the Reset and Clock Control register */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

// Get the clock frequencies
RCC_ClocksTypeDef RCC_Clocks;
RCC_GetClocksFreq(&RCC_Clocks);

SetupTimer.TIM_Prescaler = (RCC_Clocks.PCLK2_Frequency/1000000) - 1; // Prescale to 1Mhz
SetupTimer.TIM_CounterMode = TIM_CounterMode_Up;
SetupTimer.TIM_Period = 60 - 1; // 60 microsecond period
SetupTimer.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseInit(TIM2, &SetupTimer);
TIM_Cmd(TIM2, ENABLE); // start counting by enabling CEN in CR1 */
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); // enable so we can track each period
int count = 0;
while(1){
  if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
  {
  	TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
  	count += 1;// Insert your 60 microsecond event here
  }
}
Comment

PREVIOUS NEXT
Code Example
Assembly :: google appscripts cell get background color 
Assembly :: links in markdown 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: popper.js cdn 
Javascript :: jquery remove readonly 
Javascript :: js on page ready 
Javascript :: datatables remove pagination 
Javascript :: npm install gatsby cli 
Javascript :: jquery redirect 
Javascript :: refresh window js 
Javascript :: JavaScript that executes after page load 
Javascript :: WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jquery 
Javascript :: jquery check if element exists 
Javascript :: javascript replace all space 
Javascript :: vuex-module-decorators rawError globally 
Javascript :: change input placeholder text jquery 
Javascript :: implode js 
Javascript :: install expo cli mac os 
Javascript :: react native rotate 
Javascript :: how to get the selected text of dropdown in jquery 
Javascript :: remove property mongodb 
Javascript :: javascript import jquery 
Javascript :: colored console.log 
Javascript :: get random number with min and max 
Javascript :: update version of node gyp 
Javascript :: get current formatted time in javascript 
Javascript :: 1 line unique id 
Javascript :: js timer reload page 
Javascript :: boxshadow in react native 
Javascript :: how to install react in windows 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =