你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

Spirit1的数据发送,没有发送完成状态

[复制链接]
xionghuang 发布时间:2019-8-22 10:37
采用Spirit1实现433M的无线发送,通过SPI接口配置了SPirit1,配置寄存器读写正确,写入TXFIFO数据,发送前读取TXFIFO的数据Number为20,然后启动发送,SPIRIT1_GPIO3中断能进入,但是没有发送完成的中断状态,发送后读取TXFIFO的数据Number为0,采用SPIRIT1的配置工具生成的参数配置,测试结果也是一样,SPIRIT1_GPIO3中断能进入,但是没有发送完成的中断状态,数据也没有发送出去,什么原因?- f# @9 [4 q& f1 }- B! l
/* Spirit ON */
2 x# g& R# y* D0 n+ z# A  SpiritEnterShutdown();' v8 p* S, D! E, T. \! H
; _% `$ L8 U0 A/ M3 s
  SpiritExitShutdown();
3 s$ g$ a& O$ @: x' O4 M
2 T- W: F' j  j! x0 P  SpiritManagementWaExtraCurrent();- l: e' ~1 v- l$ X
) g+ V  a" s; [) \! ^
//  SpiritManagementIdentificationRFBoard();
5 j! K" Z0 ?3 s        SpiritSetXtalFrequency();
5 w$ G. h1 f; |/ ~+ ~. T2 k' C' |) Y0 [3 W; W) ^/ Z1 A- ]6 }8 M7 j3 a
  /* if the board has eeprom, we can compensate the offset calling SpiritManagementGetOffset
- c7 x' C" c( ]" I$ V  (if eeprom is not present this fcn will return 0) */
! n$ l. ?- R; h9 k! f  xRadioInit.lFrequencyBase = xRadioInit.lFrequencyBase + SpiritManagementGetOffset();7 C. O) [4 O, S, z7 {" k, u
, U# g" ~$ l4 J; O  ~3 v
  /* Initialize the signals to drive the range extender application board */
% ?) s+ J) C: c" B  SpiritManagementRangeExtInit();  
2 ^2 P) f! r/ E: d: b
. l; @: N& @6 f& M  n) f  /* uC IRQ config  uC IRQ enable*/# f9 x9 q+ C+ x
  Sprit1_GPIO3_IRQ_Init();" S. z$ W! t' g/ X" i

7 L7 d# z, e) l$ A! M! D  /* Spirit IRQ config */
7 ?9 R9 J& f2 o( o  SpiritGpioInit(&xGpioIRQ);  
, v- P' X" i  L) a
* a& z, \( f1 k# R  /* Spirit Radio config */
6 y# l& p* v. J) Z( `/ U  SpiritRadioInit(&xRadioInit);+ k5 n. }) r. k, Y
3 f$ x# E  Z9 j4 `6 _/ \2 q$ E
  /* Spirit Radio set power */* D0 I: e' V0 P: R
  SpiritRadioSetPALeveldBm(7,POWER_DBM);
0 `* j' |, B" J; \  SpiritRadioSetPALevelMaxIndex(7);. n, c) B8 s6 Y7 n  L% N; R
" n  c& B% p! U6 K- @" k  c) ]' [
  /* Spirit Packet config */
9 [6 Z9 Q) E) Y7 K+ ]: J  SpiritPktBasicInit(&xBasicInit);
% f2 r+ r9 [0 T1 x+ k2 |" P1 y5 n8 x  SpiritPktBasicAddressesInit(&xAddressInit);" Z& H# h5 r, ~2 J. Z0 s

5 ?4 J! E) P: F/ o6 n, B  /* Spirit IRQs enable */
  R! }0 n6 }  l! M# I* O- L  SpiritIrqDeInit(NULL);. r: E% e. z+ h# H
  SpiritIrq(TX_DATA_SENT , S_ENABLE);
$ H5 u" i/ V* B% L6 x  SpiritIrq(TX_FIFO_ERROR , S_ENABLE);
8 _" \- z- z  R; g' ^" l0 i; C% W; p' ?* z/ Y6 T  P. }
  /* payload length config */8 u+ A0 Q7 c1 L3 x0 u, m
  SpiritPktBasicSetPayloadLength(20);1 ^, i. i5 }! K$ P) }2 {* e+ I. F1 r
9 ]3 ^* K3 [; _' l8 N0 l
  /* destination address.! @1 J/ `; T" g% K5 U1 N9 `
  By default it is not used because address is disabled, see struct xAddressInit*/' q8 A$ A. J9 g
  SpiritPktBasicSetDestinationAddress(0x35);* |4 T7 T+ l7 u) c0 z3 p

