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

CORTEX-M0 探索板流水灯~~

[复制链接]
dspapi 发布时间:2014-3-3 20:33
 //----------------------------------------------------------       
% _, j. g/ G1 A- I/ ~* q- d6 G) D void Delay(uint32_t temp)                                                                                                                                        //¼òµ¥µÄÑÓʱº¯Êý£¬ÓÃÓÚ°´¼üÏû¶¶
; F, y! ?* ~& Y! A  }3 A- p7 _: |$ m+ r{" z. [/ j! p3 P2 ?1 m& R) a
  for(; temp != 0; temp--);
  W7 m. N& w& s3 M9 M+ A  b1 z" h5 K% n0 L$ L1 k! n/ K
        + W. w/ s: d6 p' P$ F5 @! Y7 I
//----------------------------------------------------------
( l- K* c9 {9 [//----------------------------------------------------------
" }$ g' c, t7 i# s0 h) n. j* w! Funsigned long i;' E; j# K% A+ w- C6 I0 m
 
* q3 [$ P6 G: Q" zint main(void)
& b% s+ Q' m. Z+ e2 Y) F* i{
. h6 r- `- [4 d) M# g* e        unsigned int j;) p4 s1 W+ y8 F
  /*!< At this stage the microcontroller clock setting is already configured, 
6 _' O( p9 t% ?. f       this is done through SystemInit() function which is called from startup
1 p5 Z* @8 ~( Y) ~       file (startup_stm32f0xx.s) before to branch to application main.) r: Z& m7 [3 m9 P  u
       To reconfigure the default setting of SystemInit() function, refer to. G3 b! H$ o3 `
       system_stm32f0xx.c file
- b) G6 o6 Y: v7 R1 C  b     */* f  j% l+ v: r
 0 T) _& i2 S* j& c" A. V
  /* GPIOC Periph clock enable */" [- J5 q) N0 R2 F8 j7 t0 Y2 q
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
1 \8 H' B) m0 k! C! ~( v % C' J' e3 f5 E) q7 p
  /* Configure PC8 and PC9 in output pushpull mode */0 ]: y+ }  V5 p% T! I. m
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;+ T+ `( h, Z( x& d* k& l7 k
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
4 m1 f; v( s* @: _7 [' C  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
: q6 H0 k: W% D6 v) c" B( h  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;- t  Y6 F" G: D2 d# j4 D1 N& R
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
" X/ r4 x( Q" A+ {$ T' A  GPIO_Init(GPIOC, &GPIO_InitStructure);
2 a8 b9 k0 ^2 H1 u* N6 O       
7 k, Q: S; Q  R% q% ^//----------------------------------------------------------( t$ V! M  j" v/ G. j8 c- Z( A
 
; G' N) ^; q6 r5 S$ H        //Ê×ÏȶÔkey½øÐгõʼ»¯£¬Ò²¾ÍÊÇÉèÖÃGPIO µÄģʽ
7 p0 m- `4 n. P8 o$ a9 z//        GPIO_InitTypeDef GPIO_InitStructure;                                                                                        //µ÷ÓÃIO¶¨ÒåµÄ½á¹¹Ìå
! I1 _! ?5 l  B3 l1 h$ T0 k- E        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);                                //ʹÄܰ´¼üIOµÄʱÖÓ3 X4 ]( [2 X: y0 S. y
  GPIO_InitStructure.GPIO_Pin         = GPIO_Pin_1 ;                                                                //ÉèÖÃÁ¬½Ó°´¼üµÄIO¶Ë¿Ú
' K0 y* W0 Y! K4 ~2 t& v- g6 J  GPIO_InitStructure.GPIO_Mode         = GPIO_Mode_IN;                                                                //ÉèÖö˿ÚΪÊäÈëģʽ5 H1 C; I: \) l3 U/ f
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;                                        //ÉèÖÃËÙ¶ÈΪµÚÈý¼¶8 V3 s) S/ z; K! @8 X; ^
  GPIO_InitStructure.GPIO_PuPd         = GPIO_PuPd_UP;                                                                //ÉÏÀ­ÊäÈë: H- k: y$ w' B7 ~& J
  GPIO_Init(GPIOA, &GPIO_InitStructure);                                                                                        //°ÑÉèÖõIJÎÊýÓõ½½á¹¹Ìå
4 T6 |% p# }5 U0 M) z 5 v; d! }3 I! t, N
 
8 H, K4 \1 V: J) B) X( C1 t 
) o8 o$ `: l( U( |- C1 @  /* To achieve GPIO toggling maximum frequency, the following  sequence is mandatory. 
, o4 e4 M1 K& @) Q& V  y& Y     You can monitor PC8 and PC9 on the scope to measure the output signal. 
, v2 I: o( v# j# {9 I9 T     If you need to fine tune this frequency, you can add more GPIO set/reset 
" m5 L7 @3 t0 d! t4 @5 U" M     cycles to minimize more the infinite loop timing.
+ }3 h" @- E" T8 t2 w* y) C     This code needs to be compiled with high speed optimization option.  */. c' m) }1 ~( M! x
 
$ v6 P! w0 j* W# O# S+ M( a: f2 }+ X        while (1)) t' f# a+ [) n0 K. ?4 i
  {
: V8 w( C1 u9 X9 E* T    
: z7 D8 k. ^* r3 }5 l+ m+ d           if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == 0 ) 1 Q1 e% m. }" y! L9 k
          {           - h) N+ m! B7 u& C5 X) `4 i" Y
    /* Set PC8 and PC9 */
3 s, y/ X2 Q0 |# j                for(j=0;jBSRR |= (0x20BRR |= (0x400>>j);        ( C% m$ ~+ b% u$ Y5 K# _' Y
                         Delay(5000000);7 D+ C' {  O; r: L
                        }/ L/ K$ {# k/ F) J# K/ F3 S
                       
- f9 M5 b4 |% U* `. I                }
4 _2 I3 ]- T: E+ @$ m7 ~        else' [) o6 M; F6 Y% [
                {           0 x9 @; x/ }& o  ^+ ?( G! x- }
    /* Set PC9 */
$ Q) t! ~* z/ M: b$ u3 M3 W4 S! v 
6 E# s: i" W7 B! o5 _7 e0 d    GPIOC->BSRR |= 0x0200;
: K# m" m0 N0 [. b% y                Delay(1000000);               
5 W/ ~0 `$ ^) z0 X- ~6 v 0 k- _% I3 [# u1 K' D7 m  B
    /* Reset PC9 */. M2 Z+ g8 Q7 I
               
6 _- P0 B2 t& Q4 E2 `                GPIOC->BRR |= 0x0200;9 {. {, h; m; Y; m
                Delay(1000000);        ( X/ {- I/ E, m3 C/ D
                        1 f" @3 j4 P$ M+ m
                };3 H0 D2 A* P7 ^6 Q- k4 k, s
 " N# C; W5 _  Z: V& ]
 
# m) v% c% w6 ]4 Q7 T" V: z  }2 C0 z+ M7 E+ i- m3 {$ X% l
}
收藏 评论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 手机版