|
|
View previous topic :: View next topic |
Author |
Message |
benoitstjean
Joined: 30 Oct 2007 Posts: 552 Location: Ottawa, Ontario, Canada
|
|
Posted: Fri Sep 21, 2012 12:49 pm |
|
|
This is some of the code I found in CCS for DMA. Shouldn't it work? Note that I haven't tested any of it yet, but will that code work or it's *there* but not functional?
Code: |
short DMA_SPI_IN_TRANSFERRED = false;
short DMA_SPI_OUT_TRANSFERRED = false;
// Allocate 1024 D-WORDS of DMA RAM for SPI IN Buffer A
#BANK_DMA
unsigned int DMA_SPI_IN_BUFFER_A[DMA_BUFFERSIZE];
// Allocate 1024 D-WORDS of DMA RAM for SPI OUT Buffer A
#BANK_DMA
unsigned int DMA_SPI_OUT_BUFFER_A[DMA_BUFFERSIZE];
// DMA Channel 0 interrupt routine (SPI IN)
#INT_DMA0
void DMA_IN_ISR( void )
{
DMA_SPI_IN_TRANSFERRED = TRUE;
}
// DMA Channel 0 interrupt routine (SPI OUT)
#INT_DMA1
void DMA_OUT_ISR( void )
{
DMA_SPI_OUT_TRANSFERRED = TRUE;
printf( "o" );
}
In the main file:
DMA_SPI_IN_TRANSFERRED = false;
DMA_SPI_OUT_TRANSFERRED = false;
setup_dma( 0, DMA_IN_SPI2, DMA_BYTE );
setup_dma( 1, DMA_OUT_SPI2, DMA_BYTE );
enable_interrupts( INT_DMA0 );
enable_interrupts( INT_DMA1 );
enable_interrupts( INT_SPI2 );
dma_start( 0, DMA_CONTINOUS, &DMA_SPI_IN_BUFFER_A[0] );
dma_start( 1, DMA_CONTINOUS, &DMA_SPI_OUT_BUFFER_A[0] ); |
Ben |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
Posted: Fri Sep 21, 2012 1:39 pm |
|
|
You are correct...
I was looking at DMA for a PIC18F which has a DMA transfer, but not the same controller as the PIC24's and just didn't think that far.
And the last time I looked for DMA was years ago when PCD came out and I didn't remember it being in there as PCD was so new.
(I could swear I typed it into the CCS help and got no results)
but there ya go.
Let us know how DMA functions in CCS work out for you. PCD is sometimes known to still have a few rough edges.
Cheers,
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|
|
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
|