这是部分程序,前面的程序没有任何问题,当执行( X t/ I/ v: G2 d" ] g
case 1:
& r0 S4 G: ~ a7 ]+ ~ PWM0_0=1;
5 m8 C8 C( m7 p1 F4 Z* N _ TH0=-PWM_Value1[0]/256;# Q4 w4 O) ?: `
TL0=-PWM_Value1[0]%256;( [( F1 P9 U, M& t
break;/ B2 Z5 n5 ^/ k: M
时,break没有起作用,反而直接到了case 12中的这一步( K, _. p+ @; g) p3 _1 p
TL0=-(3300-PWM_Value1[5])%256;9 W5 n7 W; Y4 a& p7 \ ]% m- G3 {
order1=0;9 c& m. T5 k) U4 a0 w
TR1=0;) H2 L A! ~0 i* E% e, a' D
break;5 B4 ]6 m- b6 e% `, l: H* c
}) Q+ G( C8 Z# C
order1++;6 D M8 R! I! b6 c- Q
在case12中结束循环的
* D, S( C% I2 n, M/*===================================================================================( G' t% T% L2 J# v& {
定时器T0的中断服务程序* H4 d. U- x* V* Q w
一个循环20MS ≈ 6*3.33ms8 O% f. X; Y8 ^. |+ U
=====================================================================================*/' v+ b& c8 ]3 d) O9 }
void timer0(void) interrupt 1 using 1. i, o, }( n+ l: @% X* T
{
0 y/ D4 o9 O) O3 Q- R switch(order1)
$ p. A& S* {2 ]5 b2 z" u1 c{
# y( V/ H* \" ?, S T7 icase 1: 6 U E* O! [. Y& p: ?
PWM0_0=1;
+ o0 k D, l% r# Z TH0=-PWM_Value1[0]/256;
6 f) M9 u( G M% `: |, A TL0=-PWM_Value1[0]%256;" I7 R: o0 s0 A, b, P% q( J% ~
break;
9 `' B; K6 ^+ F8 S8 hcase 2:
( J- X% C5 a4 @! V5 J PWM0_0=0;
) y; a, J. T d/ x5 r TH0=-(3300-PWM_Value1[0])/256;6 e. U( H0 F% O' o* q4 Q, e% u- Q
TL0=-(3300-PWM_Value1[0])%256;
% ?/ z7 x7 H( q' j( x: { break;
: [+ T& ~$ V' ^ c$ n6 @/ A5 Qcase 3:
7 p9 Y1 w3 O( L PWM0_1=1;' Z7 \) }& f2 d! v% n
TH0=-PWM_Value1[1]/256;
, U/ ~9 v6 [8 F! Z9 S. T TL0=-PWM_Value1[1]%256;' C+ \, r" o5 Y a1 Z3 v8 @
break;
5 Y3 E8 n# s* b/ _' P hcase 4:
3 T1 q q; |1 w1 |2 I* w' j PWM0_1=0;
( z- I: V: w" l6 {' W( g TH0=-(3300-PWM_Value1[1])/256;# f3 C4 s2 I" f2 h; [2 b0 F* n
TL0=-(3300-PWM_Value1[1])%256;; W1 e" s& x" K! m
break; J1 i& a# _, U' U
case 5:
) D0 Q/ {9 x: k' ^3 _5 @+ } PWM0_2=1;
4 _: s, ?( s3 p7 ]7 g8 ` TH0=-PWM_Value1[2]/256;1 c3 y* D& u; Q- g, z v
TL0=-PWM_Value1[2]%256;
1 p1 E+ ?8 T6 D break;
( J# e0 N$ C5 O, m0 M) |+ Zcase 6:
' k+ O- X$ ^, [" s$ F2 R PWM0_2=0 ; r; U/ K( I# G8 T8 j0 s5 v
TH0=-(3300-PWM_Value1[2])/256;
3 j- P1 F. D5 j) c# ^) R TL0=-(3300-PWM_Value1[2])%256;1 \0 C* n; h9 L g& n9 \
break;
6 K: d6 @. T# w( r" `9 [case 7:
* q- o5 p4 v* y4 O8 Z! P: `2 U PWM0_3=1;$ z4 }$ d2 s! V5 a2 N/ W5 C- {! X
TH0=-PWM_Value1[3]/256;
1 u9 k6 W' C6 B/ {; N+ m6 `7 M TL0=-PWM_Value1[3]%256;9 B- b" a9 q0 {% U B' y0 v
break;
; ?) e. i0 ~+ ?* P- f2 r. @ h" H4 g/ ?- F& Pcase 8:
5 f8 b. V* h! [# @& u1 W PWM0_3=0; # A$ w# y8 ?3 A9 I; q
TH0=-(3300-PWM_Value1[3])/256;( l" G. E9 K3 V8 c5 K- l
TL0=-(3300-PWM_Value1[3])%256;% |9 [) ~" ~$ U# f
break;8 Z$ ]& R; m7 x, A
case 9: 7 W: a2 V, }3 e, h6 ?
PWM0_4=1;
) v1 {+ T% ~$ c z/ T8 X: m) ?$ M TH0=-PWM_Value1[4]/256;
+ B( t" ^3 F! L TL0=-PWM_Value1[4]%256;; u$ A4 o0 K9 n& G- e; X+ n
break;
1 E$ I: P: k( s% p* J. vcase 10: 1 g8 q& j9 _5 m. u3 ~. Q7 N2 v
PWM0_4=0;& z; O! P& j x; U" ^ d
TH0=-(3300-PWM_Value1[4])/256;
9 e- {: d/ ~' }3 D3 x TL0=-(3300-PWM_Value1[4])%256;+ I, [. U$ ]( M/ g& X
break;
+ u. ^$ y' ~. R( Q3 g9 L* W" E/ ucase 11: $ e; t q6 L! [/ Z- s! y
PWM0_5=1;* j+ L) v$ U0 L
TH0=-PWM_Value1[5]/256;
( Z- g3 |# W, l TL0=-PWM_Value1[5]%256;) a+ M9 r! O+ l: k% u* B4 ?
break;
* Q) g- D) w0 @7 Q9 Y7 p4 dcase 12: $ B# C, U6 S" d+ q6 i: ]5 M+ Z `
PWM0_5=0 ;0 x/ }( E7 N( {- ^
TH0=-(3300-PWM_Value1[5])/256;3 G+ T8 I% ]0 I' u# R. ^+ l
TL0=-(3300-PWM_Value1[5])%256;/ i( [! V/ O/ t& N5 r7 n7 ?9 h
order1=0;
7 Z" g5 |4 H3 X5 o TR1=0;
' n4 L+ M+ {1 z1 F1 S; ] break;
* B" R; v5 x/ i }, c# N: i L' ~5 S. H# u7 T, T
order1++;5 h1 C; }, @+ g- x( A
} |