嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?
1 l* b: I+ `$ j; g0 ?8 h+ |
Void UPP_TASK(Void)/ I: o. f4 M$ `) g( N' I* r( Y
{* G7 G! a; h4 y) T5 h$ X

) H7 Z( W+ j7 @7 n  R4 U+ }0 x    int i,j,k,target_int_count=2;- ^& `3 s' y/ D4 j/ L
    char ch[2];( P6 t3 M% V& l7 ]
8 h' k/ G0 P2 y) m
. }- B+ @) G. `1 U5 O! W/ Q
# T; S/ ?/ r- ~; q- V
    upp_interrupt_count  = 0;! p4 y3 P% F# |
    upp_error_count = 0;7 ]  H7 t) C5 f# c
9 T. S# ~* `, I
    UARTPuts("\tResetting uPP buffers...\r\n",-2);+ U5 j7 w& q2 Z7 Y8 y3 b: `2 U2 J
    // Initialize data buffers
7 j: Y& V/ P9 V( d6 t    for (i = 0; i < upp_frame_size; i++)
! x6 F) p9 N- S9 k* ]6 k    {
, `% b8 N! s$ ^       upp_buffer_b =i;0 A% Z% @! K3 D; C7 \
       upp_buffer_a = 0xDEAD;
+ e, B# |; e( g4 G5 j    }# C7 n" T$ f$ ?+ R, }, y! u1 l
, e4 s0 h. V( [0 X7 N- L) M
    //for(i=0;i<1024;i++)
# P7 d6 `" ]4 l- k3 j1 _7 J* q( v- S# n    //    temp=0;
! K- J8 q' h: V- F, s8 I3 O/ C8 a5 u1 l! {4 f
    //UPPReset();
) m& G, M8 w7 z0 u- G. ?    /*启动UPP DMA传输*/
6 l. ?9 ~+ W) ~. {    UARTPuts("upp_prog_dma_i\n",-2);! W# P! c1 d) [  {' ]* v* d) w5 E
    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;
' `6 D! }% A; }# j$ |7 v4 f/ x4 Q: X/ t    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);7 F$ H' N1 b7 \2 V2 h# A, h* I
    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);
$ n+ }" G6 C$ M& [& K/ T: j5 s4 y5 T3 V; K3 B4 M
    UARTPuts("upp_prog_dma_i\n",-2);
4 E6 G: ]% F1 Z. u1 h    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;
* o" e" \. Z! T* F- O# I! u1 T8 d- V    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);1 N' C- m+ i, B, v& M
    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);) O% x- Q# H. }* ]

  j* i3 O4 z; U$ S* q2 b    /*等待UPP传输完毕*/
8 n' O% U- [! W2 d0 t    //i=0;
3 N+ z- j8 M2 @* c5 R7 f/ I    //j=0;* n+ o! P% M2 H9 N* I) `/ W! ~
    while (upp_interrupt_count < target_int_count && upp_error_count == 0)
/ J! k9 {7 B3 \$ Z+ \  ]( `! ?    {
$ S2 j% K2 P$ ~# Y- U        /*  测试UPP传输的同时操作普通DDR数据
5 i/ v! @6 D& J. A& L2 n        temp=i;& q7 v, x- t6 z* [
        i++;
: ]% W) H' \& c1 x- [9 |9 F0 z        if(i==1024)
- l  P4 }: V3 z- T        {
) f9 r, K1 q) g9 ?- j9 ^6 m            i=0;
' ^6 G/ B8 D; t/ G' ?            j++;
. {1 Z' B7 v: J- p        }  x9 e) o% V$ W4 r' Z! r$ V
        */# ~$ P7 P& \  E8 k. r0 r, l
. Y9 ?: k8 `7 ?' f+ o% A8 M
       asm(" nop");
  y8 r5 A% S( Y& |* c; |; g- M: P# s9 L+ V+ s) i9 o$ B& d  `. [
       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);  {, V/ a0 V# m, k
    }
' C% D- Z# o) K' j0 S/ f7 S3 B! @& _- J) r8 \( A/ @
    /*检查UPP传输的数据是否正确 (loopback modes only)*/( i% O6 r1 b4 ]5 _
    //UARTprintf( "i=%d\n",i);
+ m& Y# I# N  s2 O/ a6 D    //UARTprintf( "j=%d\n",j);3 x4 r3 c1 X* H
    UARTPuts("Data mismatch in buffers.\n",-2);
, s8 S5 C( R5 {: R    if (upp_interrupt_count == 2 && upp_error_count == 0)
3 S+ b4 t* l9 C2 {    {& C8 w* R1 f( G, F0 K- Z) c
        for (i = 0; i<upp_frame_size; i++)4 O) S2 a* S( M
        {  W9 P7 Z! Z* m2 X4 j
            if (upp_buffer_a != upp_buffer_b)
6 w2 N. B& j$ ^' F+ e$ B: E0 C            {
  Y( @/ g0 l$ H# Y  x                upp_error_count++;
8 N* P$ h2 ~- T6 \6 V5 Y            }
5 {7 }! B+ K( k        }0 t0 d2 h  |* ]6 ]
    }" w7 n3 L3 }9 Y
) w! U, G; O- r
    /* 报告通信结果*/
- D% T1 @+ m* [' {; `" j. P    if(upp_error_count != 0)0 b6 d, ^) k: i  M; C
        UARTprintf( "upp_error_count=%d\n",upp_error_count);
. w+ B+ x+ m4 ^0 q  `    else
. q) ]# e; G8 L+ M1 T2 h        UARTPuts("uPP transfers complete!\n",-2);
" m& N1 U& |7 }0 _5 u4 y& Y& e, J9 z8 a9 ?$ S) \$ M0 T. s4 ^
    UARTPuts("Do you want to print all the data?(y/n)   ",-2);$ z  W; `, T0 W9 O/ l% m  I+ ]4 c- U. P
    UARTGets(ch,2);
1 o. e' q! _( m    UARTPuts("\n", -2);. H1 L2 l" O( u# T: M, E
- X5 l, P; M% z0 H, g
    if(ch[0] == 'y')
* O0 k$ P; p9 q  A' K+ \! U! i    {
. {3 y$ D) X/ e( l        /*打印全部读到的数据*/
* ]8 ?* a. {: F* ]. Z" c        for(i=0; i<upp_frame_size; )' d$ f1 c; K( U3 F& a3 H% B' Y/ [- c
        {
# p4 P. T" x1 Z( O0 F3 h) C            for(j=0; j<5; j++)' b3 o$ d9 \7 o, Q5 D
            {. A% Y7 A( S* g0 [: l$ Z! ~' u
                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);
, U1 X. m5 q& f1 ~  b% x+ p                i++;
8 o* F+ f1 ]( P: k                //if(i >= 4096); r) }/ l% x/ O
                //    break;
8 \. a: u4 ?9 ^1 l( a  s% N! H+ t% S9 F" p* F" r4 w6 X
            }
" c3 P- t4 y& B2 p9 |3 F            UARTPuts("\n",-2);7 H; y! [$ T; v* `1 t4 g
        }
+ I) x7 ?3 p+ {+ S1 l/ d    }
, v! M) Z; Z% F' _$ {+ M) ^3 z+ `* p7 U% c" D
}
8 n! M3 L+ r3 B

. J( E4 f& C' ]
' [3 S9 `+ ^, {* m8 r1 [
作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。* t9 j, a/ B. f" A8 Q

作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。
- [4 M/ B, i4 s4 o$ x( X




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