这是部分程序,前面的程序没有任何问题,当执行 7 Y: Y% F9 u1 O7 Q; pcase 1: ) h$ ?$ L( y6 sPWM0_0=1; 9 P. j9 K! _6 J$ l- uTH0=-PWM_Value1[0]/256;: i- f8 J1 k7 W- u( g TL0=-PWM_Value1[0]%256;9 V8 x$ p, b9 p, i; c) ] break;2 _$ m' i; q% H/ V 时,break没有起作用,反而直接到了case 12中的这一步: ?! {3 f, o1 A# }- s TL0=-(3300-PWM_Value1[5])%256; # @+ I& Z% _' n* f. W* e9 P6 Sorder1=0;8 Z0 K1 _7 D7 d TR1=0;; n3 C3 s1 S! ?$ u- p break; 7 c/ N: k6 g5 Y" I2 u9 `}5 W; t' {- L$ i" [% S% } order1++; R3 @" K+ T6 `; H4 j在case12中结束循环的: O" Y: W/ z# k! P /*=================================================================================== & J) q1 ^& Q( @* n定时器T0的中断服务程序 " x) X7 M9 S6 ]( t0 `, x一个循环20MS ≈ 6*3.33ms) n! _/ p G8 K4 H, ^+ X m* p =====================================================================================*/7 B4 P' d1 G* r, V1 ^: ] void timer0(void) interrupt 1 using 1 % n* {# R& L: Z& a5 e+ Y{ ! \( {6 w2 ]2 t7 u5 e6 M5 dswitch(order1) 6 H8 O9 B: T( _{ " Z. {2 ^+ S% D% bcase 1: ) U7 Y! {) \2 r: I* [PWM0_0=1;4 |# c/ c$ J; k) ]/ d8 E2 {8 ], r8 I TH0=-PWM_Value1[0]/256;9 P) z5 W! |/ W3 N6 Y- l) |1 c3 L TL0=-PWM_Value1[0]%256;( Y. f! }, o$ O6 H" p2 h, t break; 4 Q5 \2 n5 I! I% ocase 2:3 W( ], @; v- [' l; S* d; |# S PWM0_0=0;5 q p' u6 q; O4 B TH0=-(3300-PWM_Value1[0])/256;' N2 U9 ]- X/ X5 G TL0=-(3300-PWM_Value1[0])%256;- }! O4 F8 W1 @ break; 0 f) V: @% v! _1 qcase 3: ! ~- E- |9 X# d% E6 d9 s$ ?PWM0_1=1; * z; F5 k4 V6 C' ITH0=-PWM_Value1[1]/256;1 X2 {0 D" V# |$ j TL0=-PWM_Value1[1]%256; & ^3 O( D2 K8 i vbreak;8 b9 t7 `. F& J. ` case 4: O& `0 p, ]; K: N! P3 J; ?PWM0_1=0;( {3 R$ z, w1 w% e6 q" f$ k TH0=-(3300-PWM_Value1[1])/256;& w+ e- E) a' t. O9 S TL0=-(3300-PWM_Value1[1])%256;" l4 S+ `2 E! p+ l; \6 a# h2 b break; 2 _: ~8 {$ q* D: T# Scase 5: # T& v" o1 g* d, Z! L. DPWM0_2=1; " t5 k# e6 ]8 B. R& }TH0=-PWM_Value1[2]/256; 3 J) C6 C, j4 ]) QTL0=-PWM_Value1[2]%256;. h. i0 P9 N' ^1 t( K, N break;4 E3 Y5 Q8 h( |* w% C5 n8 u; d case 6: 8 t; }% Y* | A0 V0 I% uPWM0_2=0 ; 7 h( n: w* R3 m5 r9 RTH0=-(3300-PWM_Value1[2])/256;4 `$ s, `+ Z) \* H# f6 u TL0=-(3300-PWM_Value1[2])%256;* o) d, s- S9 U$ }3 m" D break;- k, C J3 x- J8 B% u( S case 7: & A2 `. o) ]) i* {3 @PWM0_3=1; ( t. Z4 I _( z& bTH0=-PWM_Value1[3]/256;/ [1 }- N7 [7 K$ M- i: q, d7 z/ T TL0=-PWM_Value1[3]%256; / K( p4 H1 _0 G8 ?0 `break; 9 p0 Y! w9 e6 _- @case 8:. N C* Y' v& b' T PWM0_3=0; 9 N' B/ I: {* N. ~TH0=-(3300-PWM_Value1[3])/256; + Q3 }! K: j4 m7 yTL0=-(3300-PWM_Value1[3])%256; 1 ^% J3 H7 q$ q* a0 `break; 1 V \3 F; d* y% N- C2 C- Vcase 9: / v" {% p+ X" i6 A3 EPWM0_4=1; & R2 X. g6 V8 }7 |% {/ LTH0=-PWM_Value1[4]/256;! p/ p5 a& O, t, h' W' n4 ] TL0=-PWM_Value1[4]%256;7 j; K! q4 V0 L6 R4 G! a break;7 Y$ X- k" K% T/ d7 N' n \ case 10:+ H) t7 n6 c5 q1 [ I7 U, Y PWM0_4=0; # b( G. q- m! y5 h0 }TH0=-(3300-PWM_Value1[4])/256;4 x) O; `: N, { TL0=-(3300-PWM_Value1[4])%256; 3 [0 B0 @* w+ v( _1 tbreak; 7 q$ C3 t" K" ?; @3 y% F: Rcase 11: ; s) n W# X0 K% z/ {7 R1 w0 XPWM0_5=1; 2 T* N+ K! Z5 L0 l q# t" zTH0=-PWM_Value1[5]/256; . t6 T" v. ^0 T" z) T& o9 uTL0=-PWM_Value1[5]%256;4 E9 X2 u0 J# q/ e+ P; K8 w- @ break;% }6 H: F" k' |$ R case 12: 3 t- y8 t5 B* b( oPWM0_5=0 ; ' O, H7 U+ s! H: A: Z4 |TH0=-(3300-PWM_Value1[5])/256;' R- M. R2 `! H TL0=-(3300-PWM_Value1[5])%256;6 M2 R3 w: ?) q$ `# D2 a order1=0; " o8 P! ?' j- ?4 rTR1=0; / |" R$ o1 t! k) q `2 Wbreak; 7 K9 w+ ]* L' D# C) {} & [: o: @! R- z, B; d$ j _order1++;) y5 c, m0 F1 A" c% U } |