Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define STM8S105
- #include "features.h"
- void Wait(uint16);
- int main( void )
- {
- TIM3_DeInit();
- TIM3_TimeBaseInit(TIM3_PRESCALER_8, 999);
- TIM3_OC2Init(TIM3_OCMODE_PWM1, TIM3_OUTPUTSTATE_ENABLE, 749, TIM3_OCPOLARITY_LOW);
- TIM3_Cmd(ENABLE);
- uint16 i = 0;
- while(1)
- {
- TIM3->CCR2H = (uint8)(i >> 8);
- TIM3->CCR2L = (uint8)(i);
- Wait(10000);
- i += 5;
- if(i > 999)
- i = 0;
- }
- for(;;);
- }
- void Wait(uint16 l)
- {
- while(l > 0)
- {
- asm("nop");
- l--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment