cancel
Showing results for 
Search instead for 
Did you mean: 

LPTIM NOT WORK IN SPECIFIC TIME

jdo
Associate II

hI! I am using the LPTIM, but not work in 486us, the minimum value is 2.6ms. TIM1.JPGTIM2.JPGTIM3.JPG

in the logic analyzer i view:

TIM4.JPG

5 REPLIES 5

How is that waveform generated?

> but not work in 486us, the minimum value is 2.6ms

Why should it "work in 486us"? What does that exactly mean?

JW

"I need it to work with 486 microseconds. The waveform is observed with a logic analyzer, changing the value of the microcontroller pin each time an interrupt is triggered by the timer."

in the next code is:

int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_ADC_Init();
  MX_TIM2_Init();

......................................................................................................................................................................


void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim)
{
	counterTIM++;
	//HAL_GPIO_WritePin(GPIOC, tx_Pin, GPIO_PIN_SET);
	HAL_GPIO_TogglePin(GPIOC,tx_Pin);
}

> changing the value of the microcontroller pin each time an interrupt is triggered by the timer

With 62kHz system clock i.e. 16us per clock, 2.6ms means are around 160 clocks. That's quite the expected value, especially if you use Cube/HAL and perhaps don't switch compiler optimizations on.

JW

Ok, I have a program with a 1MHz clock and the timer is configured with a period of 486. So, I follow the same procedure to measure with the logic analyzer on pin 14, which changes state in the while loop, and the result is 486us. Now, I need to lower the microcontroller's frequency to a minimum of 131kHz, but I need the timer configuration to remain the same, meaning that the logic analyzer should read the output of pin 14 at 486us. Please tell me if I am correct or wrong in my analysis, or if the output on pin 14 will give another value and if the timer is properly configured?

It takes some processor cycles to execute the interrupt. If you use Cube/HAL, it takes more. If you don't switch on compiler optimizations, it takes more.

JW