嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?
/ c1 \  m$ n+ q: L5 `$ P
Void UPP_TASK(Void)
1 Z+ N1 _. [  s. _! y{
2 P8 Y; h5 t+ z, W' A3 E) e2 X- j% p' J2 p( n1 S0 J# }
    int i,j,k,target_int_count=2;, s( N0 f4 [$ [( M
    char ch[2];! i' o; Y/ o. |* b* Y6 y
- u1 N0 K- s. b* ^6 \

5 e; {$ g5 l  c
0 x3 K; ~' t( x. V) n6 j0 c0 w    upp_interrupt_count  = 0;
( G" \; f$ N5 Y6 s% b) S    upp_error_count = 0;  N' B: ^- W  `2 u" Z, W7 e

4 o8 E0 X% e9 R7 x( u    UARTPuts("\tResetting uPP buffers...\r\n",-2);, A. |5 c7 ]0 x: o5 X
    // Initialize data buffers
# I1 J8 @: G+ j& o3 u    for (i = 0; i < upp_frame_size; i++)
$ `- J9 h/ G; C2 |    {
) }+ W$ ~  F, E       upp_buffer_b =i;! U$ B& r- I3 F
       upp_buffer_a = 0xDEAD;: k: D4 z; C6 I# A6 S& h) U
    }/ m* \- t; Q8 {+ o6 b
! m! E% z7 F! j. U' k) f% X4 b( J) H
    //for(i=0;i<1024;i++)' s8 E! T9 s9 ]% @; j! Z: q$ I
    //    temp=0;6 L+ x2 |  o/ t1 n  h& l

+ K+ v$ D& V6 y    //UPPReset();
4 b; M+ |6 ?: I% j8 }    /*启动UPP DMA传输*/* ^. B) e. H; ~: o, n, K- e: }. x
    UARTPuts("upp_prog_dma_i\n",-2);6 g0 v0 M4 C0 X: ?: ]  X8 S7 L
    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;/ n% x3 }* k5 D2 ^/ _$ V) D
    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
2 d7 `& D, }3 R! l    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);
) e0 z4 A$ @* b1 D) \* k% O+ w8 x, {9 c0 d
    UARTPuts("upp_prog_dma_i\n",-2);
+ Z6 ]# r3 ~; E    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;" P( f" W( L- ~8 U+ c( w
    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);# x; a% G- ?, _! x" b, k' Y" z
    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);+ x& p" l) _% L- K# F
4 I- \( B% x  n" }
    /*等待UPP传输完毕*// f+ o1 B/ u/ }) {" v6 H" M
    //i=0;
4 ]. W# E( ~* m/ C/ s8 U    //j=0;: d, Q0 d" o+ j
    while (upp_interrupt_count < target_int_count && upp_error_count == 0)9 [6 g' M4 S( v+ Q' ^
    {
& \7 j9 \4 V: T$ M  c" ^7 t9 J        /*  测试UPP传输的同时操作普通DDR数据
  z% \$ f0 P# C! s3 Q! P        temp=i;
% c* X( b# [$ p/ \        i++;0 F# V  b: P0 [
        if(i==1024)
" p7 h* L8 S! k        {& _+ b% G  R# n* ^
            i=0;6 s3 L1 c. `* [+ M$ E3 J
            j++;3 p* e0 a. O, I
        }9 a# u/ {+ h0 Y. `9 u1 T& {5 ~, @: s
        */
# }* A/ ]$ T) @8 h/ {
1 k% A3 a& c6 ]6 ?% T; }       asm(" nop");
( H* \% U5 P7 S  s5 E) e
4 b: j- p. U9 J. }1 @$ L       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);
. }* v  a# f( Q# c, N    }
/ Z8 S" o$ o! r6 E+ B
8 P  C0 y2 w  i! P2 m    /*检查UPP传输的数据是否正确 (loopback modes only)*/
( m1 p' B4 Y9 v* T3 R0 |8 ~- r0 ~2 S    //UARTprintf( "i=%d\n",i);& T1 `2 k/ Y: D3 o: ?
    //UARTprintf( "j=%d\n",j);
( v4 {9 q( g% H, [& g: x5 D    UARTPuts("Data mismatch in buffers.\n",-2);& e8 [& B* s7 w9 ?
    if (upp_interrupt_count == 2 && upp_error_count == 0)& `( u' u! y* D2 Z0 Q6 x+ ~4 P
    {
! M& B% {, H# b        for (i = 0; i<upp_frame_size; i++)
  \' Q4 G: G3 g+ K6 J        {' g  ]) G: }, P- r; Z7 s& u3 W
            if (upp_buffer_a != upp_buffer_b)* ?: ]4 @$ k- O9 {# a0 e3 O
            {
! {: {- N( s! P* F" _! A- h                upp_error_count++;: E9 D) ~/ ]& f. {, y% N% A
            }2 v" |* M2 l5 t
        }% c* O1 L& |' d3 A
    }( G# d, H! P* ?& N# O2 m3 H

" {$ a% E1 M# F( I4 l    /* 报告通信结果*/
( t+ h3 M; e; h6 `/ r9 w4 H  a3 }    if(upp_error_count != 0)3 \& Q+ Y# n3 @. G! G2 d
        UARTprintf( "upp_error_count=%d\n",upp_error_count);2 [- b3 \! O8 }
    else5 H: ]9 Q3 F* ~# d2 Z
        UARTPuts("uPP transfers complete!\n",-2);
/ N% R( L; \* K, ?! Z9 n  C' o+ h5 ?" x. U
    UARTPuts("Do you want to print all the data?(y/n)   ",-2);- @) Y6 Q+ E* ?2 }; {) S6 h$ E
    UARTGets(ch,2);
3 g* x! T: `% H+ I, B    UARTPuts("\n", -2);  [" K% ^4 O" K! t& {$ _

5 s6 D1 Q+ m. r8 W) B    if(ch[0] == 'y')
9 G- `2 F& O+ _; x# j, ]    {- Z/ M2 K' x0 T+ X
        /*打印全部读到的数据*/* q! f! U) e% p5 F6 a6 h# R
        for(i=0; i<upp_frame_size; )  w) V$ t) c1 l' D+ y0 Y
        {
/ ]2 n) Y7 [* E; j% t4 i7 o            for(j=0; j<5; j++)% l0 S$ }; [4 n+ i; U! X) M/ V
            {
1 r; Y5 Q. i# F% h                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);
1 E5 F" V; t6 c                i++;
2 R: j0 F/ v& C) ^7 [                //if(i >= 4096)8 ^8 d0 @, C& D$ `2 W& U
                //    break;  w) ?3 l  W  @3 B3 |0 d: p4 R
$ h. n% L& N: J" |) _& U  g+ M
            }( j4 N) n$ b; }+ v( m
            UARTPuts("\n",-2);
* J1 D# O$ q, l% Z" k1 n        }" M6 @9 Z2 ?/ f& A
    }2 |- N1 X6 C+ {( ]5 K' V
0 C* K6 G% M. }7 ?1 }# K  p, p
}
" m9 ^% Q6 L  Y, q

5 l4 g0 i# r$ w* g) _  e6 Z# _6 s& }$ A* z( i6 J$ l0 e6 U7 o

作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。
+ i8 t6 [+ `8 ^. L/ v, P) b
作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。
* x: B4 t) X: h' G5 s$ ^7 B




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