嵌入式开发者社区

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

作者: tulipyyf    时间: 2014-12-22 14:35
标题: upp问题,在SYSBIOS下的应用问题
下面的任务,只能在第一次执行UPP时成功,后面的均不成功,请创龙工程师看看为什么?
3 N0 g' _: h2 ^0 a
Void UPP_TASK(Void)
- X# L2 r3 T$ t% ~6 u# P{, |9 r# ~. b0 n: N2 K" ~" x

$ p, B2 N5 r1 D" J. n    int i,j,k,target_int_count=2;& X5 |# N2 Q1 Z# B0 M6 S3 s3 U
    char ch[2];
: m5 L1 [+ G2 _5 Y$ M$ z) A7 e# h7 Q- e. f# F8 }
; @6 m: `5 d3 ^6 Z4 f8 B7 u

+ c! t9 G# I- `6 U( s    upp_interrupt_count  = 0;1 _4 \, J& O0 Q6 E
    upp_error_count = 0;
9 R; P- [  P& G" Q; ?$ x8 H, r+ v! C1 O
! D; i; r9 e) A$ Q5 s! |    UARTPuts("\tResetting uPP buffers...\r\n",-2);
4 h% N* K1 w2 D8 h+ \2 x$ T    // Initialize data buffers
8 f( U* r1 |1 b- K+ k6 B  V9 @    for (i = 0; i < upp_frame_size; i++)1 U) x6 s0 u  V- K" M8 j6 Y
    {
; h" D( [9 _- g" k/ K1 g       upp_buffer_b =i;& x5 c7 S5 D/ Q, a
       upp_buffer_a = 0xDEAD;+ V- p# d5 X! ?) g; z9 n$ _" j8 i
    }
% n! [4 \% f" P; E8 V6 ]$ [) u. d6 {  r
: s: Z- s: ]+ B6 }$ R! n9 [5 m' z( `( F    //for(i=0;i<1024;i++)
. {' u2 Z( X: c7 d    //    temp=0;6 ~5 `3 Y4 @; C- m, Z* f" Y/ h
+ n- B9 Y* y8 t& o
    //UPPReset();
4 X( M, l# t/ a! @3 |' ]    /*启动UPP DMA传输*/. V  B) W2 L; h! l: i
    UARTPuts("upp_prog_dma_i\n",-2);' p, S2 D( I& m4 {4 E: ~+ [& M
    upp_reg_hdl->UPID0 = (Uint32)upp_buffer_a;
) ~+ i) c: [% N+ U* i    upp_reg_hdl->UPID1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);8 z; [. ?1 q! P
    upp_reg_hdl->UPID2 = (Uint32)upp_line_offset*sizeof(Int16);! C8 j5 U- E1 a7 O9 E, ^' m

% D6 ~6 q& N! o, p( s; y6 g    UARTPuts("upp_prog_dma_i\n",-2);
3 |+ a) \0 E5 e* L! \    upp_reg_hdl->UPQD0 = (Uint32)upp_buffer_b;
1 G* x9 j. d! E+ z$ A    upp_reg_hdl->UPQD1 = ((Uint32)upp_line_count << 16) | (Uint32)upp_line_size*sizeof(Int16);
" U$ J8 r" w' _    upp_reg_hdl->UPQD2 = (Uint32)upp_line_offset*sizeof(Int16);) }, {: m1 i, u: |$ N# ^; v; p3 u
1 w: y, I1 S1 q% X4 }
    /*等待UPP传输完毕*/
- F3 Q( b' u5 F: g' A    //i=0;" Z& @- c' {% q2 `8 |' v, E2 m
    //j=0;
, F5 ?: t( d& ~$ f    while (upp_interrupt_count < target_int_count && upp_error_count == 0); R8 A9 e4 [( D% [! Q' S
    {
& `. O+ _5 q8 T0 b' ~        /*  测试UPP传输的同时操作普通DDR数据; O6 T$ T7 x$ V3 c5 e! L
        temp=i;' _' s+ Z! E3 h) ?% y2 w
        i++;
# u/ z4 z0 w6 b        if(i==1024)
: l+ b+ f) [4 h/ X: l        {8 {( L) F# E/ b! z
            i=0;
' G7 x* H0 o& I' W! l3 R1 Z/ W) V            j++;
7 o0 A2 _$ h! ?        }+ n* h1 J( [  v7 t* W
        */6 S" n; T1 w1 r! ?5 B2 W1 w( ]8 h

  D8 k" r, L+ J2 g0 V# e       asm(" nop");  n3 ~6 ]- Q* n' x9 _
% t5 d: R) y& u# ]! V- H, g
       //UARTprintf( "upp_interrupt_count=%d\n",upp_interrupt_count);
+ O/ V( O" r* P% y1 v/ P    }. \; {6 d- D" x3 S3 X

: R1 D0 s5 w- v! \4 f    /*检查UPP传输的数据是否正确 (loopback modes only)*/. a7 I( a' s- z4 t8 `: }
    //UARTprintf( "i=%d\n",i);9 M5 v  |5 u4 E2 V- K  J
    //UARTprintf( "j=%d\n",j);; N1 x% M, ?  J+ [
    UARTPuts("Data mismatch in buffers.\n",-2);+ v  T) q( A0 n+ c+ Z( }8 X* L
    if (upp_interrupt_count == 2 && upp_error_count == 0); u$ f1 I+ A4 _8 ~. Y
    {
, q: h2 C& V; J$ J        for (i = 0; i<upp_frame_size; i++)$ k9 n& O0 A' Y! ~
        {8 b  F- y9 Z+ t, w- v: X0 J7 e
            if (upp_buffer_a != upp_buffer_b)
( a0 m7 [* u  E- r            {
+ d+ v& Z9 a1 C                upp_error_count++;' ^0 L# p: ]5 x% m1 v5 `
            }
5 s: A7 S1 O; ?' P' Y        }2 x# q- K2 Y# Q  F
    }
+ ^8 T6 o1 @1 d7 P6 \
4 a8 g4 U7 R! h# S6 {    /* 报告通信结果*/
; O6 |, r' B, f4 ?4 b  J8 C7 [' [    if(upp_error_count != 0)2 O/ K$ S2 I: J  S* z; H0 M
        UARTprintf( "upp_error_count=%d\n",upp_error_count);& ]# Q3 Q, ~9 S2 ?/ q
    else4 {9 n8 x- `5 j: }! c
        UARTPuts("uPP transfers complete!\n",-2);* h3 [& T9 |( Z; g

! m& `! [# T; S1 y! [3 ]6 X    UARTPuts("Do you want to print all the data?(y/n)   ",-2);
  Y& B; y% c: z& A! B# E$ P    UARTGets(ch,2);& L2 S5 b1 W6 d/ }1 L  w$ r
    UARTPuts("\n", -2);% ~) U) |1 b7 A6 z! ?

9 G; s: h, J. {6 s    if(ch[0] == 'y')
7 G' e+ W1 P; u6 Q' Y    {
0 R8 r- W# B* D6 \/ I        /*打印全部读到的数据*/5 C! ?4 b7 z4 U! x
        for(i=0; i<upp_frame_size; )
0 t% q, k# U9 k! z        {
# O8 D! u% x% v) L            for(j=0; j<5; j++)! y9 S& T4 h6 ]* z& Z
            {+ g0 [" \0 i. t$ h) o9 }
                UARTprintf("upp_buffer_a[%d]=%d   ",i,upp_buffer_a);0 S; k; j1 S& d* a$ z2 K2 U; y& @0 N
                i++;
: b' U" @( Q+ O* T0 x7 U. q% L                //if(i >= 4096)
4 j$ t- R5 e' Q- r+ w1 W                //    break;
; R0 }/ n) J5 p  T0 l( {% a! D. E# r& ~
            }
7 g" }$ A- U9 x4 `. m# b( D            UARTPuts("\n",-2);* D' D6 e7 M3 e  Q( Z" E( w9 Y
        }" u2 c9 Y% q" Z; t' B1 K8 ]% R
    }  v- W! O; j/ l7 m: |2 k% S% w5 T8 V
( v4 p. |; z( w+ G: I  j& V6 r
}

5 A! {0 P7 Z8 D4 ^8 W6 a

6 g3 O; Z' }0 h+ n) d- ?3 g
6 Y% D9 t4 y# i- k0 V3 g8 X- x' M
作者: tulipyyf    时间: 2014-12-22 16:08
追加说明:任务是空闲任务,因此没有做循环。& b+ m" x$ f; D8 z8 x' R$ l9 \

作者: Lewis    时间: 2014-12-24 18:06
多次执行是没问题的,最好不要用空闲任务,优先级太低。- J3 U+ Z* S$ P* c+ y





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