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

CORTEX-M0 探索板流水灯~~

[复制链接]
dspapi 发布时间:2014-3-3 20:33
 //----------------------------------------------------------       
  b6 v4 [8 p- J* V: L( w8 w void Delay(uint32_t temp)                                                                                                                                        //¼òµ¥µÄÑÓʱº¯Êý£¬ÓÃÓÚ°´¼üÏû¶¶
: t% E2 e& ^2 K! _{
) ?0 U& T, E/ q  for(; temp != 0; temp--);
& {' T( @& n: k2 d! V, T6 U. _' q7 X. U* l  j! U4 u! y
        ' v7 X. U  R7 i7 h9 d$ J
//----------------------------------------------------------6 L' r: Z$ U5 r' X* a3 C4 r& s
//----------------------------------------------------------
; |5 m9 c( G3 V4 v4 kunsigned long i;( L# n0 T0 C* F
 ) l" {) c  G! ~6 e1 K
int main(void)
% j1 v% S# a) d, g6 T. T' Y4 }{1 y( o% i6 V( A
        unsigned int j;" g1 E% ~8 n2 E7 s
  /*!< At this stage the microcontroller clock setting is already configured, * H# v+ n! s7 n; b9 [6 h2 c
       this is done through SystemInit() function which is called from startup1 B9 Q% H3 J% ~4 M9 T2 n
       file (startup_stm32f0xx.s) before to branch to application main.
2 g1 k" m7 T$ a9 ~       To reconfigure the default setting of SystemInit() function, refer to2 q+ }+ S' ]$ k8 A7 H
       system_stm32f0xx.c file# h1 `$ Y3 E) W& m! J
     */
) Z5 a9 e. G. q8 Q& a 
$ g; m: ?  T: B1 E% T  /* GPIOC Periph clock enable */& c0 E9 Z! h6 p) d/ s+ V6 ?
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);+ W- I, H( E7 Q! A4 F0 U
 * F+ _6 b( _3 t+ D) q, |
  /* Configure PC8 and PC9 in output pushpull mode */5 \, b5 e$ k2 P& {0 @% S
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;: G: N7 S  j' a
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
7 [- g4 w  e4 l  b" i. i" Y  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
4 d% E7 ^  W* x+ l# P! C& X- H' p  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;0 |& C9 T6 b6 L- j: f) y" s
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;0 h$ R$ g, `5 t* e3 B$ d9 u& \( h
  GPIO_Init(GPIOC, &GPIO_InitStructure);" I: K* D' k1 f5 V, [, w
        % {& Y0 F) N3 T' x# u
//----------------------------------------------------------
5 y, U7 r  Y7 Q0 r* B 5 w; \$ I7 y; ^  l( y" Q
        //Ê×ÏȶÔkey½øÐгõʼ»¯£¬Ò²¾ÍÊÇÉèÖÃGPIO µÄģʽ2 @! _5 D! z0 E  e" Z! ^$ u
//        GPIO_InitTypeDef GPIO_InitStructure;                                                                                        //µ÷ÓÃIO¶¨ÒåµÄ½á¹¹Ìå3 _: F: S" x1 |$ Q7 q3 `  L
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);                                //ʹÄܰ´¼üIOµÄʱÖÓ+ O  A( e$ r* G3 d
  GPIO_InitStructure.GPIO_Pin         = GPIO_Pin_1 ;                                                                //ÉèÖÃÁ¬½Ó°´¼üµÄIO¶Ë¿Ú. J8 Q; Q5 E' h3 ?
  GPIO_InitStructure.GPIO_Mode         = GPIO_Mode_IN;                                                                //ÉèÖö˿ÚΪÊäÈëģʽ
  t8 K4 A( _; N  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;                                        //ÉèÖÃËÙ¶ÈΪµÚÈý¼¶
* ?1 t; W: n  ]) `- D; Y  GPIO_InitStructure.GPIO_PuPd         = GPIO_PuPd_UP;                                                                //ÉÏÀ­ÊäÈë) d0 Q0 q0 Y0 |2 V6 ^- I8 p
  GPIO_Init(GPIOA, &GPIO_InitStructure);                                                                                        //°ÑÉèÖõIJÎÊýÓõ½½á¹¹Ìå9 \" i. r& V) Y& [; b5 Y
 ( D2 [9 R  [7 W8 A) Y, ^9 o
 8 E: u1 x. K0 ^* d+ A- |( C4 K- y/ v
 % ~! j2 v# P1 V6 s# Z/ z
  /* To achieve GPIO toggling maximum frequency, the following  sequence is mandatory. 
8 K1 W4 c, g  P% m; t+ o" ~     You can monitor PC8 and PC9 on the scope to measure the output signal. 7 {; F. l+ O, U1 I6 I7 x% u
     If you need to fine tune this frequency, you can add more GPIO set/reset # R' J, l& l% K
     cycles to minimize more the infinite loop timing.8 C2 H, \& Y$ H8 y
     This code needs to be compiled with high speed optimization option.  */
3 B" {$ D( d+ G( c9 n 
0 Z! L5 p5 v2 o        while (1)
  S5 K0 M: O, g  {
+ f. h* i. b! Y2 @# R3 z" {" v    
% L. H$ d: A! {$ |: X. p$ m: M# F. q           if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == 0 ) ; O' b! K- @5 |- {$ k# j5 f, g. @3 f
          {           
6 |+ d5 r  p: j  f9 M6 }  \- u& G    /* Set PC8 and PC9 */' W/ }) @% }( C# V' o( M) p1 e
                for(j=0;jBSRR |= (0x20BRR |= (0x400>>j);        9 [) h* G+ X# P
                         Delay(5000000);
. J- @9 E1 `; f                        }1 x4 l8 S6 B$ R* [9 P. i9 ^# W1 E) w! Y
                       
0 Q# U7 t2 A( v9 k$ i9 `2 y                }
  ^$ P' k" u' l" {2 k4 V9 y2 G; o* z        else
+ p- T' Q  Q! D, v                {           8 {8 V! E5 J# y$ T1 ~0 G! I& ^
    /* Set PC9 */
! I; X  Q' t1 b. B ) @5 O. H) l  D* |, Y
    GPIOC->BSRR |= 0x0200;
/ j. t% |/ [6 S0 s                Delay(1000000);               
2 `8 E4 ^1 q0 T; W* Q. d! r5 ]9 l2 ` ! K* y; B( {6 S5 F1 d) `
    /* Reset PC9 */
! A( z- u9 j! s7 H0 Q( O$ S                3 I6 F& H+ p, o! {1 Y
                GPIOC->BRR |= 0x0200;
! V3 i. g9 x2 V4 q: M" K' m% T                Delay(1000000);       
9 H/ E4 g. m7 U, V$ h1 D                        : }1 W4 i* o* y( V0 W) q8 L' P$ S, k
                };$ c+ ~& S7 m4 q3 t- @/ `; `3 ]1 \9 H
 ( Y+ S& O" a0 u8 l, n
 & }% y2 K# I/ Z' c$ [* A
  }, R; n. S3 o  M7 a. t" k$ |
}
收藏 评论1 发布时间:2014-3-3 20:33

举报

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

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

for STM32F030?

所属标签

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版