嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?( X% U% c, @3 P8 m/ i, ~5 K
Void UPP_TASK(Void)' b6 W7 D; ^4 H
{
: f" a- O7 p; K. e* [! R9 g' y- H$ T0 r4 ]/ q5 r- O* e  E
    int i,j,k,target_int_count=2;  r% O; _! x  @
    char ch[2];% L2 R8 h& B2 {( Z- ^% A! S) }0 ?
8 ?; G6 r/ _2 R+ p; h% v4 ^, C, c
; U( f- B5 K: }/ G! e. K

' |' c+ m' T0 U- P% z    upp_interrupt_count  = 0;* R* c& h  `3 t- u7 i, M' b
    upp_error_count = 0;
# n+ Z3 R0 U3 F2 d/ w# e# q) C! {4 ?& p1 G: N1 c2 f
    UARTPuts("\tResetting uPP buffers...\r\n",-2);
) ^) Z- V, I; H; T5 L8 L/ U    // Initialize data buffers
( j, I% J; ?! p, V' E    for (i = 0; i < upp_frame_size; i++)! t9 B) f. P4 m* N
    {! ?+ {2 @; w; S. }5 @
       upp_buffer_b =i;% S  f, k2 [$ Q- [4 q. v/ x
       upp_buffer_a = 0xDEAD;
% t3 m1 t  W# H    }# J% z, H5 z  d3 ?' y

; V  f  }5 J* {" R& {    //for(i=0;i<1024;i++)
/ w( `8 C. \& }! u8 K    //    temp=0;% E' e! [0 G+ ?8 H7 s

5 x9 w% Z& F2 Z6 A# b    //UPPReset();: K% @: {! |" L
    /*启动UPP DMA传输*/
' z4 t" Z  `0 X! W# G; g6 R    UARTPuts("upp_prog_dma_i\n",-2);- [; n4 F% |# g( n5 @
    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;8 [8 v. }6 E- O
    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);( Z% C8 m9 ?) j1 m$ q9 u; ^4 p
    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);
/ N$ Z5 i. _' {' ^8 h
4 Y- c# b  v( A8 o    UARTPuts("upp_prog_dma_i\n",-2);$ `6 c; Z4 B2 a9 P7 U2 }- e
    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;
1 h+ P3 e/ Z& q- H5 J    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);6 j$ T9 y$ e6 I; d$ |' ~( J: s5 G
    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);
$ g1 S. w7 w1 j; A
8 p: T3 \2 i7 L3 U    /*等待UPP传输完毕*/
* B$ Z$ N. g- l    //i=0;  j- e+ }$ s, m- C( y
    //j=0;* w+ i# z4 F; l& l5 v5 H. L3 g7 a, B
    while (upp_interrupt_count < target_int_count && upp_error_count == 0)
* |  |4 P: y* ]    {% A& ^8 j5 n( l* ~/ e2 f* K
        /*  测试UPP传输的同时操作普通DDR数据
  i  ?" v+ t+ `: }        temp=i;( Q5 g* {7 \9 ]! L2 d- l4 Z$ v3 x
        i++;& C& e: x! E0 B, G. w+ H
        if(i==1024)/ E+ ~2 M+ s1 V5 E! q' X0 B7 ]
        {
- _0 Y; z. S8 o/ _/ B            i=0;/ M3 \9 C* e* \, v
            j++;
6 F6 w: @6 {5 r$ ?1 ^# t$ G5 f        }
: L) P# y. n' H; g' Y- l        */1 m: {' M  B2 d5 O' `( h
8 c% \, j+ i& {: F1 m- l3 O1 v
       asm(" nop");
( E; n7 m0 B( y& P: Y; x2 e$ _5 G0 t% w2 t" U- |
       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);: Q0 T7 W0 ^; }
    }
8 x( [" t$ l  F, X; O5 D3 p6 V
, T0 M! q+ `/ H* D- y    /*检查UPP传输的数据是否正确 (loopback modes only)*/
5 w* I  k" @. N9 n  m    //UARTprintf( "i=%d\n",i);, _; K) J7 Z! o  C1 ~
    //UARTprintf( "j=%d\n",j);
* M9 L$ X9 O+ ]' Y; [/ V    UARTPuts("Data mismatch in buffers.\n",-2);1 Z9 }- B5 r& ^" b
    if (upp_interrupt_count == 2 && upp_error_count == 0)
! t. ]: O. [! Y* Q1 o1 `; M    {; D% }* M) H) i: V
        for (i = 0; i<upp_frame_size; i++)5 C7 O  @. m+ f% ?, n
        {% r& j: i4 @  m" r! `; W
            if (upp_buffer_a != upp_buffer_b)
, f4 A/ B+ P* \+ c8 T/ L3 P            {
+ V! r, F; |4 `' K* |2 _                upp_error_count++;3 h  x+ p# ^: B. u! T
            }/ v& k# l- y$ B9 }, j9 G* v: g
        }
4 ]" R/ x( o8 B3 }; R    }
, J0 ]1 S% u" @8 e8 t5 O8 O$ ?7 r8 f( o8 ]
    /* 报告通信结果*/
9 ?  S+ U" n( H5 B    if(upp_error_count != 0)
) }% x8 E* e: z4 B% o        UARTprintf( "upp_error_count=%d\n",upp_error_count);3 G: b1 _# T& Q. ]
    else
8 X6 d- m+ |# I        UARTPuts("uPP transfers complete!\n",-2);
4 T; G0 |- _3 W. L0 I) k9 H) m* j( t8 e" n4 d) I
    UARTPuts("Do you want to print all the data?(y/n)   ",-2);4 ?4 ?4 A, I5 K: X- L; P, x- q, r
    UARTGets(ch,2);
3 W- n, E: R4 x, z5 u    UARTPuts("\n", -2);5 N7 ?) P2 U# Y/ F" L: H( x- d
+ [* \6 @( e0 g
    if(ch[0] == 'y')9 Q' N+ w. _. I; Q% q
    {
' ^$ R, w1 U5 C7 Z/ F8 s0 W* n        /*打印全部读到的数据*/1 f# n; ]" r0 M: b8 w
        for(i=0; i<upp_frame_size; )
! ^' d6 g) F: `4 s% \# W        {
. w: r) S4 H5 }# ^3 x/ [            for(j=0; j<5; j++). e' D8 h; f" n$ {, g
            {6 \+ e* W2 [1 w. F+ Q. x. \0 a
                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);
4 _, v% O4 z* c( Q9 K, x  ?4 j                i++;
2 L" X7 h# h/ M; h6 v3 B* M                //if(i >= 4096)
- ~+ `& t- H8 ]7 b                //    break;
# c8 ]! `+ g( ~$ p5 d  J1 M) U; T' k$ i1 B+ i0 S: u; P3 ]1 Z
            }. d7 i$ n; L. @3 r
            UARTPuts("\n",-2);
, I! r6 I7 ^  o  h  }        }
0 `* R( D" I. z2 u' \3 e    }
+ T5 I+ k! Q: i2 ], s( U  u" E. @
4 i5 q  i4 N5 s, n5 Q; F}

( R7 M6 a& M/ ]: r7 r8 t

5 Y1 j5 l& H; E3 {) x9 u# u: ?/ H2 ~6 T

作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。
0 B, @- H1 f/ }! c7 d4 ^( w7 e2 h
作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。
: d. X0 c+ R$ ^1 y( \& [




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