嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?5 f. k5 u0 e+ T
Void UPP_TASK(Void)
9 a) L! V; A$ y# d% M, u* Q% q{
9 J3 _* D, K# _: ~0 P* m  u4 G
( t8 z9 Q! v4 W    int i,j,k,target_int_count=2;# m5 Y2 A+ Q$ [$ q; t  t7 z4 e
    char ch[2];
$ e) V( l0 l; G, W
6 W! d- ]( W6 z' x' y% @
; W9 c# b) Q, A' [
+ x0 u7 U! m8 M6 ^; x    upp_interrupt_count  = 0;
, i7 o3 _1 Y8 M, E* i+ r    upp_error_count = 0;% h1 y% a3 m# n' `. N3 Y7 A
7 F) G- w' V: N" ]2 G0 l0 m9 P
    UARTPuts("\tResetting uPP buffers...\r\n",-2);% H: R/ x5 x* y
    // Initialize data buffers/ d& D9 k' w7 F) w) e
    for (i = 0; i < upp_frame_size; i++)
/ \3 {$ n* J0 ~+ k3 H1 v, U. S    {& P! W7 E4 u" [3 D0 {% }
       upp_buffer_b =i;
! X" ?5 l7 u: L# Q       upp_buffer_a = 0xDEAD;- t7 u' i$ J5 a; a
    }9 w% f/ K' ^: l; d

: V# h' l; ?* @" G) A% f    //for(i=0;i<1024;i++)* G" R1 p! N1 T
    //    temp=0;
2 ^* }# \* e6 N9 }! \, p
& l% t' h' ~2 T0 o! L    //UPPReset();0 ~. e6 n) h  b9 \5 D
    /*启动UPP DMA传输*/' v& h1 ^$ A6 R7 I# j8 b5 a
    UARTPuts("upp_prog_dma_i\n",-2);3 a3 S, {) ^* ?
    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;
: A9 `8 r( S0 X    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
2 D& h- p" l, E; `9 R    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);: y4 }) l; I1 |1 t
% |( W9 v9 s: u+ `, M
    UARTPuts("upp_prog_dma_i\n",-2);& S! n6 Q$ r2 f) p! T
    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;# c1 |/ Z- }$ }5 s3 y
    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);9 i6 ]; ]$ a( V% m4 K9 }1 E# ~
    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);
) @' w1 l+ F- H$ W" f% G6 S8 e# b9 @6 i' a% g1 ?+ ]; p
    /*等待UPP传输完毕*/3 M$ a+ p8 a9 A# E
    //i=0;: l0 c! X4 c7 _2 q. `2 }4 Q
    //j=0;
) J1 A8 V6 ?- D% p% M" g    while (upp_interrupt_count < target_int_count && upp_error_count == 0)
4 q# E7 _! F" a; h    {
4 {) m* k! F4 e4 D) B- F        /*  测试UPP传输的同时操作普通DDR数据$ n3 {+ U1 d, A9 L- u' |
        temp=i;" l* Q0 q1 g4 X  i8 H6 m% F! a
        i++;
5 M. A% D. ~- l- H        if(i==1024)
* C3 I9 Q+ J4 @- H2 B/ g        {
. y) B3 j, A* ~* M+ t! J            i=0;
  ?0 ~- `4 y) c) m8 l            j++;
$ q6 P( B% k8 L4 ?$ M% O        }2 V" E% H% l1 l. i
        */
3 P0 P; @; K# E+ K+ ?) O
+ W2 N3 g' q# O4 _# p4 t3 V8 K2 K       asm(" nop");! f+ ]# O8 t. G: I# Y; t8 ~' Z7 d
4 y6 ~" I, u& J9 S+ @. Y/ L4 L
       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);
5 F( F" B. m* A0 v- B- p& L    }
# I4 Y7 _7 a3 V9 w/ v( [& z, Z( l/ p+ p( ]6 d6 G" k
    /*检查UPP传输的数据是否正确 (loopback modes only)*/. k( [2 H8 D( n
    //UARTprintf( "i=%d\n",i);
& h7 _  ~" L1 l4 @& `    //UARTprintf( "j=%d\n",j);
( ?5 Y+ A; P! X' q2 `" E    UARTPuts("Data mismatch in buffers.\n",-2);3 f* Y9 ]9 X7 n+ Z0 ~
    if (upp_interrupt_count == 2 && upp_error_count == 0)
' d5 Y) X+ t$ H, x. m7 u    {. T9 D9 s: C+ u/ G/ R
        for (i = 0; i<upp_frame_size; i++); t. V6 K) p+ _+ J/ o
        {/ `6 y4 i( G- \4 n& _% I5 r
            if (upp_buffer_a != upp_buffer_b)
; V  v' \) [9 i8 L4 \            {' {( W6 w, \1 [5 E
                upp_error_count++;
* ^3 h( i2 v8 B. U            }
$ D2 u1 v9 }8 `* T8 s        }6 b. E/ M" j7 W* e& r
    }
: R$ }  @9 U$ U7 J" s: T: q- {% s& T/ d7 f
    /* 报告通信结果*/, h' D* A8 h0 k- B& x( v
    if(upp_error_count != 0)
% I, V/ y  X: q# D& n2 Y8 R4 d. k        UARTprintf( "upp_error_count=%d\n",upp_error_count);
% k8 C4 O6 p8 C  Q$ z. ?    else
- ?: G9 J% v* Z+ c. _) h2 y9 t  {6 f        UARTPuts("uPP transfers complete!\n",-2);
; G- x2 D2 _" s! D7 W0 g, O3 @9 f3 A8 _& Y
    UARTPuts("Do you want to print all the data?(y/n)   ",-2);
9 |; T) p. G8 |( j6 y" U    UARTGets(ch,2);7 r) P* Y6 ]( |( f* G% d- C
    UARTPuts("\n", -2);2 N8 Q8 e, x7 y5 J  _
" g' M) f9 y/ B; @
    if(ch[0] == 'y')
  j, w% Y# g, [/ m    {9 m5 m  y4 ^* B( L& ]4 `- H
        /*打印全部读到的数据*/
  o% C* ?/ s' v        for(i=0; i<upp_frame_size; )# g- k' a8 L. _
        {  X) f" G/ U, t. m* i2 j" R2 Z0 u% |
            for(j=0; j<5; j++)
# P+ b7 A# H3 f, i; c, M+ ]            {
! X6 k4 @$ S- C+ {  ]0 V                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);! H& H+ X: J9 L. m
                i++;
* C3 I+ y0 v( H! h0 a                //if(i >= 4096)6 B3 [% ^  C2 R% h
                //    break;
; A: d2 o2 b- L+ G( ~" h
3 q/ P8 e& D' H6 d            }
3 m& b" p  W" g, k            UARTPuts("\n",-2);
+ Q9 ]8 {$ R5 G3 N, C8 [: A        }* D. m1 E- e- H( c8 D; M
    }; z0 J* h/ C& X1 r  j" r7 o
2 B  L) [2 Q6 Z3 `+ H0 R! g, h
}
. ~4 E) X1 R1 B8 V

' N% e& G( E1 [; C5 y$ y
1 E5 h# G* d. b6 o/ _, H
作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。
& k" \1 z3 _2 N, j: `
作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。) {* J0 C& G) V! g! K% A





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