LPTIM NOT WORK IN SPECIFIC TIME
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-06 11:24 AM
hI! I am using the LPTIM, but not work in 486us, the minimum value is 2.6ms.
in the logic analyzer i view:
- Labels:
-
Functional Safety
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-06 11:45 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-06 12:04 PM
"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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-06 1:48 PM
> 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-15 10:55 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-16 12:04 AM
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