7 `  u; N0 i5 A7 T( [' A! @9 Y  /* IRQ registers blanking */% }' F" d; ~. s3 x
  SpiritIrqClearStatus();/ x  r* P) \: {; y; b3 n6 }0 Y

7 O7 c) e, }# t% H& W  /* Infinite loop */# f0 J# U" p" U" l$ h
  /* USER CODE BEGIN WHILE */
" @. i, g- L  F7 ]1 U  while (1). N# B6 t. [: I
  {         7 f5 O  |- ^& a2 [* ]
    /* fit the TX FIFO */- P- o4 z6 t; o5 E1 I) X. D
    SpiritCmdStrobeFlushTxFifo();
1 U. K6 j+ U7 F. ~& b
5 u9 p  D. f4 y7 L; N3 b    SpiritSpiWriteLinearFifo(20, vectcTxBuff);5 c  P# P/ F8 D& a" X( f% K* ?. v
+ `+ T& Y8 Y3 n$ ^1 L  ^6 X! V0 K
    /* send the TX command */
! F* O8 A8 u4 F    SpiritCmdStrobeTx();  J  O6 a2 g- H1 E
! l5 T2 o* G, A/ K" f. I
    /* wait for TX done */
& `: N0 }5 G0 i1 V; j9 u& a4 c//    while(HAL_GPIO_ReadPin(GPIOA,  GPIO_PIN_11)==GPIO_PIN_RESET);1 K  {3 }  q/ O0 p
' R: d' E6 q1 g& j( J) n9 p6 i' M
//    while(!xTxDoneFlag)- S3 Q6 D  q4 g( X2 u3 {# r
//    {
# j3 [! C$ M- M//      SpiritRefreshStatus();
: _- g; Q7 j" H//      
4 U5 W2 b; l$ @7 h2 P2 C//      SpiritIrqGetStatus(&xIrqStatus);
2 \8 n) M* L/ @//      - J, D$ }* c& l# v
//      if(xIrqStatus.IRQ_TX_DATA_SENT)
, f1 u- l8 `# Q7 W5 W) H//      {
- a6 J5 W/ c& O) s( h//              xTxDoneFlag = SET;3 g; K# C  ^7 ^1 ~3 Z
//      } ) l* n4 ]0 L8 c# m  r8 A6 u2 k$ D
//    }; Y) K  j! b% h$ K4 ~
//    SpiritIrqGetStatus(&xIrqStatus);
* v4 P. V3 c" T" T1 X% i    /* wait for TX done */& w( {  t. s1 [( J0 Q5 k( d: c/ @% I. ?
    while(!xTxDoneFlag);) ^; p- V. V  \( {) q, r

9 B% p$ t5 K$ u/ I    xTxDoneFlag = RESET;" Q  F! \/ q/ l/ r* q
    g_dwtx_send_ok++;0 a: ?: t) T. e  V; T

- h: }' f$ V% x% K4 \% t, n0 X6 c    /* pause between two transmissions */0 p% k1 s, I1 T
    HAL_Delay(500);  //delay  500ms6 [  _$ @& P* W4 p7 R

$ ^4 ~7 j+ B. Q4 F6 W- Q; U! A
, @- z- c# p. J    /* USER CODE END WHILE */5 O/ e$ z4 x0 @. R" }5 ]

' Q4 a0 L5 l* t    /* USER CODE BEGIN 3 */4 q: ~; g2 {3 t  `6 R7 v
  }
" o8 n5 Q( R8 b  G$ L  /* USER CODE END 3 */4 ?3 c) `; v- D' N
}, F3 [3 ~9 P$ i

8 J6 z) a( f" u0 ?, w//中断处理部分+ E1 F; U& v1 p% M+ D
if(GPIO_PIN_11 == GPIO_Pin)//SPIRIT1_GPIO3中断$ H( U$ f2 X) L5 V2 d' _% e
        {
4 X. k2 P9 I- u/ e3 Q5 T! i# C$ O            /* Get the IRQ status */
8 O3 {( P# R: n8 ?2 @( z            SpiritIrqGetStatus(&xIrqStatus);, C) k2 }6 @! L+ Y4 j
            3 j4 O5 e) k2 H5 g1 c
            /* Check the SPIRIT TX_DATA_SENT IRQ flag */
/ `2 [# c" [3 Q+ m- Y' A            if(xIrqStatus.IRQ_TX_DATA_SENT)! l8 [' a% W1 p, o8 b/ F; y* w
            {
1 h, O/ o1 g4 H- j% n3 j                    g_dwTest_Count[0]++;
' j  |' P& B) j. y0 a2 O8 C* L) ]% I              /* set the tx_done_flag to manage the event in the main() */5 F: C. h: h7 n6 O! q
              xTxDoneFlag = SET;
; z, r7 h4 p0 _# f3 v//                                g_btransmitting = 0;) X" }3 V2 C% T
              / d7 {* S2 c6 U" e* o2 h7 f. |
              /* toggle LED1 */: |) m5 s* p3 L3 `
//              GPIO_Led_Invert();# m  O2 T1 t9 C
                                /* Flush the RX FIFO */
( `+ {" P6 F& }. z//                                SpiritCmdStrobeFlushRxFifo();
& g! Z4 _; E! W% v: [& W/ {& u' f. @% [7 Y- i" M: x
                                /* RX command - to ensure the device will be ready for the next reception */
3 f0 y" ?" U  c. t' X9 f1 M: h, m& Z//                                SpiritCmdStrobeRx();2 n/ B8 }* D7 _9 v

# }; D: D; Y; W1 {' l8 r# ?% D            }$ @. f1 J; ~$ Z1 g& N
                        /* Check the SPIRIT RX_DATA_DISC IRQ flag */
1 l- A' B, b8 Q) L! [5 t! Q                        if(xIrqStatus.IRQ_RX_DATA_DISC)
/ b  z" T6 k# _) \* ~& t9 Z8 ~9 t5 l                        {: h# G$ v/ s0 U4 D  b/ ]& N: z5 m
                                /* toggle LED1 */
3 F0 u0 B1 _* U" L//                                GPIO_Led_Invert();//SdkEvalLedToggle(LED1);
5 u+ j, t" k: x% u8 k( t" \) O                                        g_dwTest_Count[1]++;2 [" @5 I) Q: G1 @* S3 b
                                /* RX command - to ensure the device will be ready for the next reception */
* G" S3 _+ P1 G3 E( V6 o4 B! O                                SpiritCmdStrobeRx();
( a9 |4 K! a" \& a+ k& J                        }
3 F  Y. h: D6 H" f2 O  n' B; ?- S) p% ^* P/ r& f& \$ [( G3 c3 `
                        /* Check the SPIRIT RX_DATA_READY IRQ flag */! U1 X! |. {$ i0 A5 A/ j
                        if(xIrqStatus.IRQ_RX_DATA_READY)# y) V# Q  v$ x. t2 t: T( M
                        {
9 a* a& B8 w- B$ U2 f/ k- J                                g_bReceive_New_Frame = TRUE;
& B" N( W8 \/ j3 v; ^$ ^3 ?* M                                g_dwTest_Count[2]++;   
; _; Z$ b& z1 Q7 j                        }
. B  i! K1 a, F" L      //////////////test///////////////////////////////- E4 b7 I- e) u" j
      if(xIrqStatus.IRQ_TX_FIFO_ERROR)/ X! b! p: _- _. R4 }* _
            {2 j6 J3 q& J  }! \0 [4 f' l. ~
        g_dwTest_Count[3]++;/ w) e$ N7 ?0 q5 y9 W4 ]) [/ i, ^

; {9 {  Z& {& A: y      }4 L! w) l  @( R' x1 N' B/ o
    //////////////test///////////////////////////////      
0 q/ N0 |- \/ T* @, |( x        }         2 I) Y! H' a8 ~5 h- b$ L1 O
void SpiritSetXtalFrequency(void)
" i- B9 M8 |3 y" i3 Z0 ^3 ~{
& q4 w  O) M. `  m+ D6 K5 s        do{9 \' o8 Q  G5 h$ H
            /* Delay for state transition */$ T2 D% C0 e8 X7 Z
            HAL_Delay(2);  //delay  2ms" |2 `; h4 w2 m$ V7 x
            
4 L0 f2 L- V9 y0 E% N/ o5 m            /* Reads the MC_STATUS register */! e2 t7 T- f1 D4 ~, x
           SpiritRefreshStatus();
$ `  @. B, D5 P* J6 g          }while(g_xStatus.MC_STATE!=MC_STATE_READY);, G/ \( x$ G* U

0 q. o3 e# `) T. i) P& n    SpiritRadioSetXtalFrequency(XTAL_FREQUENCY);//XTAL_FREQUENCY = 26000000;
: t) w- m0 d. n% X; {5 }# V+ ?* _) p3 X1 D# i, z. w% v& Y* n
    SpiritManagementSetRangeExtender(RANGE_EXT_NONE);
* e, ?7 P9 v3 t' s) H& o% Z% i
    SpiritManagementSetBand(0);8 y% t( b% w* ]
# c# J3 B9 X3 T1 ~
    SpiritManagementSetOffset(FREQUENCY_OFFSET);   
. a& \; c, y! Z}
; M+ y+ `6 f, \; \; H# \  Y7 x- M2 p* H
赞 收藏 评论0 发布时间:2019-8-22 10:37

举报

0个回答
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版