|
3#
樓主 |
發(fā)表于 2011-5-2 18:35:14
|
只看該作者
這是部分程序,前面的程序沒有任何問題,當(dāng)執(zhí)行
* A$ }: a1 O( `8 {case 1: % f: |* ?- f5 ?1 z1 Q
PWM0_0=1;
" K5 U; i9 r4 I6 E TH0=-PWM_Value1[0]/256;
' N* D/ e' i1 v1 S7 r; ^ TL0=-PWM_Value1[0]%256;2 t1 R, D* k# j# i# u7 ~
break;
. T. o& V8 S$ K( c) y6 r時(shí),break沒有起作用,反而直接到了case 12中的這一步1 k* J' h8 q; y* D
TL0=-(3300-PWM_Value1[5])%256;
; U. c9 s( I: ]- a/ j order1=0;% N+ v3 N x7 O& j3 m
TR1=0;) z6 c0 T' m. }0 w3 r
break;. y3 w, _ E/ \' H
}
) p' t" Z3 y( G) z0 b: I( c) V, worder1++;
% _! c" f4 t. }* m在case12中結(jié)束循環(huán)的; C# o, s5 {- X5 {# X% y: I
/*===================================================================================
$ z( p/ ^- q% r3 X3 c 定時(shí)器T0的中斷服務(wù)程序
, K9 g& D! r7 f# O K2 U1 Y 一個(gè)循環(huán)20MS ≈ 6*3.33ms
f6 A4 W g3 k" c# h* P=====================================================================================*/2 }& P& w+ u. b
void timer0(void) interrupt 1 using 1, ]9 t9 e; B& G
{
) u3 h X0 j# I% n4 N switch(order1)/ J, u$ I9 D, e6 V
{0 t/ {& {0 ]5 x3 J# K
case 1: 7 M N. [- z \! o5 `- `) m7 i
PWM0_0=1;
) R: _% S. X/ r2 W6 G5 O5 O TH0=-PWM_Value1[0]/256;% J3 Z; e2 H$ X
TL0=-PWM_Value1[0]%256;- C- `3 r* M3 n7 k6 x, f2 i) P2 D
break;
1 ], L* F' D4 Y! N7 X' Gcase 2: & F( t3 O) \/ C2 w
PWM0_0=0;
% Y, L) _% w/ X$ \ TH0=-(3300-PWM_Value1[0])/256;
* E5 b, D ]- P) U3 h0 b0 s3 s TL0=-(3300-PWM_Value1[0])%256;" L( ~4 v8 b- X( I2 l
break;- g( [$ v E: I( y
case 3:
, w8 N" m+ @7 J: a, r6 }$ C8 p0 _ PWM0_1=1;' ]0 ^& S4 Z7 A8 |
TH0=-PWM_Value1[1]/256;$ Y- k2 j$ y/ g) d3 F
TL0=-PWM_Value1[1]%256;
2 ~) m, U+ w( \5 P; Y break;
- |5 ]/ X3 V1 A' \4 Gcase 4:
: l$ J0 F D9 Z! |% O PWM0_1=0;
8 b/ {0 t& \' D2 j9 n TH0=-(3300-PWM_Value1[1])/256;
$ y8 K7 ^& T' z* L& _ TL0=-(3300-PWM_Value1[1])%256;
( H& @5 i- f9 {& m2 |: }5 }. e( t break;) ?& d- i6 ^3 A# w1 v$ V
case 5:
8 t; E, I9 B) g7 v5 i- W PWM0_2=1;
! b* E6 A' i. y2 n( \- | TH0=-PWM_Value1[2]/256;: I! r. |6 r$ d. B v9 x
TL0=-PWM_Value1[2]%256;: h. T' f0 O* q7 `9 k; h [
break;
- v- G& j6 M9 T0 _6 N" {case 6: 9 ?6 k' ~: ?; N+ u& w0 q+ `4 Q1 J
PWM0_2=0 ;
s0 p, Z( C( L. n7 o# w TH0=-(3300-PWM_Value1[2])/256;
: h" W/ Y) _; k i TL0=-(3300-PWM_Value1[2])%256;+ L; \. }5 o) r5 q8 c* _
break;+ ]0 L/ t& b5 _& P- ^% {
case 7: 8 a' b! r" W* p5 X; J: M
PWM0_3=1;
3 [, @- [- n) `3 z) Z4 U TH0=-PWM_Value1[3]/256;
+ `! k9 l( D u/ `& ^! t TL0=-PWM_Value1[3]%256;
" |: _( T) k) x7 Z0 x5 N break;
& e% J% u, L: \- @case 8: 5 x2 _$ Q0 ]) S9 X% R( ^& e# w
PWM0_3=0;
/ {7 z, V# m1 M% t; {+ |4 S; Q: R TH0=-(3300-PWM_Value1[3])/256;
3 }9 @5 L# Q/ h3 i/ H% U TL0=-(3300-PWM_Value1[3])%256;
8 N1 \7 K l* W# n4 i7 X break;
6 ?( c; C5 E7 R" `* M4 lcase 9: 5 C/ v9 R4 [4 Y1 R B4 u, K
PWM0_4=1;
( e: a1 ?, T ~' F3 l TH0=-PWM_Value1[4]/256;/ U, s+ Z" t; y8 i4 R/ E
TL0=-PWM_Value1[4]%256;
4 A3 J/ f- j+ t* @4 \! z0 f' K. b break;
" v3 I6 Q. Q1 p# n- G' S0 M$ k% ycase 10:
/ @; Z: U e1 h6 a" u PWM0_4=0;
# _0 A- N" w% U TH0=-(3300-PWM_Value1[4])/256;
0 ]& ?) E) `: x& X TL0=-(3300-PWM_Value1[4])%256;
% B; A1 g/ M2 f5 Q. U break;: y2 L `0 o. r+ P% L
case 11:
; n' {0 Y, N9 `3 R, N- i( l7 D PWM0_5=1;
0 u7 H1 d5 p* A, ~2 t TH0=-PWM_Value1[5]/256;/ o& h q! R% D9 G( c4 ~) k/ X& u
TL0=-PWM_Value1[5]%256;- ?& k+ ]* I# A, N3 h @' s5 N
break;9 \9 N$ ~+ b# M ]7 M
case 12:
; I7 ~9 h% W- b5 l PWM0_5=0 ;
9 c& b( ^+ O) i) z& ~/ L; v TH0=-(3300-PWM_Value1[5])/256;4 Y1 p. P p( Y; x
TL0=-(3300-PWM_Value1[5])%256;7 R9 p- B7 ^: J( J' r3 X& o
order1=0;
6 D% P. [* Z3 ?2 W7 O) \( J+ L TR1=0;
2 v+ T8 |4 r9 b, z* w% @" F. Q break;' F1 S9 P5 V; `, k0 k0 g
}+ C5 X5 P. |0 v) m, g* N% o2 j
order1++;( n9 G1 D9 R# x" u: }
} |
|