• AVR Freaks

Hot!Question about CE214

Author
ezedhill
Starting Member
  • Total Posts : 78
  • Reward points : 0
  • Joined: 2019/02/07 06:43:05
  • Location: 0
  • Status: offline
2019/03/21 06:32:38 (permalink)
0

Question about CE214

I have never used DMA before. CE214 is an example of using DMA channels with the UART peripheral. The DMA channels are associated with the following two buffers.
 
//********************************************************************************
//  STEP 6:
//  Allocate two buffers for DMA transfers
//********************************************************************************/
unsigned int BufferA[8] __attribute__((space(dma)));
unsigned int BufferB[8] __attribute__((space(dma)));
 
Forgive my ignorance, but how do I initiate a transmission? Like this;
For(x = 0; x < 8; x++)
{
      U2TXREG = TXdata[x];
}    
 
Here is the main snippet from the example.
 
int main(void)
{

 
// Configure Oscillator to operate the device at 40Mhz
// Fosc= Fin*M/(N1*N2), Fcy=Fosc/2
// Fosc= 8M*40/(2*2)=80Mhz for 8M input clock
 PLLFBD=38; // M=40
 CLKDIVbits.PLLPOST=0; // N1=2
 CLKDIVbits.PLLPRE=0; // N2=2
 OSCTUN=0; // Tune FRC oscillator, if FRC is used

 RCONbits.SWDTEN=0; /* Disable Watch Dog Timer*/

// Clock switch to incorporate PLL
 __builtin_write_OSCCONH(0x03); // Initiate Clock Switch to Primary
             // Oscillator with PLL (NOSC=0b011)
 __builtin_write_OSCCONL(0x01); // Start clock switching
 while (OSCCONbits.COSC != 0b011); // Wait for Clock switch to occur

 while(OSCCONbits.LOCK!=1) {}; /* Wait for PLL to lock*/


 //This routine Configures DMAchannel 0 for transmission.
 cfgDma0UartTx();

 //This routine Configures DMAchannel 1 for reception.
 cfgDma1UartRx();

 // UART Configurations
 cfgUart2();

    while(1);
}
 
#1

2 Replies Related Threads

    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3122
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Question about CE214 2019/03/21 09:40:18 (permalink)
    0
    If you don't know anything about DMA, no one will be able to help you because it would take too long to explain.
     
    The best advice I can give is to download this from Microchip:
    Section 54. Direct Memory Access Controller (DMA)
     
    Read it several times.
     
     
     

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #2
    ezedhill
    Starting Member
    • Total Posts : 78
    • Reward points : 0
    • Joined: 2019/02/07 06:43:05
    • Location: 0
    • Status: offline
    Re: Question about CE214 2019/03/21 11:45:06 (permalink)
    0
    Thanks, reading it now. 
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5