嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?
4 E5 S* B' ^7 y: [; y7 l9 s- \
Void UPP_TASK(Void)
% Z; A+ @$ H7 }5 V# X. n! p* J{: k+ i8 W* c5 _* }

  e6 F( o6 ^* v- j3 M+ n    int i,j,k,target_int_count=2;# @8 e/ K% F# f1 ?: j
    char ch[2];6 J& ]8 r' C3 t3 ?# R* c# u

5 i2 B$ L8 N7 ^1 \
5 Y+ F& W1 N) I: n# s0 i  }# L  A) |/ S: d$ g- N
    upp_interrupt_count  = 0;
3 }6 p1 o: n& F  X2 s5 ^  q    upp_error_count = 0;
! `$ `) ~6 i7 y) @" V, v6 q4 V1 H+ \; u4 x
    UARTPuts("\tResetting uPP buffers...\r\n",-2);# D2 T: M3 f  Q& \0 ?
    // Initialize data buffers
4 R# ?) K' s  V9 I+ A    for (i = 0; i < upp_frame_size; i++)( {- I# y. y/ H2 `8 n" d  w
    {
# S- k- H1 O4 x  f2 z# X       upp_buffer_b =i;* N  ?4 ?2 R5 Y4 @  V
       upp_buffer_a = 0xDEAD;0 @; m0 {7 H: J( J0 B
    }
" I/ U. u  y& ?4 O+ q6 y# |# s* v  r, \( A5 B, F
    //for(i=0;i<1024;i++)
5 L" `+ S' ?% W% B; |    //    temp=0;
9 s/ O. q: y) ]& D2 B1 j1 z2 I  ?+ @( ^* S
    //UPPReset();/ o: f$ E1 @6 C9 @  j! W- _. f
    /*启动UPP DMA传输*/
% ~% ~9 s0 \+ Q$ O5 w' S    UARTPuts("upp_prog_dma_i\n",-2);2 i5 j/ {8 m. C6 `$ d% X# g
    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;
& G' L" O* s! r    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
0 f! c) @9 S7 O    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);
8 a! d, ]' ^+ }" _
. r- V+ {7 {; n! x9 _: X' f/ K    UARTPuts("upp_prog_dma_i\n",-2);
7 f  Y1 l: o0 ?    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;1 Z* v$ `9 O4 ]: a/ ^. x4 [- b
    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
" E5 g% v" f0 H5 ~# X- x- H    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);
& I+ ]$ E  P/ z! x" ~' R# O8 B
5 u  D# T  i4 C7 y, W, Y/ x% B    /*等待UPP传输完毕*/# w3 a/ d7 Q3 h8 y: x
    //i=0;
* B# g. K% `/ [4 _. c    //j=0;
' t) n7 `4 M* b1 Q    while (upp_interrupt_count < target_int_count && upp_error_count == 0)3 C; A! q8 T- L6 h
    {
* P! m3 {  x$ i1 W        /*  测试UPP传输的同时操作普通DDR数据
4 N- o3 C+ P5 ^# O% F        temp=i;
7 q1 p1 E. c3 x* r- w        i++;
7 E9 q- w" N& Z1 q# @3 I1 c        if(i==1024)
, |% G, G5 B4 f/ a% W- Q3 @$ d0 c. S  j! k        {2 C) c9 C# t; s- k$ r% O
            i=0;
1 ~6 A8 w: k) r( `  K6 M5 l; F, y            j++;- w! A# P& J, n% C' ?6 U3 s: E
        }2 g- i/ q3 A7 y# x, c" d6 K$ {3 A
        */7 l  d# U3 [4 J2 y' N

7 _- N* C2 g5 m+ l0 l6 ~0 O5 _       asm(" nop");
( g6 X  `8 P" l# }  t/ s# B' k. e. j, V# B3 d! q- h
       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);( b; u' T- F3 ^& |
    }
3 S' b% F% J2 Q' ?1 Y9 O: o
! m9 y, s4 ~4 t    /*检查UPP传输的数据是否正确 (loopback modes only)*/
. A6 q2 i- I$ j/ q# R/ F0 E    //UARTprintf( "i=%d\n",i);
( ^+ d# F* J) x* c( T    //UARTprintf( "j=%d\n",j);: n& `. z9 P+ p1 c* {! i. e) X
    UARTPuts("Data mismatch in buffers.\n",-2);
2 c- q/ E2 v" U0 _% \    if (upp_interrupt_count == 2 && upp_error_count == 0)
+ F& W$ \3 h  Z6 {/ Q; D# k    {9 ?4 i: J8 N- ?
        for (i = 0; i<upp_frame_size; i++)
4 C. {# b8 I! Z/ N+ d0 U( J. f1 b        {0 e- U8 t1 s2 n" @- f2 G, J+ l$ @  e
            if (upp_buffer_a != upp_buffer_b)6 U# T1 W: J  T( W2 {* H. ?, `% d# l
            {, Y. U0 f+ x' [) o# k! T9 S
                upp_error_count++;
& R; q& R6 [; Y# h8 P: o            }4 ]* J/ a$ s# l* s
        }* ~0 k1 |+ _  \) `" c( W% n
    }
5 ?# D& n7 U. k3 P
2 c' G9 Y. j+ y3 E! o2 _    /* 报告通信结果*/2 n7 r0 h- j$ ~$ ^5 E, j) Y
    if(upp_error_count != 0)7 B& [8 A; }. g  m) {- q
        UARTprintf( "upp_error_count=%d\n",upp_error_count);) S# I+ K1 V' z' l' v, F* Y( |
    else
& P& _0 \$ f, v* B7 |        UARTPuts("uPP transfers complete!\n",-2);
( Z% B2 v4 s7 j. x& b, l0 ]' d; t0 H! `0 d" ^' a  c
    UARTPuts("Do you want to print all the data?(y/n)   ",-2);! U+ L0 g; z; V3 T7 ~
    UARTGets(ch,2);
& n: V% X2 L/ S! `$ o    UARTPuts("\n", -2);
9 E! M7 K$ z; P0 a: m# J" z/ ~& w/ R0 R  n4 s: C
    if(ch[0] == 'y')8 [  j( e$ q4 X, [6 l) Z, c
    {% m& X8 {3 f: o8 e! r8 \4 w  R
        /*打印全部读到的数据*/
2 z7 i- J7 K( U0 a3 d        for(i=0; i<upp_frame_size; )
# l3 d0 `0 a6 F' \1 v' k        {7 x3 l& B! a( R' i! r
            for(j=0; j<5; j++)
1 Z8 _2 b& O- }            {8 P0 H2 A+ m* e4 M# L( W( f, [
                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);. G1 z, @! H3 Q: F
                i++;% _- E- @5 K. i6 j% G6 \* }
                //if(i >= 4096)
" H" Z; o) D& }* K2 N+ a9 E                //    break;
& K% k3 G9 M. ^" ^& [( h  O7 E0 B
( y  e9 F# g$ p) C$ \) o            }0 O- N7 Z. f$ ]
            UARTPuts("\n",-2);
/ y+ B! n/ b0 s4 g- m) J        }
9 F7 G& u; p. K* m) W7 B, x    }/ }4 [) j& j: N
  S6 b! S; s" U" F- U9 Y7 F
}

, A6 h. F- x) \; j6 {. r/ L; S  W

7 Z+ D0 G3 s* H$ X9 |( x5 S  `- A. e8 S' U, s! ?

作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。% @8 ^, ?1 ~- a

作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。! ?  J5 a* @9 ^' B+ o  `5 r





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