![]() |
stm8/ #include "mapping.inc" #include "stm8s_conf.inc" segment 'rom' BRES PB_DDR,#7 ;input BSET PB_CR1,#7 ;Pull-up BSET PB_CR2,#7 ;with interrupt BSET EXTI_CR1,#2 ;01: Rising edge only BRES EXTI_CR1,#3 LD A,#$CC LD IWDG_KR,A LD A,$55 LD IWDG_KR,A LD A,$2 LD IWDG_PR,A LD A,$FF LD IWDG_RLR,A MOV IWDG_KR,#$AA …… |
int i = 0; unsigned char uc = 0; unsigned long Temp; ADC_CR1 |= 0x01; i = 6; while(i--); ADC_CR1 |= 0x01; while(!(ADC_CSR & 0x80)); AD_Value = ((((unsigned int)ADC_DRH)<<2)+ADC_DRL); TIM2_CCR2H=0x00; TIM2_CCR2L=(unsigned char)(AD_Value>>2); if (AD_Value>0x10) { Temp=(unsigned char)(AD_Value>>8); if ((TIM3_ARRH>Temp+0x05)||(TIM3_ARRH<Temp-0x05)) { TIM3_ARRH = Temp; TIM3_ARRL = (unsigned char)(AD_Value&0xff); TIM3_CCR1H = (unsigned char)(AD_Value>>9); TIM3_CCR1L = (unsigned char)((AD_Value>>1)&0xff); } } while ( uc < duration ) { while ( i < 1200 ) { i++; } i = 0; uc++; } …… |
![]() ![]() |
![]() |
![]() |
![]() |
| 歡迎光臨 (http://www.raoushi.com/bbs/) | Powered by Discuz! X3.1 |