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

CORTEX-M0 探索板流水灯~~

[复制链接]
dspapi 发布时间:2014-3-3 20:33
 //----------------------------------------------------------       
5 W: T8 y. I: Q+ j$ V- d6 J void Delay(uint32_t temp)                                                                                                                                        //¼òµ¥µÄÑÓʱº¯Êý£¬ÓÃÓÚ°´¼üÏû¶¶
" o% V& |; [" e1 l  A4 G4 ^{- P2 q" k, q1 C, D/ R0 i3 v
  for(; temp != 0; temp--);
% u( t' g3 y1 R4 W* Z8 J% ]
2 d, }. O! Z9 h* S' i       
8 o/ C  r% f4 V, J//----------------------------------------------------------
/ f5 o9 w" `+ B+ @3 c7 y% d  t//----------------------------------------------------------
0 `+ j: A% d, u( Aunsigned long i;
: f2 g5 k3 |% I % I2 R8 _7 F8 ]) I, R1 T2 K
int main(void)
, e- k9 H& y6 H/ F# v9 Z# J* g& [{$ u0 g+ I. A& w5 O# T
        unsigned int j;$ P4 L7 G) ?) E% G/ L9 @) S
  /*!< At this stage the microcontroller clock setting is already configured, / q% y4 H  w% s- u+ r9 G" }
       this is done through SystemInit() function which is called from startup
- ~- p1 o1 g8 v+ e1 G       file (startup_stm32f0xx.s) before to branch to application main.
: v" }( Y5 ]7 s8 d, F3 V       To reconfigure the default setting of SystemInit() function, refer to" x& ~8 U( m4 \- D6 l  K! R2 e; [
       system_stm32f0xx.c file/ C; x+ _* Q; z; i& H
     */
+ I/ g* _7 G4 e9 U, o0 M4 w1 D! { , h3 y1 f0 d, z/ m0 p& m" ]7 _. B5 x
  /* GPIOC Periph clock enable */
" [/ U' }0 T( x" ]# L- r  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);- q! U" W" }2 `6 Z3 w$ n
 2 S$ }& E7 r0 X
  /* Configure PC8 and PC9 in output pushpull mode */( ?9 L7 x, n( x3 `0 v5 F/ C
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;9 Z+ g6 k+ c6 m1 M6 A
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
3 [7 d8 x0 S& |! h: y6 k0 V  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
* i" `5 V" x4 R* a5 W6 ?  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;; }" i: n) q3 j* b
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;2 t# L* _( K+ K0 _" y- `. |
  GPIO_Init(GPIOC, &GPIO_InitStructure);
$ G/ P" q6 o, E* m3 ]  g       
' Y. w9 L- t8 Z8 u//----------------------------------------------------------1 {7 [: a. Y" I( L
 6 x7 a4 Y- Y; W) D8 C
        //Ê×ÏȶÔkey½øÐгõʼ»¯£¬Ò²¾ÍÊÇÉèÖÃGPIO µÄģʽ
" S7 K! d( W5 d5 w7 w9 i. S2 T* w//        GPIO_InitTypeDef GPIO_InitStructure;                                                                                        //µ÷ÓÃIO¶¨ÒåµÄ½á¹¹Ìå
8 W  M$ R8 L8 a) P. N+ E4 H        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);                                //ʹÄܰ´¼üIOµÄʱÖÓ
: ~1 p6 J6 B6 N: x  GPIO_InitStructure.GPIO_Pin         = GPIO_Pin_1 ;                                                                //ÉèÖÃÁ¬½Ó°´¼üµÄIO¶Ë¿Ú
) d% \' x3 B3 y. @4 |  GPIO_InitStructure.GPIO_Mode         = GPIO_Mode_IN;                                                                //ÉèÖö˿ÚΪÊäÈëģʽ0 |  u" {1 {9 f/ x& o7 [
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;                                        //ÉèÖÃËÙ¶ÈΪµÚÈý¼¶) B3 |9 Y; o+ j9 Z! }5 v5 K9 I
  GPIO_InitStructure.GPIO_PuPd         = GPIO_PuPd_UP;                                                                //ÉÏÀ­ÊäÈë
# l, ^' e+ \0 z7 ?4 ~0 W( t  GPIO_Init(GPIOA, &GPIO_InitStructure);                                                                                        //°ÑÉèÖõIJÎÊýÓõ½½á¹¹Ìå
% C+ l' V/ W% E# Z7 k 
/ f; L7 k% N' ?4 B * m/ U# s8 s2 {. `9 p7 F4 v
 " s# @. t0 B& G4 K0 f
  /* To achieve GPIO toggling maximum frequency, the following  sequence is mandatory. 
+ @. Y, l: M) Z4 K  F9 i5 J4 `     You can monitor PC8 and PC9 on the scope to measure the output signal. 5 O8 P% E) A+ q9 S; s+ w) L& |
     If you need to fine tune this frequency, you can add more GPIO set/reset 
# C: {, j4 v' G% z. K9 K     cycles to minimize more the infinite loop timing.* {4 j1 g( U& G# x. }) h$ L2 M1 f
     This code needs to be compiled with high speed optimization option.  */  M# k6 Q) N7 g) B$ ^
 
% y- G2 a& j% `+ k/ e% h1 e        while (1)" }8 L  g# g2 {8 h' V% {( m" n
  {& G0 t" `1 n& z8 f# \( }$ S
    5 Z. Z9 h5 a5 L" U+ r) I/ M
           if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == 0 ) 
+ a* c" q1 B4 Y+ }6 L          {           : @+ U+ v: W; g1 A& f3 }
    /* Set PC8 and PC9 */
$ f8 ^: T# F% u9 D                for(j=0;jBSRR |= (0x20BRR |= (0x400>>j);       
& I; e. n0 E. A( @6 y6 r                         Delay(5000000);' t6 Q1 u5 W( t2 m6 \
                        }& T" M1 T( p" U. X+ A
                       
: `+ Q, m- E3 @& X1 X3 ~                }
( [( }* Y0 a* O+ }! e: q6 z3 E: p        else
% y3 B7 [% G. E6 z- n) G                {           * g7 {0 o5 U# \: [* p2 Z
    /* Set PC9 */
" M! v' v1 x8 _, V: e( v0 z  j% | 
  P. B" c& ]. v! r    GPIOC->BSRR |= 0x0200;
8 L7 p2 q, n/ ^. b  U) p4 ]                Delay(1000000);               
# @3 Z2 d8 O" B9 Q, m$ M 6 }5 Y$ E0 U) j( j) ^
    /* Reset PC9 */
0 `4 W* ^0 l1 l4 C( J               
- ?1 Z9 V0 y: f! ]) |: S3 w6 x                GPIOC->BRR |= 0x0200;6 V3 J% l* L1 {: i: Q' U( a
                Delay(1000000);        9 O9 X+ S/ E9 O* u5 }5 Y  T
                       
1 d. T. g$ q+ h$ w+ ~5 B                };% d/ A( K8 H5 k$ _
 : w$ l3 t, p' A& l; A- C! A- n
 
* {- T/ ^. F3 ^% p1 e- Q3 K  }% D4 ]5 x/ o5 S" F5 n; g+ t! H4 P
}
收藏 评论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 手机版