嵌入式开发者社区

标题: upp问题,在SYSBIOS下的应用问题 [打印本页]

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?
3 x9 V) x$ c  K. ?' p' `7 ~
Void UPP_TASK(Void)
* K& J" \7 V- X- r9 B" m6 p! s{/ B5 T* i  I! g9 l0 U3 P

% N# q1 X* f* e) t; V    int i,j,k,target_int_count=2;
! o' O1 Z- C2 j/ O6 J7 G    char ch[2];
! [; l7 z( T* A* d6 s, m/ d# g2 J2 H7 y

8 C- Y: R3 }5 t' g7 X: j0 N! C+ I' }: B. Q; V  n
    upp_interrupt_count  = 0;3 }( M6 B0 N6 D6 V" ?: Y
    upp_error_count = 0;
. [, `) k- W$ z! T/ |7 u( D- w
$ _2 R% L1 F6 n    UARTPuts("\tResetting uPP buffers...\r\n",-2);' P% z/ S7 a" z1 L" o. P7 t8 w
    // Initialize data buffers/ T0 ?$ T( x, f
    for (i = 0; i < upp_frame_size; i++)
7 C: J& K0 \  U9 G1 E% X; Z3 c! C4 E    {0 ~  Q& L6 x+ R+ d, U" q7 k
       upp_buffer_b =i;
& _2 k- i) {/ O* m0 M$ |       upp_buffer_a = 0xDEAD;0 ^* S  z% p  E
    }- j6 ]& }$ e! ?9 Y

4 o0 Y' B# |) c1 s' }  r    //for(i=0;i<1024;i++)
: {0 d6 G/ j! s/ l% s& X3 q    //    temp=0;& R2 R( a) c+ m0 E9 Z

& F& W. V- p+ S1 |, \6 G* ~' M, X    //UPPReset();
. H; i5 w; x5 z5 o6 ?- U% e5 q    /*启动UPP DMA传输*/8 w( b) h" O2 N7 ]) ~" |
    UARTPuts("upp_prog_dma_i\n",-2);
8 R" C( y% B/ K0 K* f9 ]) h    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;
# D* a2 H* s' W/ s    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);5 f3 _! T3 V( c. d) i' C# ?- q; E) O
    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);1 I; M' x8 Q' s' G, ^- q5 D

