嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?
( F. B. G4 B& }; N0 {6 {  d+ [
Void UPP_TASK(Void)8 ^3 z9 U, Z1 u7 G0 g9 H, G
{
: T: B, M9 r. a; G% h* z0 J  r1 T2 i" C% e/ p* m
    int i,j,k,target_int_count=2;6 U0 t  J9 y  V8 B4 P$ {+ k$ }
    char ch[2];% F; V" N! I6 W' ]% `8 @
9 T! x: r! r# \% X! `% C
. D0 T+ D' D( H0 E
& m$ u+ Q4 I6 Q+ ^& g$ e2 @7 @- D
    upp_interrupt_count  = 0;1 u" A! E$ y! Y4 A! J% g+ h
    upp_error_count = 0;9 w+ u& H/ G8 T6 O; |& o3 i

1 E; f; @" `! x0 Z" h% q# W    UARTPuts("\tResetting uPP buffers...\r\n",-2);
+ b5 j% y4 g! U, z; ~- ]0 W    // Initialize data buffers- J$ m0 D& x3 w; d4 `1 O" {
    for (i = 0; i < upp_frame_size; i++), f  S" P2 d7 Y' h( y+ }! O. l
    {; U9 s" ?3 L% K" o4 m( E" O# D
       upp_buffer_b =i;, p# v9 |6 Z6 d! d: o( r5 p
       upp_buffer_a = 0xDEAD;: f5 A1 u4 Y5 Z( w# t) B. q/ @5 D
    }4 q- V4 u3 S5 `+ x2 a' V
; J$ v" n- s& I
    //for(i=0;i<1024;i++)
5 M) y- G& S2 E: w    //    temp=0;
! O! x  v) G. l5 B8 H+ B
, |% G( V  w2 [3 B! P    //UPPReset();: ^2 F# m1 {" T4 a; o8 U" f5 k1 ^
    /*启动UPP DMA传输*/' j  r* L6 S) E! \- R& Q0 {5 N3 k
    UARTPuts("upp_prog_dma_i\n",-2);, F+ w* c* K: W, ~# l
    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;* T3 A+ Y/ e% P) G6 t* I5 l
    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
; e+ d8 X3 x  i" R5 A' C- R    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);7 @7 W+ f7 X) ^+ |

- i6 M3 b  u( q6 ^6 v3 Z    UARTPuts("upp_prog_dma_i\n",-2);
. H. P* w: c8 O) w3 u% ?2 z    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;6 q" M8 K, f0 B! e. u
    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);: W# l  u% f: w2 o
    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);
$ ~" ~! M4 X. V. c( p/ k) H0 i: Q1 K1 a: i& h; P( c" Y
    /*等待UPP传输完毕*/
( v- o4 @1 I$ }+ l( c    //i=0;
9 ^3 a5 g# x: B/ i0 \# S    //j=0;
3 t& K/ p1 P# M. t    while (upp_interrupt_count < target_int_count && upp_error_count == 0)
6 C4 Z( }8 q+ l1 a& N( t8 G6 A8 Z3 R    {
+ x8 o. Y$ s  E+ D4 H7 q        /*  测试UPP传输的同时操作普通DDR数据
0 ^: U* ]- Q6 ^! k7 X        temp=i;
; E) f3 z' R! C! t# |! E8 ?; B  j8 x        i++;) H9 p4 o( D7 D- T$ p% d
        if(i==1024)6 d' |4 Q$ B, ~. x4 C! K6 G: W
        {
3 v' L5 h4 `, ]% K' W            i=0;
$ l+ G6 c# V9 w' C            j++;
: q/ R  d0 o& J7 {        }5 G' G; ]3 N2 F, q# t. e6 J) O
        */
2 ]) i2 p* F. o) Z  d* t* V3 d/ d, E" p
       asm(" nop");
( }$ F# h+ r& N2 l' X* k; s- V8 P0 @2 A. s
       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);' z& c1 R: r# K9 u2 b/ x
    }
6 S5 u9 d# E. g& M. u: u. I. M1 h: _4 G" w1 L
    /*检查UPP传输的数据是否正确 (loopback modes only)*/2 c8 `( P& G  g. W
    //UARTprintf( "i=%d\n",i);* b. b) R' L' H0 Y
    //UARTprintf( "j=%d\n",j);
0 H4 I, l0 V" r5 s3 L    UARTPuts("Data mismatch in buffers.\n",-2);9 X3 m+ s# j9 g, b/ ]
    if (upp_interrupt_count == 2 && upp_error_count == 0)/ Y. ?5 ~& I" V- p
    {. h7 i; V2 y7 x- U+ |# ^
        for (i = 0; i<upp_frame_size; i++)
: ~" U! P; C/ ~) G7 F. V6 B        {4 W+ O( e0 Y; q8 E; B! P1 ], o+ i
            if (upp_buffer_a != upp_buffer_b)) o# S0 @5 t0 @" O/ s- V6 W
            {# ~! t4 Z  e1 Y) B( g5 w
                upp_error_count++;
1 S" Q$ R# j7 l- K; Y6 v            }$ X8 Y) I, W: O: O& m
        }7 U# m9 V- {' _2 B6 U, A
    }
" P/ ~7 V. J1 n* M0 @
5 @9 O) ~$ L; W' m* K' b) I    /* 报告通信结果*/
! a+ I# G" p0 Y! b& |- x    if(upp_error_count != 0)
* e" ^1 e. _; o        UARTprintf( "upp_error_count=%d\n",upp_error_count);
4 s. `/ L6 z' a+ ]" w+ e: A    else: s1 C& Q3 H1 z1 |8 l4 I
        UARTPuts("uPP transfers complete!\n",-2);: a7 ~6 t) e: Y& P
. U4 w& g' _2 C
    UARTPuts("Do you want to print all the data?(y/n)   ",-2);0 T0 V  K- U# Y( A) ~
    UARTGets(ch,2);
" i) W( f4 H, C7 S! I. r5 s6 C    UARTPuts("\n", -2);
) B4 I1 Y6 W% p5 s* G) R' F! f% k+ M( g) v5 b6 |
    if(ch[0] == 'y')6 i/ m# |# `) C8 V# t
    {
+ \/ C- v1 Q' y0 X3 |% o        /*打印全部读到的数据*/
9 i% l' i/ c/ ?9 [+ u& Q4 l3 P" D        for(i=0; i<upp_frame_size; )' H7 U: c+ v$ s! H2 f4 g( K
        {' r$ f0 m2 A4 X$ L7 Y' Q5 r
            for(j=0; j<5; j++)
  o4 ?( E2 J/ ^: D5 e9 D$ H: }            {
7 _1 q7 E: [! D, Q                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);
- m" |6 s: R) _! |% X                i++;) K( W) \; k, R  Q4 H
                //if(i >= 4096)
0 x8 @) @# p; |0 B                //    break;
; w% f% y, d5 }4 H9 w" Z9 a3 L
! K6 T' R( D1 N& @0 S1 U            }
. D6 F0 L5 a$ `            UARTPuts("\n",-2);
, }# n9 v/ U- y% n' H        }
: I& w5 b+ O8 W7 s$ L    }2 ^4 U# l9 @4 Z. P' ?8 F# v
; k+ Q# W' i. q+ V
}
+ ^+ [3 q. Q. ]

* [% K! {3 j# b' M6 m
0 s% D0 L5 C: Q9 d) _# f' W
作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。3 w) n; Q7 j! G8 o" f: _8 Q

作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。; W" E0 Y# T1 p' D* u4 q





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