首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

基于MC13213(MC9SGB/GT60)的Smac4.1c 的基本功能应用项目不断更新中。。

先自己贴一帖。
freescale提供了自己的SMAC协议源程序和一些基本的应用项目。
不过由于本人license的问题,好像没有仿真的权限,请教下达人是怎么回事?系统报229
XX的错误。
求助
-SMAC的项目源码中的Radioini()是在哪个头文件或者.C文件里的?

基于MC13213(MC9SGB/GT60)的Smac4.1c 的基本功能应用项目不断更新中。。

[此贴子已经被作者于2007-5-17 9:50:16编辑过]


[此贴子已经被作者于2007-5-21 15:31:56编辑过]

这里有个基于smac发包的PROJECT,达人能否帮忙看下。这样在MC13213开发板上能否实现发包功能。

好像不能上传文件,那就发下我的主程序,劳烦大虾看下。 


void main(void) {tRxPacket rx_packet;  //SMAC structure for RX packets
 tTxPacket tx_packet; //SMAC structure for TX packets

 byte rx_data_buffer[20]; //Data buffer to hold RX data, if you want larger packets change 20 to what you need.
 byte tx_data_buffer[20]; //Data buffer to hold TX data, if you want larger packets change 20 to what you need.

 UINT16 packet_count;
 
      //Initialize the packet.
  tx_packet.u8DataLength = 0;   //Set TX default to 0
  tx_packet.pu8Data = &tx_data_buffer[0]; //Load the address of our txbuffer into tx structure.

  rx_packet.u8DataLength = 0;   //Set RX default to 0
  rx_packet.pu8Data = &rx_data_buffer[0]; //Load the address of our rxbuffer into rx structure
  rx_packet.u8MaxDataLength = 100;  //Define the max buffer we are interested in.
  rx_packet.u8Status = 0;   //initialize the status packet to 0.
 


   MCUInit();  //Initialize the mcu, setup GPIOs, SPI, clock scheme, etc.
   RadioInit();
   app_init();
    
  MLMESetMC13192ClockRate(0);   /* Set initial Clk speed from MC13192s CLKO*/
  UseExternalClock();  /* switch clock sources to EXTERNAL clock */
 
     /* include your start up code here */ 
   EnableInterrupts;   /* Turn on system interrupts */
  MLMESetChannelRequest(0);   //Set channel zero, can be changed to users preference 
   MLMEMC13192PAOutputAdjust(NOMINAL_POWER); //Set Nominal power setting 
 
 
  app_status = INITIAL_STATE;  //Set the initial app_status of the application state variable to INITIAL_STATE
  
                            //Loop forever
 for (;;) {

  switch (app_status) {
   case INITIAL_STATE:   //For TX    
    app_status = IDLE_STATE; //Switch app status to TX_STATE
    for (i=0; i<18; i++) {
       tx_data_buffer = i;
    }
    tx_packet.u8DataLength = 18; //Set the data length of the packet.  in this case, 6.
    packet_count=0;
    break;
    
        
   case TX_STATE:       //Load the tx buffer with the ZigBee packet.
    if (MCPSDataRequest(&tx_packet) == SUCCESS) //TX Packet, Blocking will stay here until the packet is in the air
    LED1 ^=1;            //MLME_RX_enable_request

(&rx_packet,DELAY_COUNT); //Now turn on the RX with a timeout of DELAY_COUNT
    if (packet_count < 999)
       app_status = DELAY_STATE ;    //Set app_status as waiting for ack.
       else
       app_status = FINAL_STATE;    
    
               packet_count++;
    break;
    
   case RX_STATE:
    MLMERXEnableRequest(&rx_packet,0); //Zero means wait forever with RX ON.
    break;
    
   case RESET_STATE: //MC13192 Reset, reinitialize and return to default state (TX_STATE).
    RadioInit();
    app_status = INITIAL_STATE;
    break;
    
   case RECEIVER_ALWAYS_ON:
    break;
    
   case WAITING_FOR_ACK:
    break;
    
   case SET_LEDS:
    
    /* This state takes the power value from the ack and turns on the appropriate LEDs */
    
    LED1 ^= 1; /* Toggle LED1 whenever an ack is received. (blinks LED1) */
    LED2 = LED_OFF; LED3 = LED_OFF; LED4 = LED_OFF;
    app_status = DELAY_STATE; //Take the app state and wait for some time to retransmit.
    break;
    
   case DELAY_STATE:
    //Sets the TX rate, small DELAY_COUNT means TX rate is fast while larger values slow it down.
     
    app_status = TX_STATE; //After the delay, retransmit
     break;
     
       case IDLE_STATE:
          break;
    
      case FINAL_STATE:
          tx_packet.pu8Data[0] = 'D';
           tx_packet.pu8Data[1] = 'O';
          tx_packet.pu8Data[2] = 'N';
          tx_packet.pu8Data[3] = 'E';
          tx_packet.pu8Data[4] = 'D';
          tx_packet.pu8Data[5] = 'O';
          tx_packet.pu8Data[6] = 'N';
          tx_packet.pu8Data[7] = 'E';
          tx_packet.pu8Data[8] = '\0';
          tx_packet.u8DataLength = 9;       
        for (i=0; i<20; i++) {
           for (loop = 0; loop < DELAY_COUNT; loop++);
           MCPSDataRequest(&tx_packet);
           app_status = FINAL_STATE;
        }
        LED1 = LED_OFF;
        app_status = IDLE_STATE;
       
     default:
   break;
   
  }
  

 }
}

 


 

