嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?7 O9 n" P2 W' c. d. A4 {" k# s
Void UPP_TASK(Void)
8 t2 K7 x& X8 c; k! s* I{( M* R/ F( l' X: z) Z0 r6 N& Z1 j  Q
8 U5 _' |( j+ Z* n# i3 R
    int i,j,k,target_int_count=2;
+ k& H* j% @3 J    char ch[2];! n7 N/ |8 V! P3 H, `  Z

, G, K% F9 A' E# n+ B, b( R# E, G3 s2 ~6 B- s
$ n) }9 b" p2 }- d
    upp_interrupt_count  = 0;
) X$ {+ E% l% a* H( q    upp_error_count = 0;
6 S( v, k; R- b  c1 [* D+ D1 z" }& e# u: F0 W! [5 s7 z
    UARTPuts("\tResetting uPP buffers...\r\n",-2);
" Z( t4 ~& C+ b: p% F    // Initialize data buffers
2 R5 }1 W9 j  w    for (i = 0; i < upp_frame_size; i++)$ P/ k7 y2 K; L; _5 f
    {9 k2 Z& T$ k0 G# L! I2 T2 m1 U
       upp_buffer_b =i;
3 u8 h' S  E8 K! P$ K+ z, ^2 ^       upp_buffer_a = 0xDEAD;, G9 b! n: k0 J5 n: y
    }
9 O8 {% t4 e) K  z5 a. P" R  D9 L. Z: C! a' @& J# r: {
    //for(i=0;i<1024;i++)
% s" V0 c% e/ |( e& i- \1 T1 h    //    temp=0;
1 D4 w* v# j! U# [7 W. h# Q5 F0 N2 T9 L3 {5 m8 Q" Y
    //UPPReset();
$ l8 A* d$ a( p1 ]    /*启动UPP DMA传输*/! |6 V  ]6 A% R; X) u0 B3 g' b4 E9 g$ O
    UARTPuts("upp_prog_dma_i\n",-2);' e/ g9 H' Z- H4 L0 X' Q+ k: S8 e: n
    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;
7 {- S& T* @$ t5 }% d    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
5 n( N. Q/ t5 J$ L0 _1 ~+ a    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);& \% m0 R; S+ N! V0 j
5 R  }$ D( N; E" W3 I0 O  C
    UARTPuts("upp_prog_dma_i\n",-2);
  b% @1 N1 ]  f& T, j    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;
8 O3 h/ A0 B$ C1 y# W5 `: e    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);5 g" Q% c( y; I" `. X" [
    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);
8 x5 ^- k0 z  n* l2 B& C  o- t/ X5 _4 x: C
    /*等待UPP传输完毕*/
+ H+ r; x/ ~, t" [! R2 H6 l    //i=0;
0 T3 k- e& }5 f: p# _  A    //j=0;& Q% v- Z- v1 {9 Z3 A- o
    while (upp_interrupt_count < target_int_count && upp_error_count == 0)
' l5 S: n4 [7 t& z    {
5 B- \9 i* L& x  I! Y        /*  测试UPP传输的同时操作普通DDR数据) `5 {% f- r% {7 X. T5 d
        temp=i;2 Z) e6 B# F( W. ?& O6 o
        i++;
! i+ n8 V0 n+ L2 _1 |        if(i==1024)  C! O3 g: [6 A. ^( r
        {& `$ c# f1 i4 o! f
            i=0;' E: `, D9 ~* r" ?  \( O
            j++;7 x; W4 Y3 Y. H  g
        }! J6 G& g0 _& p. I+ A
        */
$ F; V" ~  T: N( K( ^1 ^
" n5 B+ Y+ z- _9 C& m       asm(" nop");
" @' B% M# X) X  w: W" ]3 K5 E" b% K/ L  l
       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);- h+ n, e7 A$ W+ T2 ~8 v4 ^# P% M
    }  Q& k9 ^& S1 A# e  Z" y9 N" n

3 G" y  c" k3 K% R    /*检查UPP传输的数据是否正确 (loopback modes only)*/, a8 ^2 B& t' ^8 F0 M( m5 I
    //UARTprintf( "i=%d\n",i);
# \& }' S$ o* T" P) E6 X2 o+ Y    //UARTprintf( "j=%d\n",j);, M9 h3 C7 x+ ?- @. [0 q
    UARTPuts("Data mismatch in buffers.\n",-2);
% [7 u9 Z1 Q& k) f& b$ x    if (upp_interrupt_count == 2 && upp_error_count == 0)
# v" Q7 i3 c- J! W0 n5 |$ c    {: h7 W; y0 u: v/ b1 u9 M
        for (i = 0; i<upp_frame_size; i++)' c/ K1 L# @3 O# F" b
        {  d$ d% W6 C! _1 o, h
            if (upp_buffer_a != upp_buffer_b)( c  u9 U3 l6 {4 p) J" \. L
            {
8 c9 j. n! s* U4 L1 U" c( ^$ b                upp_error_count++;
9 S: D* r; {  \, ^( q3 X! p            }8 i: X- J$ H" }8 L
        }
$ `5 P6 [3 [8 ^/ p* G0 q    }
! d- `$ b0 r/ d+ z$ ]- _  m
0 I4 y+ E1 o$ L( ~    /* 报告通信结果*/8 ]8 W. b( l. r& {% r
    if(upp_error_count != 0)
: v  O6 c* r4 i  M4 `$ g3 D* F        UARTprintf( "upp_error_count=%d\n",upp_error_count);% @+ A- p, T( K- Y! L( f
    else
2 O# N  Z4 q% d" ]        UARTPuts("uPP transfers complete!\n",-2);4 @+ j9 n: _$ n7 V

0 u7 f# H/ i- d# \( J, E, e* M    UARTPuts("Do you want to print all the data?(y/n)   ",-2);
( [) S9 k7 i" x  @( d$ c( J& j' V    UARTGets(ch,2);
" ?1 s7 V, x  B6 B" M/ I% h    UARTPuts("\n", -2);
& C! g% w. i+ _/ q2 @9 t/ p9 u7 l' y2 L/ K5 F  x# y* x! U
    if(ch[0] == 'y'), ?; M/ v6 e1 f9 R. M9 [
    {
% Z# g; V, ^8 t' ?3 [$ A# C( D        /*打印全部读到的数据*/* l2 x( d' W3 w) _( a6 N5 S
        for(i=0; i<upp_frame_size; )
4 U* K5 i( ~" V. P8 V6 r% _        {( R# F$ N7 j- q. o$ R6 o' k* {" Z
            for(j=0; j<5; j++)3 \2 z" c- x- V( c
            {! N; X9 N% ~0 c4 ^
                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);' n- o4 L) A0 k) b5 E* C; O
                i++;
. i$ \7 F& X6 m4 F/ ]                //if(i >= 4096)% |# _2 g% O4 V
                //    break;6 E8 G* s4 y3 T" C& U% I4 c
3 c& J: L# r" D- e. a- k  ^! d' i
            }
. U+ U' G7 g, Q0 s9 s            UARTPuts("\n",-2);0 w; \5 G/ R5 b) w7 U8 g
        }
  d, K' T, ~6 T. ?    }
) ]# G* x! d; F, z; m/ x" F
9 w: f+ s# J5 v. l. r  y# y}
+ C# o/ Z$ f, x' }

% ]( m; U* o# T: `8 j0 I) f
! T0 I/ E# L0 ^4 S
作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。7 l6 h3 a" {  a4 _( N/ h, \

作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。
7 _, J! D' V' `' a5 V




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