• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Low Power RF & Wireless Connectivity » Low Power RF Proprietary Software & SimpliciTI Forum » DMA write to RAM on the CC2530
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

DMA write to RAM on the CC2530

DMA write to RAM on the CC2530

This question is answered
Katie Miller
Posted by Katie Miller
on Apr 10 2012 17:18 PM
Prodigy215 points

Hi,

I am trying to use the DMA to write values from the ADC to RAM, but I am having a hard time getting this to work. Does anyone know where some example code is that uses the DMA to write to RAM? Everything I find deals with flash.

Thanks for any help,

Katie

dma CC2530 ADC RAM
Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Katie Miller
    Posted by Katie Miller
    on Apr 10 2012 17:51 PM
    Prodigy215 points

    To give you an idea, this is the code that I am using. It is a simple test to see if I can move data from one address to another using the DMA. I was then planning on changing the source address to the ADC once it works. However, it gets stuck on the line:  while (!(DMAIRQ& 0x01)); 

    Thanks for your help,

    Katie

    unsigned char Data[8]=
    {
     0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0x99, 0x88, 0x77
    };


    unsigned char buf[8]=
    {
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    };
    typedef struct {
         uint8 SRCADDRH; //Byte 0
         uint8 SRCADDRL; //Byte 1
         uint8 DESTADDRH; //Byte 2
         uint8 DESTADDRL; //Byte 3
         uint8 LENH:5; //Byte 4 - Bit 4:0
         uint8 VLEN:3; //Byte 4 - Bit 7:5
         uint8 LENL; //Byte 5
         uint8 TRIG:5; //Byte 6 - Bit 4:0
         uint8 TMODE:2; //Byte 6 - Bit 6:5
         uint8 WORDSIZE:1; //Byte 6 - Bit 7
         uint8 PRIORITY:2; //Byte 7 - Bit 1:0
         uint8 M8:1; //Byte 7 - Bit 2
         uint8 IRQMASK:1; //Byte 7 - Bit 3
         uint8 DESTINC:2; //Byte 7 - Bit 5:4
         uint8 SRCINC:2; //Byte 7 - Bit 7:6
    } DMA_DESC;

    void WriteFlashDMA(uint8 *data, uint16 length, uint16 flashadr)
    {
           DMA_DESC dmaConfig0;
           dmaConfig0.SRCADDRH  = ((uint16)data >> 8) & 0x00FF;
           dmaConfig0.SRCADDRL  = (uint16)data & 0x00FF;
           dmaConfig0.DESTADDRH = (((uint16)&buf) >> 8) & 0x00FF;
           dmaConfig0.DESTADDRL = ((uint16)&buf) & 0x00FF;
           dmaConfig0.VLEN      = 0;
           dmaConfig0.LENH      = (length>>8) & 0x00FF;
           dmaConfig0.LENL      = length & 0x00FF;
           dmaConfig0.WORDSIZE  = 0;
           dmaConfig0.TMODE     = 0;
           dmaConfig0.TRIG      = 0;
           dmaConfig0.SRCINC    = 1;
           dmaConfig0.DESTINC   = 1;
           dmaConfig0.IRQMASK   = 0;
           dmaConfig0.M8        = 0;
           dmaConfig0.PRIORITY  = 2;

          // while (FCTL & 0x80);
          // FADDRH =(flashadr >> 10) & 0x00FF;
          // FADDRL = (flashadr >> 2) & 0x00FF;
     
           
           //need to set the DMAREQ.DMAREQx bit to start transfer
          
           DMA0CFGH = (((uint16)&dmaConfig0) >> 8) & 0x00FF;
           DMA0CFGL = ((uint16)&dmaConfig0) & 0x00FF;
           DMAARM |= 0x01;
           DMAREQ = 0x01; //change least sig bit for channel 0
           DMAIRQ = 0x00;  
          // FCTL |= 0x02;
           while (!(DMAIRQ& 0x01));
           DMAIRQ = 0xFE;
          // while (FCTL & (0x80));

    }

    void main()
    {

         uint16 flashAddr = 0x7475;
         WriteFlashDMA(Data,8,flashAddr);

    }

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Dirty Harry
    Posted by Dirty Harry
    on Apr 10 2012 19:22 PM
    Verified Answer
    Verified by Dirty Harry
    Mastermind19350 points

    You can look at the HAL module that uses DMA to move bytes from the UxDBUF to a queue in XDATA (aka RAM):

    C:\Texas Instruments\ZStack-CC2530-2.5.0\Components\hal\target\CC2530EB\_hal_uart_dma.c

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Katie Miller
    Posted by Katie Miller
    on Apr 12 2012 13:12 PM
    Prodigy215 points

    Hi Dirty Harry,

    I was hoping not to add complexity to my code by using zstack, it has a lot of stuff that I don't need. Is it not easy/possible to use the dma to write to ram without using either zstack or timac? Thanks for your quick response,

    Katie

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Dirty Harry
    Posted by Dirty Harry
    on Apr 12 2012 13:17 PM
    Verified Answer
    Verified by Dirty Harry
    Mastermind19350 points

    I was trying to answer your question: "Does anyone know where some example code is that uses the DMA to write to RAM?" by pointing you to a module that uses the DMA to transfer bytes from an SOC peripheral to the XDATA RAM. Although you will want to transfer bytes from the ADC peripheral and the "example code" that I reference transfers from the UART peripheral, it is nonetheless simple, example code of how to setup the DMA channel which you can take or leave. By no means am I recommending you to use the Z-Stack - although, to tell you the truth, I was presuming that you were since you posted in this E2E forum instead of the Proprietary Software forum.

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use