[此贴子已经被作者于2007-5-21 15:53:50编辑过]

请教下包和文件如何区分?
for (i=0; i<18; i++) {
tx_data_buffer = i;
}如果发送的内容为以上那么这算是包还是文件
我的项目的目标是想实现两个点对点对发,发端发送1000个包数据都为1,发送数据时闪灯,收端接受到正确数据时闪灯。
用SMAC4。1中的哪种应用项目可以实现?
jimmytan, 麻烦告诉我下这个状态机它是怎么运行的?(就是上面循环部分)我的理解是先进行初始化状态,然后进入IDEL状态。IDEL状态不做任何动作,那么如何进行发包工作呢?

[此贴子已经被作者于2007-5-26 21:14:24编辑过]

我这里发包好像不行程序运行 while (gu8RTxMode != IDLE_MODE)时,跳转到一块
FFF8 STX ,X
FFF9 STX ,X
FFFA STX ,X
FFFB STX ,X
FFFC STX ,X
FFFD STX ,X
FFFE BEST 4,0xA7
堆栈这块如何设置,是否就是数组生成的部分?
是否是STACKSIZE 0x50
这个值有没最大范围?255?
上述问题会不会是由于中断向量表没有添加造成的呢?中断向量应该如何正确设置
基本功能实现了,我能在MC1321x-SRB开发板上发包了,不过还有点问题。
发端似乎只能发送一次包,不能持续发包,收端也只能收到一次正确的包。
我怀疑是发包的指针的问题?MCPSDataRequest(&gsTxPacket);发送后没有回到原先的gsTxPacket[0];
希望哪个大虾给我点提示,应该如何改进,或是规避这个软件问题?
switch (gi8AppStatus) {

case IDLE_STATE:
gi8AppStatus= TRANSMIT_DATA;
break;



case WAITING_FOR_ACK:
gi8AppStatus= IDLE_STATE;

MLMERXEnableRequest(&gsRxPacket, 0);
LOW_POWER_WHILE();
LED2^=1;
break;

case TRANSMIT_DATA:
//gi8AppStatus= IDLE_STATE;


gau8TxDataBuffer[0] = 1;
gau8TxDataBuffer[1] = 1;
gau8TxDataBuffer[2] = 1;
gau8TxDataBuffer[3] = 1;
gau8TxDataBuffer[4] = 1;
gau8TxDataBuffer[5] = 1;
gau8TxDataBuffer[6] = '\0'; /* Sending String */
gsTxPacket.u8DataLength = 7;

MCPSDataRequest(&gsTxPacket);
gi8AppStatus = WAITING_FOR_ACK;

LED1^=1;


break;


case TIMEOUT_STATE:
if (u8RetryNo < RETRY_COUNT)
{
gi8AppStatus= TRANSMIT_DATA; /* Retransmit. */
switch (u8RetryNo % 4)
{
case 0x00:
LED1 = 0;
LED2 = 1;
LED3 = 1;
LED4 = 1;
u8RetryNo++;
break;
case 0x01:
LED1 = 1;
LED2 = 0;
LED3 = 1;
LED4 = 1;
u8RetryNo++;
break;
case 0x02:
LED1 = 1;
LED2 = 1;
LED3 = 0;
LED4 = 1;
u8RetryNo++;
break;
case 0x03:
LED1 = 1;
LED2 = 1;
LED3 = 1;
LED4 = 0;
u8RetryNo++;
break;
}
} else
{
/* Give up on packet. */

LED1 = 1;
LED2 = 1;
LED3 = 1;
LED4 = 1;
gi8AppStatus= IDLE_STATE;
u8RetryNo = 0;
}
}
返回列表