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

CORTEX-M0 探索板流水灯~~

[复制链接]
dspapi 发布时间:2014-3-3 20:33
 //----------------------------------------------------------        . w# V! l( V0 t  _$ y
 void Delay(uint32_t temp)                                                                                                                                        //¼òµ¥µÄÑÓʱº¯Êý£¬ÓÃÓÚ°´¼üÏû¶¶$ I3 L# B& u( W( e2 R. E1 |8 F
{- o7 W; l/ u  ~7 ]1 t/ U- R
  for(; temp != 0; temp--);
- A* U* Y4 {- r! X) i
, O/ s5 W8 }" b# i$ B       
) |3 o5 f" f; w" ?' t+ u4 D//----------------------------------------------------------
; u) U# x: R6 Q5 t6 l//----------------------------------------------------------; @9 k/ o* k# X, ~: x
unsigned long i;! B+ q# b6 m2 t7 _
 
3 U' K! y3 h8 b' rint main(void)1 R& [3 [. Q" b
{; g4 s) ^# O4 a6 ~8 q
        unsigned int j;; g* N5 H8 J( W& }0 g) R2 g) W( y1 W
  /*!< At this stage the microcontroller clock setting is already configured, 
; W& T0 [# k: o; L8 _( ]1 r: f       this is done through SystemInit() function which is called from startup4 M5 c% Q4 g' q& ?" V4 U
       file (startup_stm32f0xx.s) before to branch to application main.
$ k) `' G5 Z4 I5 U; ?       To reconfigure the default setting of SystemInit() function, refer to
) ?4 l" h1 J; E- \6 [; @# R       system_stm32f0xx.c file
; w# @) K+ N/ E5 M     */- t+ x3 C3 Q& ?' Z# U: |+ X; U
 
8 @  d/ z5 R+ O2 D1 }  /* GPIOC Periph clock enable */9 c1 k+ h! ?, C$ s- Y
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
/ n& ?% L8 m5 T0 A9 O$ s 
# I2 W% A: w. U9 p) {9 C/ |' |2 G  /* Configure PC8 and PC9 in output pushpull mode */
5 N3 D# ]  {- X  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;4 ~5 W. z# I1 M! W' w  `4 Z! Y* O
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
6 v8 P9 w% m6 l" h& u  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
: v$ E) Y, ~3 i3 J  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;4 y5 ~$ m7 _; w
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;! u! c/ z9 Z! t2 r3 c1 x
  GPIO_Init(GPIOC, &GPIO_InitStructure);7 `/ N/ _' d, q6 o# _
       
7 E( r! R. E6 d, ^//----------------------------------------------------------
+ }3 T1 o% f! R$ B& i8 c7 T! S % N& p' x5 ?( M- `. b% s7 n9 o
        //Ê×ÏȶÔkey½øÐгõʼ»¯£¬Ò²¾ÍÊÇÉèÖÃGPIO µÄģʽ
  R% [' Y0 Z. b3 B# ?6 X//        GPIO_InitTypeDef GPIO_InitStructure;                                                                                        //µ÷ÓÃIO¶¨ÒåµÄ½á¹¹Ìå
9 q% }7 j: D3 @  x& h2 |        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);                                //ʹÄܰ´¼üIOµÄʱÖÓ5 Z4 j% x" c& d2 F7 [7 F
  GPIO_InitStructure.GPIO_Pin         = GPIO_Pin_1 ;                                                                //ÉèÖÃÁ¬½Ó°´¼üµÄIO¶Ë¿Ú
+ O6 v$ R& L- y7 I7 B  GPIO_InitStructure.GPIO_Mode         = GPIO_Mode_IN;                                                                //ÉèÖö˿ÚΪÊäÈëģʽ
) w" e* @$ J, n9 `# J' R2 J* b  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;                                        //ÉèÖÃËÙ¶ÈΪµÚÈý¼¶/ ]* G2 s( I& i" i: S8 [
  GPIO_InitStructure.GPIO_PuPd         = GPIO_PuPd_UP;                                                                //ÉÏÀ­ÊäÈë/ N' F9 z7 ?& y, m3 M) T* n/ {. u
  GPIO_Init(GPIOA, &GPIO_InitStructure);                                                                                        //°ÑÉèÖõIJÎÊýÓõ½½á¹¹Ìå1 R3 G) K0 v/ \7 t8 J
 
$ l7 F7 T6 b7 Z% Q* `5 q+ A: x ( T5 B  f% c0 E2 q! o
 6 _- _$ r- _2 L/ o0 A3 K( q
  /* To achieve GPIO toggling maximum frequency, the following  sequence is mandatory. 
! d7 j0 [% t) {  F2 i9 M     You can monitor PC8 and PC9 on the scope to measure the output signal. 
8 c0 E$ i( y# S. {4 e# c     If you need to fine tune this frequency, you can add more GPIO set/reset - ^3 M( B; d$ G" F- y8 m
     cycles to minimize more the infinite loop timing.) V4 a0 l6 R) o+ m- l
     This code needs to be compiled with high speed optimization option.  */- M/ s+ y. J. v& y  M8 e7 y. s. [
 ' I# t0 X% J( a- R
        while (1)
) X% }+ `9 E0 n, W$ I  {! j& `- n8 n  x% \
    , I- ?; L) b8 ?" B, U' D2 X/ \# U
           if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == 0 ) . G& A7 a" c: i6 n. M  c/ R5 c
          {           
+ L) l9 T5 b  I; U% q% D: y8 b$ J8 ?    /* Set PC8 and PC9 */: X3 ]0 Q$ l/ r. B
                for(j=0;jBSRR |= (0x20BRR |= (0x400>>j);          U/ r" I, e, H2 m
                         Delay(5000000);4 a/ Z# g0 h- a( v! e5 _0 R8 z
                        }
& x" e" j+ M# A$ G" ]* t3 P- o                        + o! D- S! U- y% y8 h# D, A  s2 C
                }
- \( T+ w7 m5 _- n# j        else
; U+ l/ w( o, ]/ B/ @2 u                {           
+ l5 ?( G; D6 j" ^    /* Set PC9 */8 D* N2 G( r9 u0 Y
 
+ ^! }. S4 t/ I. C5 L2 }) \    GPIOC->BSRR |= 0x0200;
& V, v/ d8 r/ ]  m                Delay(1000000);                3 G. b& B+ v+ x- N9 h
 " E8 n) X: j. F0 O8 \
    /* Reset PC9 */
- T. `) z" `8 H) u) J8 L               
% K9 l8 ^+ E- n                GPIOC->BRR |= 0x0200;
1 ^7 J# \' H6 \: N                Delay(1000000);        ) X  ]: C8 a2 a9 ^$ P8 n) H
                       
, H2 F% P- I2 \; m                };
5 q1 A! O" Y2 p$ Z( h+ a1 J 8 n( b" j9 \/ X. w* n3 ?) @9 g
 
+ q7 }4 k0 E, f3 G. ~7 W8 X3 x  }
) s: Z. s( s: r% T( v}
收藏 评论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 手机版