|
3#
樓主 |
發(fā)表于 2011-5-2 18:35:14
|
只看該作者
這是部分程序,前面的程序沒有任何問題,當(dāng)執(zhí)行
& ^9 k$ L$ T2 O$ |" B) Ecase 1:
8 m, r$ O* a4 s7 N3 f3 N/ W8 X PWM0_0=1; s* b0 L5 @2 [8 d5 o& @( |
TH0=-PWM_Value1[0]/256;
! ~/ g* m# T5 b8 D' y3 G8 {" k; B# B TL0=-PWM_Value1[0]%256;% x$ c* I6 a0 F" p% r5 k- U% G
break;
4 _- r" M ]1 b" ]# _; {時(shí),break沒有起作用,反而直接到了case 12中的這一步
4 m2 Q' u P* \8 A# \TL0=-(3300-PWM_Value1[5])%256;) }" X& c4 V4 [1 O" j8 q
order1=0;7 V) d9 @* a8 [& B
TR1=0;
) Y+ O" q2 J$ `9 F* C break;+ c! _9 W8 p5 E9 a4 ^5 J1 K3 [
}& l) t/ J1 A5 l; }( J3 P8 |
order1++;$ D( y3 G2 v4 Q) _: q: N4 U
在case12中結(jié)束循環(huán)的
* B, D6 y' Y0 ]/*===================================================================================
! [4 Q0 Q& u$ a 定時(shí)器T0的中斷服務(wù)程序
: E. u0 w" C5 Y+ C 一個(gè)循環(huán)20MS ≈ 6*3.33ms+ P* N: O' q8 f7 }% h: s- K
=====================================================================================*/2 M: V2 n5 M1 H$ q7 ?2 `5 p; l" S6 X
void timer0(void) interrupt 1 using 1) @1 z8 ]9 q( R& J% v) O
{; T( r4 L9 h7 L6 I& \2 u
switch(order1)
0 L* E* R3 v0 R. n{
1 [" K' D( m% G d5 x( R4 pcase 1: : N/ h6 R3 E' o& V9 F5 l' B6 a
PWM0_0=1; B$ J) A5 }* s% _
TH0=-PWM_Value1[0]/256;
0 g- r' S9 Y) V6 ^. B& @7 ^ TL0=-PWM_Value1[0]%256;
9 n0 }) m/ Y9 f Y9 M5 j break;
0 I; a Y6 V7 c7 f c" dcase 2:
/ J7 j7 ]2 n8 P PWM0_0=0;
$ T/ N8 Z4 ^/ l7 H4 a TH0=-(3300-PWM_Value1[0])/256;' \1 B; ~0 \0 Q9 U2 o; \. Z
TL0=-(3300-PWM_Value1[0])%256;/ W" L( o9 @+ P( A* O
break;0 F i3 G3 K+ Z" L8 W
case 3: # Z4 ?. ^" |% d @
PWM0_1=1;
1 B- q% `8 s6 W; z1 K3 r6 t5 Z$ X TH0=-PWM_Value1[1]/256;
0 m( W7 o( y0 W* T o TL0=-PWM_Value1[1]%256;
: {+ I% Q' A9 ^8 V break;
, j2 }6 ~: {6 r. q; ]case 4:
3 H& T3 E0 d, W& W PWM0_1=0;5 B) N# B5 g, l3 q6 Y6 ]+ Z
TH0=-(3300-PWM_Value1[1])/256;& Q$ M, W5 }3 d" ]( C6 w( c
TL0=-(3300-PWM_Value1[1])%256;
1 D6 Z! E6 ~3 g1 v' T7 q break;
% n- b% |8 \: J! g$ jcase 5: + c% `7 n& s8 Q0 E0 p, C* k
PWM0_2=1;! m7 d I+ U! C. V
TH0=-PWM_Value1[2]/256;( T8 K% p/ C* `& l" l
TL0=-PWM_Value1[2]%256;
& {8 W: j1 B/ k& L break;" }4 N0 {+ P, {. W L9 B
case 6:
* ]3 A% m7 o2 u' J8 E PWM0_2=0 ;
: z6 m4 B; a+ Z5 B- E) y TH0=-(3300-PWM_Value1[2])/256;
8 u2 ]$ g7 f; G/ p3 U( O' f) Z0 k2 N TL0=-(3300-PWM_Value1[2])%256;3 g1 ?8 k1 C# C+ U
break;8 N; ?$ ?+ t1 ^6 ]' |! S
case 7:
* |" r3 y! J0 R4 r$ x PWM0_3=1;8 Q/ Y9 Q. L2 ^- W" T8 P
TH0=-PWM_Value1[3]/256;5 J, o, p9 B& [, K0 v; M
TL0=-PWM_Value1[3]%256;
Z( l @0 p* L" L break;: ?3 t0 \/ N! W
case 8:
| m" e, v0 q' m PWM0_3=0; 4 W/ G% ^" B5 W) T7 r0 V' u
TH0=-(3300-PWM_Value1[3])/256;3 G) i0 s/ _ c
TL0=-(3300-PWM_Value1[3])%256;
& _0 ^9 d: }: Y( g2 p$ w* Q4 ^4 W3 q break;
, m9 {) i4 i3 d Jcase 9:
8 b x" x: S* c/ Q2 p PWM0_4=1;
+ r9 l: d$ U6 @# H3 u! I8 f+ f TH0=-PWM_Value1[4]/256;, v1 C! Y' y5 I/ n
TL0=-PWM_Value1[4]%256;
8 T3 c x- o9 @% z4 K: a5 K8 v% H, C break;- q( r0 a; z* |, R! a3 ]! n
case 10: & q. H; h& z, A) T9 Y; x3 G
PWM0_4=0;
, j& p" P7 D4 i' S TH0=-(3300-PWM_Value1[4])/256;6 A( I( I( i4 K8 N
TL0=-(3300-PWM_Value1[4])%256;
R- }2 _, B$ h1 U8 ~, D break;
: Z& @' i: ^ y, D& @( Y- |case 11:
; R. [5 ?+ @2 C* c PWM0_5=1;
; R, `1 S5 }$ T7 e9 u( f TH0=-PWM_Value1[5]/256;1 J+ D$ n2 m: k h
TL0=-PWM_Value1[5]%256;
0 u' \8 p+ c- S break;) K' [$ q5 r+ w7 F t& Y
case 12: + X2 `8 O0 d q* G3 ^
PWM0_5=0 ;
$ g" y- x J1 s1 U8 Q7 |! N TH0=-(3300-PWM_Value1[5])/256;
/ Y& |1 K6 z" }4 |1 e2 C TL0=-(3300-PWM_Value1[5])%256;
" }- o- J, T8 E2 X& F- B4 z order1=0;
2 ^* W; ^) j0 R; C$ X TR1=0;1 O& O5 |/ B' v2 R8 S# X
break;
6 A& R' y/ U+ \: [ }
' M! G" s a7 Korder1++;
3 K4 D, Y% f! t6 d/ c3 {} |
|