嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?
" W( R2 k. ?3 S; G' U, s) r
Void UPP_TASK(Void)
; S' A, R8 s4 H: g' m' f$ Z+ n1 s! c{. ^5 _2 B9 a4 j* q, C; x. Z* [

5 }; n; e8 L, s    int i,j,k,target_int_count=2;! N: F. D5 ^+ q; A) q! h
    char ch[2];( a4 c* e) k4 r/ |% W
2 N+ X9 b- D5 J- L2 r* Y( c
& ]4 `# N9 ~0 T6 x/ h

0 ?7 @9 a3 \, W+ j, s    upp_interrupt_count  = 0;
/ k2 p, E+ x! T3 [    upp_error_count = 0;
8 Z+ a- P: a, H% y/ v6 ?) F3 y) j
/ J1 Q& j0 u' r3 a6 `9 t    UARTPuts("\tResetting uPP buffers...\r\n",-2);/ {1 U* L$ p. g/ _: `
    // Initialize data buffers
+ o+ X! \6 O9 x. t1 _$ {# C8 U2 B    for (i = 0; i < upp_frame_size; i++)
# ]& L4 u8 e) k5 G5 A    {0 X  \# F' @; w$ _
       upp_buffer_b =i;% o# K' q1 j5 O- |0 l' O) n
       upp_buffer_a = 0xDEAD;% s, ~$ v; s$ \, d+ B% F. V8 G
    }- C! I$ k3 X5 j# W5 {5 O: V  D3 E

$ ^, T# ^6 D" X/ m' d    //for(i=0;i<1024;i++)
* _' Z6 }# x* T1 x6 W    //    temp=0;
& |" M3 p1 c+ Q! T3 U
$ Y$ P( l1 A3 L! f" |  A0 ?    //UPPReset();5 h* S7 K: S* v* c! e* v, m- H, z
    /*启动UPP DMA传输*/
( I7 o& Y# {8 z3 h& f" N  B& X    UARTPuts("upp_prog_dma_i\n",-2);
: o0 P) c, y6 K. n( f9 W' _! k    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;
- Z+ H& ?+ G, Y/ ~9 E+ K2 S1 q    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);' m& t) f" n. a: e$ |' h
    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);
' J4 }1 |0 [# }3 B" J' N
8 @5 O. d$ F: \) W) a1 z. Z% B    UARTPuts("upp_prog_dma_i\n",-2);# V) H  \8 n9 m' c" s- B/ V
    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;
' \$ h4 ~4 F) O    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
1 E& R1 r: D2 \  @4 g    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);  k' }8 v/ ^/ S+ u
6 Q* E" @, H( l9 h/ [7 ~4 u. g
    /*等待UPP传输完毕*/; _0 H' \, Q. P; L* T: n+ j+ T( w
    //i=0;) k* X4 R9 I1 O. u
    //j=0;9 K% D1 i# R+ U
    while (upp_interrupt_count < target_int_count && upp_error_count == 0)
( h6 N7 N% e2 T5 n8 ]* t    {8 E/ t$ R- d; S' X  L: r
        /*  测试UPP传输的同时操作普通DDR数据
+ W9 \* P; x3 i0 f& e        temp=i;9 V* T% P9 w' Q2 N4 B. p1 t
        i++;
, `9 K$ b1 e8 K( E# ?$ x        if(i==1024): |& d- D0 {3 L7 X9 O) |, Z0 U
        {
: O, Y% T4 R. o+ d( ~            i=0;2 ~. O. Z9 c6 T' E
            j++;
5 g+ t9 O# s* L# Q        }
0 ]! X: {2 h' M        */5 X% Y  c) b+ @

; a: X- n* P. P# B" y  I       asm(" nop");
4 T) Q, H8 u* w: y) Q4 f. W1 k! w
4 E* I0 z. m  L1 ?       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);- h* `4 l+ z" d
    }
, c* w& N& P% C3 z3 M; i4 v$ e# X+ u
    /*检查UPP传输的数据是否正确 (loopback modes only)*/, M- f: Y8 y4 j0 M! {% h
    //UARTprintf( "i=%d\n",i);
4 I7 ]% O; ^- ]    //UARTprintf( "j=%d\n",j);) J- |7 M3 Y( W
    UARTPuts("Data mismatch in buffers.\n",-2);
- E1 k8 e& w4 v4 Q' Z    if (upp_interrupt_count == 2 && upp_error_count == 0)
  d# n, f' b" S. G7 Y0 \; u( X0 f( c    {
% m$ C$ N6 {# l) D        for (i = 0; i<upp_frame_size; i++)9 i, G$ Y1 n+ y8 S9 E
        {
6 g: J. w! r" C: J! q            if (upp_buffer_a != upp_buffer_b)
+ D3 W% T8 h# Y, g9 E            {
1 ^5 v# o* \( X7 w                upp_error_count++;
+ v  R, a' v$ z& [  `  c            }
2 E( x! T0 f/ Y% j9 ^  ^        }: H$ j4 C% Y2 A5 k0 k6 p
    }6 f. Z. j3 |, t

: T' N- L# G5 _: x% f0 w, ?& v    /* 报告通信结果*/
( ^9 g3 f0 W' i; b$ L' {! L    if(upp_error_count != 0)
3 \7 S5 y! P( J  {+ `& [3 k2 t( A        UARTprintf( "upp_error_count=%d\n",upp_error_count);' s' F8 s. F( t4 u: A
    else
9 X6 s9 V) w3 u2 V8 W, R        UARTPuts("uPP transfers complete!\n",-2);
* o$ ?* v1 F8 S
4 _3 ]2 W  ]: e! S( `( z% f) u    UARTPuts("Do you want to print all the data?(y/n)   ",-2);
* t0 f- q0 l8 Z& ?% {    UARTGets(ch,2);
6 l5 }3 m8 S: X8 g. ~, Z2 H    UARTPuts("\n", -2);8 O' ~7 @* E, Q/ U5 U0 g* w) n1 p
3 V% R/ O& ]: g+ I: _
    if(ch[0] == 'y')% O+ R0 M1 P7 `2 ^0 c
    {+ h" r1 Z( s% R" c# l9 t
        /*打印全部读到的数据*/! O6 U& {1 G6 t4 M
        for(i=0; i<upp_frame_size; )
" K5 k( w( C: {, x. G        {) m; ]& f, o+ Z! v% {
            for(j=0; j<5; j++)& U5 Z6 M% n* |# r0 ]6 b
            {% E  }( Z; W5 ]# W- }6 S
                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);6 D. ~; y5 p; f: s) F
                i++;
' M& d7 i6 S" p9 t7 {                //if(i >= 4096)$ v) i! l0 m3 }; A
                //    break;! Y7 B" X0 f' Q& e, P( f
+ y% ~2 D) J: n8 ~
            }9 A! U4 n6 I% }6 e  L. B$ J4 Q
            UARTPuts("\n",-2);) i9 @1 ~) N0 Q- P) t% i* P
        }. y( I2 ?+ ~" y' R
    }- E" i) K! b" {  T0 e9 O  `, y
6 n3 C' A* a( T8 \9 r  ~% O6 M
}

% d5 J" B) f% {/ |! F

/ k$ Z3 W4 S$ i6 ]: {' T& E1 l, J: ~, }  K1 y4 G, N

作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。
; e$ v% \9 f! m( C8 A" @* Y
作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。
5 |3 ~* t7 J  F# B7 z, m# k. ~2 y5 E




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