1.代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| #include "stm32f10x.h" uint16_t temp, i,temp1,j; void Delay(unsigned int count) { unsigned int i; for(;count!=0;count--) { i=5000; while(i--); } } void main(void) { RCC->APB2ENR|=1<<3; GPIOB->CRL&=0X00000000; GPIOB->CRH&=0XFFFFFF00; GPIOB->CRL|=0X33333333; GPIOB->CRH|=0X33333333; GPIOB->ODR|=0X03ff; while(1) { GPIOB->ODR=~0X0FFFF; temp = 0x0001; for(i=0;i<16;i++) { GPIOB->ODR=~temp; Delay(50); temp =( temp<<1)+1; } temp = 0x0000; for(j=0;j<16;j++) { GPIOB->ODR=temp; Delay(50); temp = (temp>>1)+ 0x8000; } } }
|
2.模拟图

代码下载链接(123云盘):https://www.123684.com/s/wFuijv-i8Zgh