嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?
" o% W1 \, Y4 Y9 _: h$ j
Void UPP_TASK(Void)
# W) X$ N1 g8 j+ Z  n{' J) Z3 a+ h- D& m9 A
" n0 k# y2 d+ h
    int i,j,k,target_int_count=2;
5 y  G- |- f5 ~: ?( d7 J$ R    char ch[2];/ I6 D, g+ p5 e8 ?! Q( [
0 R$ v! _! g3 ~9 a2 s# [
$ i- ?& f' {8 N' c

% F) D( E& e/ n( g    upp_interrupt_count  = 0;" k" ^: d7 ~4 s6 c
    upp_error_count = 0;) m. f* y5 T1 S
: s5 P0 V6 e' K4 h+ F  _
    UARTPuts("\tResetting uPP buffers...\r\n",-2);
3 [9 f5 k( g: L9 U' I    // Initialize data buffers1 U6 D# F: I: V
    for (i = 0; i < upp_frame_size; i++)) p+ b* N# N9 i  |) p- i) ^
    {+ ^7 T- Z8 ~0 q
       upp_buffer_b =i;
( f& I6 L+ t$ ^3 m* m3 y( }       upp_buffer_a = 0xDEAD;0 s4 r4 U6 g- I' ]2 o
    }
$ ]% k/ f4 I+ C% v8 B
8 R# u  b& x+ H# k    //for(i=0;i<1024;i++): F+ ~1 i0 q5 V, j! `+ n
    //    temp=0;
0 i2 S6 k3 h2 K0 e/ O1 Z) {% M$ Y9 ^  \  Y" z; |+ b
    //UPPReset();
# e" W& `" a' B    /*启动UPP DMA传输*/
: S$ o* O3 D6 ~& W1 a5 n8 {    UARTPuts("upp_prog_dma_i\n",-2);6 f' v4 G8 m# @4 y. g0 \* V, c
    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;  l3 _0 Q! O8 ^  ?+ S' Y, }
    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
6 T& Z) h2 |4 t; U    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);+ o5 D  d1 G4 o; ^! [$ U

: P) g9 L' y$ X. G8 D    UARTPuts("upp_prog_dma_i\n",-2);" n2 m6 Z" m/ A. p. q- X
    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;5 e* c. s; n2 Y  ~
    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
- k. W7 b6 X* n7 v; }+ b& C+ B    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);) }( u; U% t0 ]% \" m, k
4 O7 z) Z  H2 `5 @% z+ H" |
    /*等待UPP传输完毕*/
% |* M( h6 ~; o: e+ `    //i=0;
0 v9 U3 F! Z7 H    //j=0;3 _: _8 c6 B: {1 D6 J! K
    while (upp_interrupt_count < target_int_count && upp_error_count == 0)
- W8 o" P( M' i. Y& E    {: A8 q  A+ ~8 m* b  M, s4 j4 g
        /*  测试UPP传输的同时操作普通DDR数据( Q2 f' \9 W9 ?% {
        temp=i;: A3 W9 M7 m; u/ i6 {3 A
        i++;4 z& R' G, t& w, O
        if(i==1024), X) j( L1 _  v+ ]) _  d
        {
3 |( K5 M" ?6 `& Y; V2 q5 _            i=0;
* b1 F' G. O) a' U- R            j++;
8 F) a7 x1 i# V5 ~* s- d4 Y        }
3 l: n9 J  {" T1 l        */) a' _: Q$ U$ f: X8 V

! m9 x5 H  X: Z' W' X4 K% A       asm(" nop");
" V; G" N& \0 B+ d: q8 E. D' H* s( t& D0 L
1 Y4 \( N+ Z) d' _1 ?       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);
6 q5 n$ @& f# {- \8 K    }
8 o0 x9 V9 ]" P) L
$ ~! F5 L. U0 c" z  x. U    /*检查UPP传输的数据是否正确 (loopback modes only)*// X+ Q# [, J, d6 _. o
    //UARTprintf( "i=%d\n",i);
! i, D1 }) k7 R' t! j+ A! g, ], s% }    //UARTprintf( "j=%d\n",j);
4 U. i+ _0 L" O9 X# J2 P- V    UARTPuts("Data mismatch in buffers.\n",-2);( o' l9 P# H0 [6 U$ z: q$ F
    if (upp_interrupt_count == 2 && upp_error_count == 0)/ P4 Y5 l! L  }
    {8 Q1 ~& H9 y4 S7 G
        for (i = 0; i<upp_frame_size; i++)
/ Y5 b3 [! n$ ^0 N6 c% ~. [) D        {' S* D1 i3 ~" c4 c: l7 |6 z
            if (upp_buffer_a != upp_buffer_b)# n+ @; F% K+ v* Z# b+ O
            {4 }: w$ n* k# D1 N, z
                upp_error_count++;
% z& j& s- e. l+ a            }3 \, O0 g. t" f9 y
        }
* z4 ^; ]; I) K2 l) J# J    }! n# o2 `. R- ?) J; T
: ~1 J, A, s& Y2 O# m
    /* 报告通信结果*/! c4 N0 m( j' J: o' U( O$ U" ~) K
    if(upp_error_count != 0)  x1 N$ a! {3 u% ^* _
        UARTprintf( "upp_error_count=%d\n",upp_error_count);
* X* u* }/ L4 {* |    else3 f4 i1 m9 e" P3 x+ O# X
        UARTPuts("uPP transfers complete!\n",-2);
) U( \4 R( |- I" w2 o
4 h9 F5 F- X/ U& T    UARTPuts("Do you want to print all the data?(y/n)   ",-2);" Y" K# c+ I! D( H; A( M" e
    UARTGets(ch,2);9 c7 m* [- L5 C* \* H0 R' P
    UARTPuts("\n", -2);4 o7 T1 {# x+ E; X$ O7 c" C) F

4 b3 s4 e/ U  ?, ?- m( l& ]    if(ch[0] == 'y')
, r: l5 P: k1 P8 Z$ |    {
5 _) Q+ ^4 j; l  a/ |$ X        /*打印全部读到的数据*/5 w# e. ^; j5 a, f2 F; X
        for(i=0; i<upp_frame_size; )1 X. v& {* o: q  e
        {2 H" H! y; y1 P3 l
            for(j=0; j<5; j++)) @' x! ]* {; h) v( h* A
            {
- k' j9 y3 ]* {  _7 T0 G" g                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);8 H) d  D5 y$ u# E+ q, {$ X
                i++;8 g% Y1 [1 K2 c; X( J/ f3 j
                //if(i >= 4096)
6 e1 J: k2 [+ A+ W7 r6 m                //    break;
" q. s/ Z; {- Z
) K( K& I! }: q2 J            }0 ~0 O6 E+ S3 R# Z
            UARTPuts("\n",-2);
* S- w: Y0 ^: }6 z        }* V5 M# x9 y- R
    }6 @, m& `# Q, ?: _2 y% l
+ q( M* ^1 ~" ], y; f, Y6 C
}

" m9 _5 ?- |! g

7 E' g& y0 o6 ], P1 y. e% w
: R% q5 W! Y  U- ~; P
作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。
" Q- B- \* x2 |# S& _- F& t
作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。- b' T  _( d! j8 r- l  ?





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