2022-01-05 01:40 AM
I am a newbie into the world of embedded systems.
is it possible to enable clock for ADC and TIM4 overflow update.
```
CLK_DeInit();
CLK_LSICmd(DISABLE); // Use internal clock.
CLK_HSICmd(ENABLE);
while(CLK_GetFlagStatus(CLK_FLAG_HSIRDY) == FALSE); // Wait for clock to stabilize
CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, ENABLE);
```
Last 2 lines are confusing me. I guess this code make TIM4 working and not ADC.
pls help me.
2022-01-11 02:24 AM
Hello,
Last two lines are enabling clock from the data bus to the peripheral registers. It should be done before any write/read attempt to those peripherals registers. In STM8L devices most of the peripherals has been disconnected from the bus clock to limit the current consumption. Then it is up to the user to connect clock to the peripheral prior its configuration. This technique is called 'Peripheral clock gating". You can find more information within application note AN3147, point 4.4:
Additionally you can have a look at point 9.7 within reference manual RM0031:
Best Regards,
Artur Iwanicki,
/STMicroelectronics/
2022-01-15 11:45 AM
Hello,
Really thank you very much @Artur IWANICKI . I was in a confusion that only one peripheral should only be connected to the clock at a time. Now the confusion is over, I really need a time counter of 2ms and ADC to work simultaneously.
Your answer helped me a lot.
Regards,
Vivek