嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?) e! ?4 v1 Y6 N
Void UPP_TASK(Void)
" p% ^! {4 s  E8 S" S! E$ n3 b{) l5 x' h+ v1 d, g

1 l, `( ]. U' g8 H3 t: x    int i,j,k,target_int_count=2;1 s+ g/ }. {8 f0 p0 r  F
    char ch[2];, E2 e0 W8 W' ~
% @( v4 U6 ?2 |) }' S7 ?
  |/ D  X8 E, k

' y' a6 t3 }5 ?) O: |! Z6 c    upp_interrupt_count  = 0;
) @- u9 ]3 T- ~3 \    upp_error_count = 0;
8 ?+ `8 a. L5 x0 k7 g
4 x0 {; `1 X) o* \    UARTPuts("\tResetting uPP buffers...\r\n",-2);, }( S" q/ H- M
    // Initialize data buffers2 L4 i9 H% S0 [$ b! K- a
    for (i = 0; i < upp_frame_size; i++)1 b% @' n' _1 _3 Z/ Z, {
    {
: N, g" K, \$ \; ^       upp_buffer_b =i;/ Z2 S) K! p: I6 O+ z
       upp_buffer_a = 0xDEAD;
) s5 Q9 r7 v8 e% {    }, N% ?  ?% z0 V" `

9 _; X( `3 \: @    //for(i=0;i<1024;i++)
6 `. t4 S8 m& s" c& z    //    temp=0;
( Q7 z3 ]* r7 K# q7 C- ~2 E: v9 u* Q  ^1 c- \
    //UPPReset();9 ?8 [' S. s9 D' p6 W$ ]' h
    /*启动UPP DMA传输*/- k# ^6 m, r' L) a0 t7 ^* k6 A  ?
    UARTPuts("upp_prog_dma_i\n",-2);: X" P- C/ F) e2 I* m0 L' x
    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;
; }6 O* ]: U8 I' x- M7 W4 k( c0 a    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);  x, `+ J! F5 ~4 I# U% K6 O& ~8 h
    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);  K3 q) m" c1 _8 D' z1 B+ I5 v
# ?+ @3 B3 ?$ w" I
    UARTPuts("upp_prog_dma_i\n",-2);9 f' d. n+ c5 t0 C* `* @
    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;
. e- k9 {) ?* {3 @* p6 [    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);1 P+ m; L! U. O  ]8 z
    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);
: l( a6 S$ e' x" S; d
5 ^- w- R$ {2 f, M6 ?$ w    /*等待UPP传输完毕*/
- V2 s7 Z9 T% P6 c9 U* ~) T    //i=0;
- c7 P# j' m: P$ X9 B$ m0 u% y0 O: e    //j=0;
  J! }+ [4 D6 l- T6 [, Z    while (upp_interrupt_count < target_int_count && upp_error_count == 0)1 b' {! o: O- ~
    {
4 {5 ^5 _& i3 K& I- C, |. E4 y        /*  测试UPP传输的同时操作普通DDR数据
/ p  S, O4 k9 O( Q& N  z        temp=i;' _8 E$ o) E& q
        i++;& P! x7 _% v1 l$ X% m
        if(i==1024)
$ b) O( ~, n! V/ Z9 [& a0 a        {
( i$ ^6 f. J  ^6 l! k" H6 ^# \/ p            i=0;
9 ~% l+ n9 ~, ?- c- h7 c            j++;" u- F4 w  s( r4 C9 [  a3 b
        }/ z; u$ Y5 ?8 ^' E' ~" \+ M- A
        */
$ d5 B0 \1 F( U7 ~1 K  n0 @! \. R* n" r4 [) A4 B
       asm(" nop");
, \  m) `" b  U$ `0 l! J$ i9 y4 {- U: k) G
       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);
, K1 ~  Z: g% R7 t% {7 r1 {    }
4 S( G8 L) w- K$ y9 {5 ~7 Q' g# @# Z5 t0 l
    /*检查UPP传输的数据是否正确 (loopback modes only)*/! W$ L: v4 _, H4 m$ a$ o
    //UARTprintf( "i=%d\n",i);' T) X/ ?" Y  Y  C- F9 ^% \
    //UARTprintf( "j=%d\n",j);/ |! r# l& n4 u  `- g
    UARTPuts("Data mismatch in buffers.\n",-2);
1 Z7 j+ {9 M! S7 o8 t4 L    if (upp_interrupt_count == 2 && upp_error_count == 0)) N3 B  E  O  p
    {
- e( ~8 K- ^5 x- E4 ^5 n: p        for (i = 0; i<upp_frame_size; i++)+ }  t# M7 `9 f8 Y  ~# C5 G! d
        {
. k2 ?- w8 G9 b" w+ d            if (upp_buffer_a != upp_buffer_b)
( U1 Z2 y6 X! M2 W/ t            {' I2 l9 P5 y1 q' e5 q4 Q
                upp_error_count++;1 E$ ?% x/ e: ~8 U
            }4 F! t8 m6 f! |9 H; {; X0 j
        }4 Y5 }2 i1 Y& w) v9 \1 A
    }6 c9 q; L; C& B) r% ]
" J  c1 ^; P( E5 y) S& Q2 J
    /* 报告通信结果*/
6 I0 d; k* H/ x; s, r    if(upp_error_count != 0)
8 T& E% T0 `( ^        UARTprintf( "upp_error_count=%d\n",upp_error_count);
6 O0 O* }& r$ x, }5 V( ]2 p- N    else* Y  h$ e+ w( j* {2 P
        UARTPuts("uPP transfers complete!\n",-2);0 E7 O1 H) M/ L  E) _- ?. z# ~

. Z7 m' e( t1 S9 W  t3 n8 ]    UARTPuts("Do you want to print all the data?(y/n)   ",-2);
) Q& d; d% P2 D) x- J, m    UARTGets(ch,2);
# H7 W/ z* I5 b    UARTPuts("\n", -2);( p+ d3 u6 L2 U% l, u% k" J; k
4 B  E3 r0 w3 @
    if(ch[0] == 'y')
) D% P9 n% `1 y; ?: A6 y' {; s    {# t0 [0 O  Y" f* G9 _/ M& {+ J
        /*打印全部读到的数据*/" C: S  B& n& [5 z' J) Z3 U9 P
        for(i=0; i<upp_frame_size; )
. R( G6 B7 \4 a* H* g+ g  m        {
1 Y1 u3 [9 B( e$ ?# g; W            for(j=0; j<5; j++)% C1 Z& ?8 c0 ]6 I0 b5 y
            {/ B! X3 k' f* h" u( {6 m( O1 s9 c
                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);
) F# Y) K; g4 m# d* _                i++;
4 ]: k" N, u1 x7 d  T7 X) _                //if(i >= 4096)- M) }1 L# ^. {3 q
                //    break;& n6 H, f/ ]# g
; p- S* F. [/ V$ W
            }
  n* l- ^5 a' i            UARTPuts("\n",-2);: I9 @+ _4 ^1 z9 t4 P! s1 H6 K+ {0 S
        }
. n: m# C3 \' o    }! G0 Z" G9 [+ d1 Q

$ y* ?1 k/ z, D2 t. Z+ j; w+ G}

. F: P( c" `/ c- c1 D( J
! R6 Y" h& x: x8 r
/ h( a/ W' U2 f; V( C1 @

作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。
9 |& C& Z$ I2 X8 C
作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。
" n0 ?5 Y( q4 S7 O/ z. O3 C




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