嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?
' x6 u# g5 h0 j0 C4 y0 V
Void UPP_TASK(Void)$ t9 {' I6 s  L9 R+ k' C
{
5 p+ @2 }7 [0 g5 s3 \1 V
6 r* p: Z' N& G    int i,j,k,target_int_count=2;
' h% p/ q5 M5 P4 [5 j    char ch[2];5 z( ^0 b8 M  y+ C/ Y9 N7 J

' w* I* o' f  S
/ C; R4 A( z. t" k4 Y* J5 d
6 I# _) n# Y  f" r    upp_interrupt_count  = 0;7 P9 J" b, d& T% }, H% z
    upp_error_count = 0;; N7 i9 [7 B1 |
3 C; _2 J! N$ @) G) F4 ?
    UARTPuts("\tResetting uPP buffers...\r\n",-2);
( V% K) O1 ~6 W; ~+ E    // Initialize data buffers
0 f3 \7 a* O# u# x    for (i = 0; i < upp_frame_size; i++)" f' v% S" }- b, Z
    {/ M2 ~# a7 B/ y+ i0 [; v' P7 Y' s
       upp_buffer_b =i;9 y; n; s0 o- l& z( t
       upp_buffer_a = 0xDEAD;
. b& y; Q8 I- Y! O* x$ |    }: Y9 n  [6 f$ D$ R9 \+ F2 b

. u: P8 V% a9 h    //for(i=0;i<1024;i++)
) |! N8 R: w7 w1 K    //    temp=0;
7 {! }7 H% A% m
9 R0 _9 Y7 j* g    //UPPReset();/ Q3 L, W$ o7 X# z1 l" c* U
    /*启动UPP DMA传输*/8 n2 g5 D4 ]9 y' Z5 L9 W- ^9 v
    UARTPuts("upp_prog_dma_i\n",-2);
( f6 r. L; C0 p( h    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;
3 H& {2 o- s+ f2 o2 S2 h    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);- B' h* @7 V) ?: `5 F; C* G
    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);
# B+ M# S& A! A. x! o
. F/ K* S' Y7 U: \    UARTPuts("upp_prog_dma_i\n",-2);
* L; g6 f/ {* G! p& O* ]+ X    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;
1 B4 o8 j$ l) [! L. @5 ~' v    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);. F3 W# C$ z8 s* f
    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);
5 K0 X- `# S$ E% ]/ I1 ?8 w
: `7 U! K& d4 P1 L$ T    /*等待UPP传输完毕*/# a/ B0 A8 G4 n' x+ i8 A
    //i=0;3 m) q( ^# `9 Y1 }* Z# s) @
    //j=0;
! e3 l8 U' D1 O. M    while (upp_interrupt_count < target_int_count && upp_error_count == 0)5 K7 X5 n1 e1 O! W/ O
    {5 W$ J- i) g- j+ E0 z1 T" @' r* P6 G
        /*  测试UPP传输的同时操作普通DDR数据3 E8 q- y; i% ~+ x0 I
        temp=i;
2 e9 i1 q: i; O        i++;
" C, C" e0 \; V) B6 s        if(i==1024)8 y+ m: M1 y* C' w
        {, ^9 t7 z% V/ l2 i; C; {
            i=0;
8 e4 R2 z- e8 @8 l- b, q) `% @            j++;" m7 a- O3 F. G" Y) Q% s
        }5 z, K0 d" l7 ], N9 i9 r( H
        */$ B+ u; ?/ f/ D2 }( {- X
/ n' B' z% s9 P7 w: r* R5 t" a2 ~
       asm(" nop");% S* r' f7 Z8 T8 C, ^1 h

9 L0 R5 N, W5 Y3 ?) V, A# E2 {3 t       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);
* q! A, ]6 ~5 K( a    }# ]. R% l+ {- S+ b
" L& _9 O$ W/ A" l4 U& f
    /*检查UPP传输的数据是否正确 (loopback modes only)*/4 {. I$ ~0 g2 c- J4 N8 ^( `& H. O
    //UARTprintf( "i=%d\n",i);! Z; w8 C& |. k  `
    //UARTprintf( "j=%d\n",j);
) |! b5 A5 t' ?) V5 w; ~; y$ N    UARTPuts("Data mismatch in buffers.\n",-2);+ O0 K) }$ @' X* O  q
    if (upp_interrupt_count == 2 && upp_error_count == 0)8 ^) a. J* w5 K, t
    {& U/ [' i. ^; C7 K! p& W
        for (i = 0; i<upp_frame_size; i++)
5 |+ d* d3 R7 Q5 \7 b4 U" E( Z/ `        {
9 {4 k! r% [3 z; I4 L% E# X! v4 ?            if (upp_buffer_a != upp_buffer_b)
- Y9 K  P6 {, B$ z' \$ k            {0 P1 G/ ^5 M( c2 u7 f3 _3 ~
                upp_error_count++;# S7 S. R9 R+ h3 p* h
            }
. {. l3 R9 Y! C9 q; |  Z* j3 L        }, |- u- D2 E0 \6 T
    }
* p2 O4 g% S$ |9 f( A' r; y  t, ^' |  Q- g% q# L3 V0 a( Z
    /* 报告通信结果*// ?# p% x- t, A: |1 h5 `6 [. d1 `
    if(upp_error_count != 0). R9 b* d- J/ V2 j# W4 s3 W4 E
        UARTprintf( "upp_error_count=%d\n",upp_error_count);
0 C# x8 P5 i" S, [5 f, i    else: i) \$ W) I( A
        UARTPuts("uPP transfers complete!\n",-2);( l: q, y$ Y# y. k- ?

& t' w- [* J, O% o# i    UARTPuts("Do you want to print all the data?(y/n)   ",-2);
3 z: V- c. t5 C: J; ^; M+ v5 V    UARTGets(ch,2);. D# }9 [6 Y# G. i. q9 x
    UARTPuts("\n", -2);4 }) K% H- A+ _+ E4 m5 |

. E, e2 E1 N( I4 P' U- f8 l    if(ch[0] == 'y')
2 G. m" p- T7 |( E$ @  }    {, U% a2 u; ~; W( v3 C- d5 m
        /*打印全部读到的数据*/
% b: I8 i; m; s$ t' c/ r4 t        for(i=0; i<upp_frame_size; ); c2 w& r* I4 v- U# E" x- W
        {
3 @4 X  R& y$ Q            for(j=0; j<5; j++)
5 G, ~' e" I! b, w8 r            {, L5 c: R2 r: [/ u  x+ p+ m
                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);
0 o- \1 V" L3 G/ d* b5 |                i++;2 G1 H) `/ S2 N# f3 V5 e
                //if(i >= 4096)* n. h+ t1 ]! y0 h0 c" [5 s
                //    break;  I7 g& @* h4 s! U4 x# d' _& V
1 }/ y$ d1 b: P
            }; |) j- G9 }1 D& ~& u5 q' U/ j
            UARTPuts("\n",-2);% P, p9 z6 f, ^! E6 w! ?, L
        }
, }" D6 _8 N. `    }: u, T0 t! e, N' d. ~6 w
/ Z4 \+ W  B& Z) ~- P9 I- m: h
}

  `% @9 p5 w3 B

5 ~$ }% k: R+ y" L  Z- r
  m0 D% U9 K# h3 n: I! O
作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。
4 T% A/ N' ~1 G+ {) X
作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。8 w7 h/ z0 O4 j( Z$ E1 }+ V7 A





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