微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI Zigbee设计交流 > IAR DMA 程序是否能改写 KEIL?

IAR DMA 程序是否能改写 KEIL?

时间:10-02 整理:3721RD 点击:

一个 IAR DMA 转KEIL 不知道怎么转?

#pragma bitfields=reversed  *******************************88
typedef struct {
   BYTE SRCADDRH;
   BYTE SRCADDRL;
   BYTE DESTADDRH;
   BYTE DESTADDRL;
   BYTE VLEN      : 3;
   BYTE LENH      : 5;
   BYTE LENL      : 8;
   BYTE WORDSIZE  : 1;
   BYTE TMODE     : 2;
   BYTE TRIG      : 5;
   BYTE SRCINC    : 2;
   BYTE DESTINC   : 2;
   BYTE IRQMASK   : 1;
   BYTE M8        : 1;
   BYTE PRIORITY  : 2;
} DMA_DESC;
#pragma bitfields=default

//写一个函数,使数据通过DMA传到另外一个数组里
void use_dma_one(void)
{
  DMA_DESC dmaChannel;
  BYTE  sourceString[16] = "SHENZHEN WXL";
  //sourceString[0] = 0;
  //sourceString[1] = 7;
  BYTE  destString[14];
  memset(destString,0,14);

   SET_WORD(dmaChannel.SRCADDRH, dmaChannel.SRCADDRL,   &sourceString); // The start address of the data to be transmitted
   SET_WORD(dmaChannel.DESTADDRH, dmaChannel.DESTADDRL, &destString);   // The start address of the destination.
   SET_WORD(dmaChannel.LENH, dmaChannel.LENL, 12);    // Setting the number of bytes to transfer.
   //dmaChannel.VLEN      = VLEN_USE_LEN;  // Using the length field to determine how many bytes to transfer.
   dmaChannel.VLEN      = VLEN_USE_LEN;
   dmaChannel.PRIORITY  = PRI_HIGH;      // High priority.
   dmaChannel.M8        = M8_USE_8_BITS; // Irrelevant since length is determined by the LENH and LENL.
   dmaChannel.IRQMASK   = FALSE;         // The DMA shall not issue an IRQ upon completion.
   dmaChannel.DESTINC   = DESTINC_1;     // The destination address is to be incremented by 1 after each transfer.
   dmaChannel.SRCINC    = SRCINC_1;      // The source address inremented by 1 byte after each transfer.
   dmaChannel.TRIG      = DMATRIG_NONE;  // The DMA channel will be started manually.
   dmaChannel.TMODE     = TMODE_BLOCK;   // The number of bytes specified by LENH and LENL is transferred.
   dmaChannel.WORDSIZE  = WORDSIZE_BYTE; // One byte is transferred each time.

  DMA_SET_ADDR_DESC0(&dmaChannel);
  DMA_ABORT_CHANNEL(0);
  DMA_ARM_CHANNEL(0);
  halWait(10);
  DMAIRQ = 0x00;
  DMA_START_CHANNEL(0);
  while( !(DMAIRQ & DMA_CHANNEL_0) );
  halWait(10);
}

请参考: http://e2e.ti.com/support/low_power_rf/f/156/t/17207.aspx

没有资料阿???

Group Not Found The requested Group cannot be found.

最后也没有解决方式阿,,,....

我直接复制吧,回答了了IAR转KEIL的注意点

one of the things to consider when porting code from IAR EW8051 to the Keil C compiler is that they have different endianness (little endian vs big endian, respectively). This will most likely cause trouble for structs containing DMA configuration descriptor, as the chip requires the various fields to be ordered in a specific way (see the data sheet). As this doesn't give any compiler warnings this problem can be hard to notice when you're not aware of it. But when you are, it is quite easy to check that the DMA configuration struct has the correct layout by inspecting the struct in the debugger.

Other things that will need porting is intrisic functions [ e.g. asm("nop") -> _nop_() ] (if used), memory attributes [e.g.  __xdata -> xdata ] and maybe you will need to change the syntax for declaring the ISR functions. 

#pragma bitfields=reversed 问题是这个keil无法使用


问题花了一天,自己解决了!


struct
{
short a:3;   /* a is 3 bits */
short :5;   /* this reserves a hole of 5 bits */
short b:4;   /* b is 4 bits */
} bits;      /* bits is 16 bits */
 
  15                    12  11                       8 7                             3 2                    0         
Hole(4)                                b:4                         Hole(5)                     a:3
 
對照組如下: 
#pragma bitfields=reversed
struct
{
short a:3;   /* a is 3 bits */
short :5;  /* this reserves a hole of 5 bits */
short b:4;  /* b is 4 bits */
} bits;     /* bits is 16 bits */
 
  15                    13  12                       8 7                             4 3                    0  
              a:3                          Hole(5)                    b:4                      Hole(4)

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top