void RCC_Configuration(void);
void Delay(__IO uint32_t nCount);
int main(void)
{
//uint16_t a;
/* System Clocks Configuration **********************************************/
RCC_Configuration();
//
/* Configure all unused GPIO port pins in Analog Input mode (floating input
trigger OFF), this will reduce the power consumption and increase the device
immunity against EMI/EMC *************************************************/
void RCC_Configuration(void)
{
/* Setup the microcontroller system. Initialize the Embedded Flash Interface,
initialize the PLL and update the SystemFrequency variable. */
SystemInit();
}
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval : None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
void RCC_Configuration(void);
void Delay(__IO uint32_t nCount);
int main(void)
{
//uint16_t a;
/* System Clocks Configuration **********************************************/
RCC_Configuration();
//
/* Configure all unused GPIO port pins in Analog Input mode (floating input
trigger OFF), this will reduce the power consumption and increase the device
immunity against EMI/EMC *************************************************/
void RCC_Configuration(void)
{
/* Setup the microcontroller system. Initialize the Embedded Flash Interface,
initialize the PLL and update the SystemFrequency variable. */
SystemInit();
}
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval : None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
RE:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!
看来楼主的变通能力不强呀...
回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!
不知道楼主会51不,会51就一定能写出来,如果不会那就要另说了,
看来楼主的变通能力不强呀.
不会呢,麻烦你帮帮忙吧,给我解说下呢,谢谢哈,急用呢。学的不是很好呢,现在要做实验没办法呢,谢谢你哈。
回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
RE:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
另一种方案是 开一个定时器做计时使用,主循环中查看变量
int timerled = 0;
int ledCount = 1;//1代表灯亮 0代表等灭
int i = 0;
char ledoff = 0;
int timerkey = 0;
while(1)
{
if(!ledoff)
{
ledCount = 1;
for(i = 0;i < 16;i++)
{
GPIOA->ODR = ledCount;
ledCount
RE:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
RE:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
RE:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
GPIO_InitTypeDef GPIO_InitStructure;
void RCC_Configuration(void);
void Delay(__IO uint32_t nCount);
int main(void)
{
//uint16_t a;
/* System Clocks Configuration **********************************************/
RCC_Configuration();
//
/* Configure all unused GPIO port pins in Analog Input mode (floating input
trigger OFF), this will reduce the power consumption and increase the device
immunity against EMI/EMC *************************************************/
/* RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1 |RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOE, ENABLE);
*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7; //D1 D2
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_13; //D3, D4
GPIO_Init(GPIOD, &GPIO_InitStructure);
while (1)
{
GPIO_SetBits(GPIOC, GPIO_Pin_6);// D1亮
Delay(0xAFFFF);
GPIO_SetBits(GPIOC, GPIO_Pin_7 ); //D2亮
GPIO_ResetBits(GPIOC, GPIO_Pin_6); //D1灭
Delay(0xAFFFF);
GPIO_SetBits(GPIOD, GPIO_Pin_13 ); //D3亮
GPIO_ResetBits(GPIOC, GPIO_Pin_7); //D2灭
Delay(0xAFFFF);
GPIO_SetBits(GPIOD, GPIO_Pin_6 ); //D4亮
GPIO_ResetBits(GPIOD, GPIO_Pin_13); //D3灭
Delay(0xAFFFF);
GPIO_ResetBits(GPIOD, GPIO_Pin_6); //D4灭
}
}
void RCC_Configuration(void)
{
/* Setup the microcontroller system. Initialize the Embedded Flash Interface,
initialize the PLL and update the SystemFrequency variable. */
SystemInit();
}
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval : None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
主程序循环执行流水灯,按键中断执行灯熄灭延时,楼主要多动手练习
谢谢你哈。我会好好努力的。
回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
找个GPIO的程序认真学习下,相信你应该能搞定
谢谢提醒呢,我会的哈,我会努力的呢。
回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
同意楼上的方案..
另一种方案是 开一个定时器做计时使用,主循环中查看变量
int timerled = 0;
int ledCount = 1;//1代表灯亮 0代表等灭
int i = 0;
char ledoff = 0;
int timerkey = 0;
while(1)
{
if(!ledoff)
{
ledCount = 1;
for(i = 0;i < 16;i++)
{
GPIOA->ODR = ledCount;
ledCount
回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
可以在网上找个流水灯程序学习学习。
谢谢哈。
回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
#include "stm32f10x.h"
GPIO_InitTypeDef GPIO_InitStructure;
void RCC_Configuration(void);
void Delay(__IO uint32_t nCount);
int main(void)
{
//uint16_t a;
/* System Clocks Configuration **********************************************/
RCC_Configuration();
//
/* Configure all unused GPIO port pins in Analog Input mode (floating input
trigger OFF), this will reduce the power consumption and increase the device
immunity against EMI/EMC *************************************************/
/* RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1 |RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOE, ENABLE);
*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7; //D1 D2
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_13; //D3, D4
GPIO_Init(GPIOD, &GPIO_InitStructure);
while (1)
{
GPIO_SetBits(GPIOC, GPIO_Pin_6);// D1亮
Delay(0xAFFFF);
GPIO_SetBits(GPIOC, GPIO_Pin_7 ); //D2亮
GPIO_ResetBits(GPIOC, GPIO_Pin_6); //D1灭
Delay(0xAFFFF);
GPIO_SetBits(GPIOD, GPIO_Pin_13 ); //D3亮
GPIO_ResetBits(GPIOC, GPIO_Pin_7); //D2灭
Delay(0xAFFFF);
GPIO_SetBits(GPIOD, GPIO_Pin_6 ); //D4亮
GPIO_ResetBits(GPIOD, GPIO_Pin_13); //D3灭
Delay(0xAFFFF);
GPIO_ResetBits(GPIOD, GPIO_Pin_6); //D4灭
}
}
void RCC_Configuration(void)
{
/* Setup the microcontroller system. Initialize the Embedded Flash Interface,
initialize the PLL and update the SystemFrequency variable. */
SystemInit();
}
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval : None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
谢谢哈,真的是非常的谢谢呢。万分的感谢呢。
RE:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】
AN2569_STM32F10xxx GPIOåºç¨ç¤ºä¾.pdf
2012-8-20 09:00 上传
点击文件名下载附件
178.84 KB, 下载次数: 10