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

CORTEX-M0 探索板流水灯~~

[复制链接]
dspapi 发布时间:2014-3-3 20:33
 //----------------------------------------------------------       
$ y$ ~" V1 Q7 M/ i" I4 \$ ] void Delay(uint32_t temp)                                                                                                                                        //¼òµ¥µÄÑÓʱº¯Êý£¬ÓÃÓÚ°´¼üÏû¶¶
. |' N/ O3 X5 z( [- E5 z{. `0 T  g" Z+ w
  for(; temp != 0; temp--);" t" C: P7 n! X0 U
: L# }2 C* x/ x  z( o% e2 A
        ( b: U- J9 K/ q
//----------------------------------------------------------
+ x' h% A4 C7 W3 b2 M8 s//----------------------------------------------------------) a8 c+ b# b1 X2 m2 M3 w& w
unsigned long i;! c8 R% _! j. t' f' o0 ^
 6 Q' [# b; [+ ]/ p2 D# \
int main(void)
/ y. a) j1 L- o" ?$ g2 l% t- r{, N, M4 ]% [8 l" M
        unsigned int j;& Z" `/ b- D7 O  _0 B& n5 G# k
  /*!< At this stage the microcontroller clock setting is already configured, " K6 E. i8 k3 W/ q6 ?/ K
       this is done through SystemInit() function which is called from startup
  n& o! i! q: A$ G( _       file (startup_stm32f0xx.s) before to branch to application main.
" \  ~# X+ s+ R) W- o" b/ y8 G       To reconfigure the default setting of SystemInit() function, refer to
( `) g- W9 X6 F0 m8 ~0 e; j       system_stm32f0xx.c file* u/ h4 m9 p3 n8 t
     */4 E) R8 J  C+ ^+ E( {. b) L
 
: M2 B7 a% u1 n" c2 G0 U1 m  /* GPIOC Periph clock enable */
) k) U$ S+ i$ ?  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);  S, A& |9 F+ c, C- F; f. Q
 
! ]+ d5 I# V5 R4 H  /* Configure PC8 and PC9 in output pushpull mode */
9 r- [3 f/ W3 g* T/ l  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
$ m5 j  {. K% z' H8 d' u  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;  E1 o" a7 a  x3 ~/ N
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
& H0 _" n( j9 l! S+ b8 U# A  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;6 @5 X- Q( ?# B. }8 g
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;$ H2 h  u/ H4 `) c
  GPIO_Init(GPIOC, &GPIO_InitStructure);
4 X0 P+ j' |0 S% q        & k% X, ^' x5 o. o
//----------------------------------------------------------
9 D" t- R5 ^. P% I   |: B% v" i/ u7 i; q
        //Ê×ÏȶÔkey½øÐгõʼ»¯£¬Ò²¾ÍÊÇÉèÖÃGPIO µÄģʽ
4 x9 E) Z* W; M" U- B//        GPIO_InitTypeDef GPIO_InitStructure;                                                                                        //µ÷ÓÃIO¶¨ÒåµÄ½á¹¹Ìå5 K- ]) Y' e5 x& `& I2 e" p
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);                                //ʹÄܰ´¼üIOµÄʱÖÓ
+ G- N/ h6 p8 M' p4 ?1 m$ P  GPIO_InitStructure.GPIO_Pin         = GPIO_Pin_1 ;                                                                //ÉèÖÃÁ¬½Ó°´¼üµÄIO¶Ë¿Ú7 y) n) k" `& O; ?+ G" o( c
  GPIO_InitStructure.GPIO_Mode         = GPIO_Mode_IN;                                                                //ÉèÖö˿ÚΪÊäÈëģʽ
6 M5 C' ?& B  w  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;                                        //ÉèÖÃËÙ¶ÈΪµÚÈý¼¶
0 K7 P: Q- {' m3 }2 o" q  GPIO_InitStructure.GPIO_PuPd         = GPIO_PuPd_UP;                                                                //ÉÏÀ­ÊäÈë( ^5 J6 L# X: ^+ U' S) V2 ~+ d
  GPIO_Init(GPIOA, &GPIO_InitStructure);                                                                                        //°ÑÉèÖõIJÎÊýÓõ½½á¹¹Ìå
. g/ I8 N; i9 |4 x8 x 
) e4 Y$ m" l$ M) n 
8 O; n2 W7 u! \' S+ l' J  ~ 1 q! c2 q. P+ F
  /* To achieve GPIO toggling maximum frequency, the following  sequence is mandatory. * X% t6 I+ q( T' k4 E
     You can monitor PC8 and PC9 on the scope to measure the output signal. 
5 L% L$ x! `6 z. m1 ?8 V2 D! t( n, Y     If you need to fine tune this frequency, you can add more GPIO set/reset # M- a( ]& w9 m+ \2 S6 R" x! C
     cycles to minimize more the infinite loop timing.$ _0 W0 h) {* m4 O0 q; G
     This code needs to be compiled with high speed optimization option.  */
# @5 ~4 D& q- | 
7 `+ H; z) ?. I        while (1), m  I, W; L! K( f; H+ T4 R
  {: L# Y- s0 t; F4 U3 Q: Y
    . Q  X" G4 |* b
           if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == 0 ) 
7 m( T& E. K. G5 D          {           
8 u* m  H1 L! t+ E    /* Set PC8 and PC9 */# z  F% K2 @3 v' h" i) W
                for(j=0;jBSRR |= (0x20BRR |= (0x400>>j);        / w6 f  y: k  [( R, g3 b" A: |
                         Delay(5000000);
; b0 ^5 F' Y- i& [# ?2 ]+ r                        }8 N( [$ d; L' A  [9 l% h
                       
( B5 o% k% a$ |. J                }) P, t' u% u; i
        else
' [3 P* v' `2 }0 ?- I                {           2 O  P) O+ u0 b6 I7 w
    /* Set PC9 */
: O- @  N1 [+ U5 P5 O4 f , U! \' E- Z4 `( o; C2 W
    GPIOC->BSRR |= 0x0200;
5 O5 {- K; E+ N2 L                Delay(1000000);                  d6 _1 X2 F4 E5 S9 X5 r# K! @6 b
 
' J1 b/ S% o+ c5 [# M' w( C    /* Reset PC9 */* `% w; D+ s# s: {4 b$ o  o2 u
                ' v3 X* N* d; }( t; e
                GPIOC->BRR |= 0x0200;
  @" o+ x4 g6 P6 C' Y  n, A2 b                Delay(1000000);       
' L$ ?. D% c, ?$ i                       
7 y0 H4 U8 N& D. M                };
, }' |" R" f+ u 
0 K& f6 R2 Y- T! I  c( F 
, E! z# b' U) y) P( P( J  }
3 r% M% y' p, ^% f- c}
收藏 评论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 手机版