12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include "stm32f10x.h"
- static __IO uint32_t TimingDelay;
- void Delay_ms(__IO uint32_t nTime);
- GPIO_InitTypeDef GPIO_InitStruct;
- int main()
- {
-
- SysTick_Config(24000);
-
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
- GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_Init(GPIOC, &GPIO_InitStruct);
- while(1)
- {
- GPIO_ResetBits(GPIOC, GPIO_Pin_9);
- GPIO_SetBits(GPIOC, GPIO_Pin_8);
- Delay_ms(1000);
- GPIO_ResetBits(GPIOC, GPIO_Pin_8);
- GPIO_SetBits(GPIOC, GPIO_Pin_9);
- Delay_ms(1000);
- }
- }
- void Delay_ms(__IO uint32_t nTime)
- {
- TimingDelay = nTime;
- while(TimingDelay != 0);
- }
- void TimingDelay_Decrement(void)
- {
- if (TimingDelay != 0x00)
- {
- TimingDelay--;
- }
- }
- void SysTick_Handler(void)
- {
- TimingDelay_Decrement();
- }
|