嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?
0 T% h$ D2 D9 i2 \; A( y# |4 {1 j
Void UPP_TASK(Void)
3 J% _# I2 K- @) s; k{' k  m, \4 V% Y* K! T7 a

. m  o) ^% A: p" N: }6 ~: _2 _  y    int i,j,k,target_int_count=2;
# [5 X* N" E; ]) Q" T4 J' {    char ch[2];; y8 t5 v6 S/ e+ j4 |& _
9 `# t" X. X; P* a& G' _! W
1 H( O$ p0 l) D/ i
9 Z: _* a. X; n- s$ Y; ]8 z& C
    upp_interrupt_count  = 0;0 y& a7 E! K( q
    upp_error_count = 0;8 N# s9 K. r; C% n! k# R

& o; J. v1 e! m    UARTPuts("\tResetting uPP buffers...\r\n",-2);
5 S4 Y! h; j. H! Z: l  h    // Initialize data buffers. S; S2 ~& X1 Q9 C8 ?4 A% g
    for (i = 0; i < upp_frame_size; i++)
. E8 s' r9 A: r! I! _, S4 Y+ N* e1 j    {: j& `) o. Z5 c6 @1 m! V9 M
       upp_buffer_b =i;/ S0 y" O/ G6 y1 t* e: u* F
       upp_buffer_a = 0xDEAD;1 I! d4 F- U* R7 U( ~, Q7 f
    }! P$ b8 X, s3 H- o

: }3 j6 J) a7 z) \2 F* f/ y    //for(i=0;i<1024;i++)
- v  g* n9 @8 l) n% P    //    temp=0;
, v8 X5 j6 C' E* C* X& f" T: H9 b. u) Y" B0 J* q
    //UPPReset();
; x3 n5 C* S' k, S    /*启动UPP DMA传输*/4 g1 a% P1 R( _3 |. m
    UARTPuts("upp_prog_dma_i\n",-2);2 {' M5 ]: W3 u" l, P, @
    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;
9 z4 ?2 o- u6 Z    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);5 C% o3 W- E$ X! h) I  P) X
    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);
. s/ l( h6 ]: E( O2 m9 f0 M8 H4 V/ p' J# E- @; ]9 i
    UARTPuts("upp_prog_dma_i\n",-2);
( M/ h+ S$ @& v$ A; U+ D7 n    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;
& X: B* V; D, p8 d3 H+ x, y    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
6 C6 o- ?4 G2 E# K; k# N1 t    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);
0 C2 }6 d5 e/ K7 D7 n" U% f
- [7 Y: J- k9 E& A. Z    /*等待UPP传输完毕*/
* z& y& Q* d! Y    //i=0;
3 \, G  h! g0 {) T+ W5 S  r    //j=0;
( \) g8 W5 S- V% r2 n    while (upp_interrupt_count < target_int_count && upp_error_count == 0)
2 K" i) N" j  w0 Q! P1 ]    {- X, n0 e% _0 L7 [: t2 \
        /*  测试UPP传输的同时操作普通DDR数据( s0 z- C( M- T# h
        temp=i;
# U; h: j  J7 F. K/ |: G6 d) f4 A        i++;0 [9 q; m. q" C8 G, Q
        if(i==1024)5 @. M0 J1 h# S5 E
        {8 w# x3 n/ A* S9 ?# U; [# k
            i=0;, l  I- o, J6 j( O5 v3 A
            j++;
) X$ ?# Q. T6 l$ i- x& S2 R        }
: w" v  n' f. F9 J! Y8 ~# V) ]$ N        */% d7 M  }  E! g7 E( Y9 y0 k7 h
  z  x4 ?  `2 |1 n9 G3 E# X) @
       asm(" nop");7 B3 H" M( `/ s' s* k# t. b
! D: `! N4 U" k2 ]- A" e- L4 z
       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);
! W( \1 s9 `& p5 T9 f    }
3 @8 h" Q7 N) H  R) c& T" b/ I# @5 N( G% b/ R+ @; o
    /*检查UPP传输的数据是否正确 (loopback modes only)*/
! P. B( v- {" O- K. R* y7 w    //UARTprintf( "i=%d\n",i);$ f8 R9 Z4 n; U
    //UARTprintf( "j=%d\n",j);
! _) ]& o$ m1 i" ~; s    UARTPuts("Data mismatch in buffers.\n",-2);
) y- `( s" c- O    if (upp_interrupt_count == 2 && upp_error_count == 0)
3 y+ f3 ?" b. B# s4 b    {
0 B# R+ ]9 H6 s; A! G2 M7 C4 f        for (i = 0; i<upp_frame_size; i++)$ B# g- s2 L$ P! R
        {
; ?' Q( A5 M# w# _            if (upp_buffer_a != upp_buffer_b)+ M0 E$ Q0 a1 F
            {
- B6 \) p# u- h& f7 g- c                upp_error_count++;
0 v4 w4 i# W  Y% P2 G            }0 @9 ~# |$ z! I3 Z
        }' r5 m1 ^6 u+ ^# i) z4 _
    }/ n4 j$ ~  B5 @6 o

) ?& L% H0 J! R/ b% R+ `' P    /* 报告通信结果*/
; |3 ^* t8 \0 P    if(upp_error_count != 0)
( r+ D8 }" \8 R( V) a/ n' ~        UARTprintf( "upp_error_count=%d\n",upp_error_count);. j! x. m/ _# a4 l
    else; i( s2 W% d+ L
        UARTPuts("uPP transfers complete!\n",-2);) D! f$ T+ a2 R* X1 y

$ s2 o) f% p' r' v    UARTPuts("Do you want to print all the data?(y/n)   ",-2);' x* k1 ?. ~4 a
    UARTGets(ch,2);
: ^9 ~' O% B% @8 K! _/ t2 X+ _9 l    UARTPuts("\n", -2);
* G5 X& r! j5 F6 P  [
% I2 Z* n1 f5 w6 @( v    if(ch[0] == 'y')4 ^4 d1 |; a. N; x1 o
    {0 c' ?  c& F2 Z5 Y6 N3 b
        /*打印全部读到的数据*/4 W: y' v2 c5 {- A1 w
        for(i=0; i<upp_frame_size; )! {$ ?7 T7 o0 d% l8 D
        {
: Q, g, _3 |$ \1 P1 F            for(j=0; j<5; j++)
2 j' @$ d: \. n& G1 w            {( {. @0 W* [3 l( t  ]$ l% R
                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);" Q) r9 Z& c4 t
                i++;2 M, [$ Q5 J: `+ w* f# f8 ?! s
                //if(i >= 4096)1 Q8 Q/ D. P! F. C# Y" b- i  G
                //    break;
6 ?' W$ K4 [2 }9 s+ N* a0 n( h9 r3 _$ E0 ^& I' E
            }; f0 \# B' g; u/ C, h
            UARTPuts("\n",-2);
1 a/ }) [3 Q* Y/ Y2 N        }
+ [; {1 x  j( D. J    }
5 ]( o) `) r. R3 Z; x7 }# o. j  J% O& L; L2 b* u% r
}
' p% v# E: ]+ p
& |3 \( }# M$ |3 n

/ Z0 J8 q2 _8 g2 C# B
作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。
& L* n5 i# [; _
作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。
. V' H2 V4 f( p2 J8 h




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