5 |0 e5 V+ E6 w    UARTPuts("upp_prog_dma_i\n",-2);/ ]( ?7 I4 V! h" f  o8 z
    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;
1 ~% O. n; U4 g, {1 I$ m    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
# s5 [+ p( f. f1 U' p) J    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);
' y5 V" j+ u: ]9 M. w2 c! V/ p2 B+ H, ]
    /*等待UPP传输完毕*/8 f: }, w) E. O  p  p3 R
    //i=0;! O$ }3 K0 B7 }, |/ ~4 F
    //j=0;4 {& {; h  K- q: q7 A+ i8 K, [& [2 L$ d
    while (upp_interrupt_count < target_int_count && upp_error_count == 0)# j" P3 y! r3 F+ U
    {
# b* C) G+ j: d5 w& [" ]4 W        /*  测试UPP传输的同时操作普通DDR数据
! k1 g5 x  h, L! P3 @3 t  w/ h2 K        temp=i;: y& `  N- p8 C" Q8 G  c
        i++;6 z' o$ G7 c: K
        if(i==1024)% U6 }9 J8 e! T: b" Q
        {! I5 d' [- g5 c9 b( _# X/ i. E' L
            i=0;. j" |3 J( t/ H% V" F* E5 U
            j++;# d) g2 S! F) I4 x+ C
        }+ j" O8 s. q: z$ G7 w2 f. [# c
        */
# L' P# d7 _: G5 t5 @! D! I: _2 ]9 e, s
       asm(" nop");% Y- c3 K2 l6 _0 k4 ?! ?

5 I# r5 _2 _5 z( a  a# w7 X8 o7 @; I       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);
' o( s0 q( F/ B! Z    }
; g* q0 L! `, w  j6 }
7 M7 f) S9 I4 A% v  y, o% P1 \0 s    /*检查UPP传输的数据是否正确 (loopback modes only)*/( b9 R# Y5 z& A% ~- ]2 c5 s- ~
    //UARTprintf( "i=%d\n",i);
' Q+ t% Y$ N; O5 J  m# n) r    //UARTprintf( "j=%d\n",j);( `- Z# V9 u, T" ?9 Q2 M
    UARTPuts("Data mismatch in buffers.\n",-2);
! f+ ]* }( {" k4 N# U: T    if (upp_interrupt_count == 2 && upp_error_count == 0)" K8 r( A# i+ F; p' y
    {" v6 X5 a' ?# a8 `7 R8 O. s
        for (i = 0; i<upp_frame_size; i++)
: e- `( Y( f1 }) M1 [8 \; i% g( l" N        {
( q; P  z9 }: w/ W" A            if (upp_buffer_a != upp_buffer_b)0 K9 f8 i1 s) I; B3 F0 {' t
            {
2 n: w# r# I2 s5 L) z, i! O1 U                upp_error_count++;
* q- t8 k: x/ i! {3 w+ j7 ^            }
- T: ]" f. |8 P# @1 r8 o  {( D. k        }
  Q. M6 [$ Z- k- e" o    }  i, j7 A* e# a( I& b

! \8 ]0 Y3 u1 a5 H    /* 报告通信结果*/
: n4 x0 @  _# ]( T' h. @2 L  i    if(upp_error_count != 0), ]; p" E( T; x  L: C
        UARTprintf( "upp_error_count=%d\n",upp_error_count);- q5 z- u0 ^4 c0 V7 A- L
    else3 p7 a' s+ j. P7 S  ?' W/ b
        UARTPuts("uPP transfers complete!\n",-2);8 e+ P& v5 x2 ]; Q2 X; V" {

% t) x+ l) |" f7 [    UARTPuts("Do you want to print all the data?(y/n)   ",-2);0 d; J( Q3 C/ l
    UARTGets(ch,2);/ Y. B" F5 P% F6 |
    UARTPuts("\n", -2);* b0 P5 s' d& B. e$ U+ X  X

! c8 `" I* j" a/ l. [! W* `$ r    if(ch[0] == 'y')
9 |* k* D2 H8 A9 h9 b4 C6 A( l" i2 e    {; ~) q5 Y) j. _$ K0 m
        /*打印全部读到的数据*/8 X% I  s* s0 B# R: B
        for(i=0; i<upp_frame_size; )
; A: m3 a0 w) {        {/ ?. k6 c- p. H( Z8 ~  o; _/ k1 L: v2 G
            for(j=0; j<5; j++)
# r/ F" q, }  x' k1 ?1 d) ?            {* q0 c4 ?3 [- M" I
                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);
6 D- l9 q6 |* u5 v" e* Z. _  o) T                i++;$ j( V0 M4 W5 P8 \. U: R
                //if(i >= 4096)
' n( ?6 {, ], g9 F                //    break;
+ W5 o: B* F+ v* C7 A0 a+ m. @7 p# v' ]( B2 [
            }
, n1 E( y' f4 h/ E            UARTPuts("\n",-2);
3 {3 i  n0 C7 T0 C" n, |        }
6 _& g2 e* {/ Q& u/ c+ m" |    }/ i# e9 B# B0 W" G! V) a

3 q2 _) p, s: x$ `8 V}

& P  i0 e9 h. r8 k+ J. R8 d9 `

# U* r0 l7 C1 g% Q  w# b4 ~; y+ x8 V7 C4 r7 V3 U

作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。) Q. L4 y) \; g1 l6 T5 n5 S! f7 N

作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。
; Y$ r' o- D* j' a




欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) Powered by Discuz! X3.4