CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

Example DMA code for the DsPIC33

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
dyeatman



Joined: 06 Sep 2003
Posts: 1785
Location: Norman, OK

View user's profile Send private message

Example DMA code for the DsPIC33
PostPosted: Fri Jul 11, 2014 4:23 pm     Reply with quote

Written using CCS PCD Version 5.026 for the DsPIC Processor

After this code starts it blinks an LED on Pin E1 at 1Hz and waits for eight
consecutive characters to arrive via UART1 then prints them on the
terminal. If this simple code doesn't work in hardware with the above
version you have a hardware problem. It is NOT designed to be used in
Proteus!!

Code:

#include <33FJ256MC710.h>
#FUSES XT
#FUSES NOWDT                  //No Watch Dog Timer
#FUSES PUT128                 //Power On Reset Timer value 128ms
#device ICSP=1
#use delay(internal=16MHZ)
//
#use rs232(baud=9600, UART1,bits=8,parity=N)//
//
#BANK_DMA
    char UARTBUFF[8];
//
#INT_DMA0
void DMA0_ISR(void)
{
   int i;
   printf("Buffer= ");
   for(i=0;i<8;++i)
       printf("%c", UARTBUFF[i]);
   
   printf("\r\n\n");
}
////////////////////////////////////
/////////// Begin Main /////////////
////////////////////////////////////
void main()
{
   setup_ADC_PORTS(NO_ANALOGS);// make sure they dont interfere if we dont need them
//
   setup_dma(0, DMA_IN_UART1, DMA_BYTE);
   dma_start(0, DMA_CONTINOUS, UARTBUFF);   
//
   enable_interrupts(INT_DMA0);      //enable DMA interrupt
   enable_interrupts(GLOBAL);       //enable interrupts
  //
For(;;)
  { ///////// main loop /////////////////////
    output_toggle(pin_E1); // verify the chip is running and at the right speed
    delay_ms(500);  // led should blink at 1Hz
 }
}  // end Main Routine

_________________
Google and Forum Search are some of your best tools!!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group