你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

CORTEX-M0 探索板流水灯~~

[复制链接]
dspapi 发布时间:2014-3-3 20:33
 //----------------------------------------------------------       
 void Delay(uint32_t temp)                                                                                                                                        //¼òµ¥µÄÑÓʱº¯Êý£¬ÓÃÓÚ°´¼üÏû¶¶
{
  for(; temp != 0; temp--);

       
//----------------------------------------------------------
//----------------------------------------------------------
unsigned long i;
 
int main(void)
{
        unsigned int j;
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */
 
  /* GPIOC Periph clock enable */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
 
  /* Configure PC8 and PC9 in output pushpull mode */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
       
//----------------------------------------------------------
 
        //Ê×ÏȶÔkey½øÐгõʼ»¯£¬Ò²¾ÍÊÇÉèÖÃGPIO µÄģʽ
//        GPIO_InitTypeDef GPIO_InitStructure;                                                                                        //µ÷ÓÃIO¶¨ÒåµÄ½á¹¹Ìå
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);                                //ʹÄܰ´¼üIOµÄʱÖÓ
  GPIO_InitStructure.GPIO_Pin         = GPIO_Pin_1 ;                                                                //ÉèÖÃÁ¬½Ó°´¼üµÄIO¶Ë¿Ú
  GPIO_InitStructure.GPIO_Mode         = GPIO_Mode_IN;                                                                //ÉèÖö˿ÚΪÊäÈëģʽ
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;                                        //ÉèÖÃËÙ¶ÈΪµÚÈý¼¶
  GPIO_InitStructure.GPIO_PuPd         = GPIO_PuPd_UP;                                                                //ÉÏÀ­ÊäÈë
  GPIO_Init(GPIOA, &GPIO_InitStructure);                                                                                        //°ÑÉèÖõIJÎÊýÓõ½½á¹¹Ìå
 
 
 
  /* To achieve GPIO toggling maximum frequency, the following  sequence is mandatory. 
     You can monitor PC8 and PC9 on the scope to measure the output signal. 
     If you need to fine tune this frequency, you can add more GPIO set/reset 
     cycles to minimize more the infinite loop timing.
     This code needs to be compiled with high speed optimization option.  */
 
        while (1)
  {
    
           if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == 0 ) 
          {           
    /* Set PC8 and PC9 */
                for(j=0;jBSRR |= (0x20BRR |= (0x400>>j);       
                         Delay(5000000);
                        }
                       
                }
        else
                {           
    /* Set PC9 */
 
    GPIOC->BSRR |= 0x0200;
                Delay(1000000);               
 
    /* Reset PC9 */
               
                GPIOC->BRR |= 0x0200;
                Delay(1000000);       
                       
                };
 
 
  }
}
收藏 评论1 发布时间:2014-3-3 20:33

举报

1个回答
沐紫 回答时间:2014-3-18 13:14:54

RE:CORTEX-M0 探索板流水灯~~

for STM32F030?

所属标签

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版