1 question
In the following test program, if you remove the '|' from CLK_CKDIVR |= 0x08; in the Init_CLK() function, the TIM1 function is the same as the preset (10ms interrupt), but the TIM2's PWM frequency becomes higher. If added, the function of TIM2 is the same as the pre-setting (1Hz PWM is generated), but the period of TIM1 becomes longer;
A lot of tests were tried and they were invalid (the same is true for the purchased development board and the other gs self-pad testing).
2 try
Because the STM8S uses the internal 16M high-speed RC oscillator by default and divides by 8, the system starts the master clock at 2M. That is, if CLK_CKDIVR = 0X18;, if the CLK_CKDIVR |= 0X08; CLK_CKDIVR = 0X08; then the main clock is still unchanged 0X18, but if the assignment CLK_CKDIVR = 0X08;, the main clock will change to become 8M. However, the Fmaster clocks of TIM1 and TIM2 should be the same. Such an assignment should have an impact on both TIM1 and TIM2. However, the two assignments are different and the configuration of the functions is correct. Only one of them can work according to the preset. It is how it happened?
When the setting is CLK_CKDIVR = 0X08 (8M), the TIM1 can work according to pre-settings, but the operating frequency of the TIM2 is obviously fast, like twice as fast. With this discovery, I will use the current TIM2 Fmaster clock. The frequency is doubled as TIM1, namely 16M, go and reconfigure the register of TIM2 again, compile, download into the one-chip computer, actually and TIM1 realizes the same function. What is going on here? Does the TIM2's Fmaster clock always double the TIM1's Fmaster clock? Try several different CLK_CKDIVRs again (of course the TIM1's Fmaster frequency cannot exceed 8M).
Next tested CLK_CKDIVR = 0X10; (4M), CLK_CKDIVR = 0X18; (2M) is the same. Whether it is conjecture or not, I still don't understand what is going on. Looked at the clock tree of STM8S also cannot understand.
3 test procedures
KENNEDE ELECTRONICS MFG CO.,LTD. , https://www.axavape.com