Hi,
I am combining code for DMA in pingpong mode and timer in autoreload mode. I have observed the timer interrupt is not working. Please help me to sort this issue.
please find the below settings for timer initialization and ISR. I have also pasted the DMA initialization and ISR.
/********************************************************************** **+-----------------------------------------------------------------+** **| **** |** **| **** |** **| ******o*** |** **| ********_///_**** |** **| ***** /_//_/ **** |** **| ** ** (__/ **** |** **| ********* |** **| **** |** **| *** |** **| |** **| Copyright (c) 2006 - 2010 Texas Instruments Incorporated |** **| ALL RIGHTS RESERVED |** **| |** **| Permission is hereby granted to licensees of Texas Instruments |** **| Incorporated (TI) products to use this computer program for |** **| the sole purpose of implementing a licensee product based |** **| on TI products.No other rights to reproduce, use, or |** **| disseminate this computer program, whether in part or in whole, |** **| are granted.TI makes no representation or warranties with |** **| respect to the performance of this computer program, and |** **| specifically disclaims any responsibility for any damages, |** **| special or consequential,connected with the use of this program.|** **| |** **+-----------------------------------------------------------------+** **********************************************************************/ #include "data_types.h" #include "timer.h" #include "register_cpu.h" void Timer0Init(void) { /* Timer0 Initialization */ // timer interval 10msec // prescale = 0 (devide by 2) // 100/2 = 50MHz ==> 20 nsec // 10msec/20nsec = 500000 (0x7A120) /* TIM0 EN | AutoReload disable | Prescale = 0(100/2 = 50MHz) ==> 20nsec */ *CPU_TIM0_CTRL = 0x8002; // autoReload // *CPU_TIM0_CTRL = 0x8000; // disable autoReload *CPU_TIM0_PLWR = 0xA120; *CPU_TIM0_PHWR = 0x0007; *CPU_TIM0_CLWR = 0x0000; *CPU_TIM0_CHWR = 0x0000; /* Clearing timer Aggregation register*/ *CPU_TIMINT_AGGR = 0x0007; /* enable timer0 int flag*/ *CPU_TIM0_IER = 0x0001; } void StartTimer0(void) { /* Start the Timer 0*/ *CPU_TIM0_CTRL = *CPU_TIM0_CTRL | 0x0001; } interrupt void Timer_isr(void) { // clear timer int flag IFR0 = IFR0&0x0010; /* clear timer0 int flag*/ *CPU_TIM0_IER = 0x0001; /* Clear Timer0 bit in Timer Aggregate register*/ *CPU_TIMINT_AGGR = *CPU_TIMINT_AGGR | 0x0001 ; //StartTimer0(); }
/****************************************************************************** **+-------------------------------------------------------------------------+** **| **** |** **| **** |** **| ******o*** |** **| ********_///_**** |** **| ***** /_//_/ **** |** **| ** ** (__/ **** |** **| ********* |** **| **** |** **| *** |** **| |** **| Copyright (c) 2006 - 2010 Texas Instruments Incorporated |** **| ALL RIGHTS RESERVED |** **| |** **| Permission is hereby granted to licensees of Texas Instruments |** **| Incorporated (TI) products to use this computer program for the sole |** **| purpose of implementing a licensee product based on TI products. |** **| No other rights to reproduce, use, or disseminate this computer |** **| program, whether in part or in whole, are granted. |** **| |** **| TI makes no representation or warranties with respect to the |** **| performance of this computer program, and specifically disclaims |** **| any responsibility for any damages, special or consequential, |** **| connected with the use of this program. |** **| |** **+-------------------------------------------------------------------------+** ******************************************************************************/ #include "data_types.h" #include "register_dma.h" #include "register_cpu.h" #include "dma.h" #include "i2s.h" #define XMIT_BUFF_SIZE 48 #define AUTO_RELOAD 1 #define SINE_WAVE 2 Int16 RcvL1[XMIT_BUFF_SIZE]; Int16 RcvR1[XMIT_BUFF_SIZE]; Int16 RcvL2[XMIT_BUFF_SIZE]; Int16 RcvR2[XMIT_BUFF_SIZE]; Uint32 RxL1_DMA_address; Uint32 RxL2_DMA_address; Uint32 RxR1_DMA_address; Uint32 RxR2_DMA_address; Uint32 TxL1_DMA_address; Uint32 TxL2_DMA_address; Uint32 TxR1_DMA_address; Uint32 TxR2_DMA_address; Uint16 CurrentRxL_DMAChannel =1; Uint16 CurrentRxR_DMAChannel =1; Uint16 CurrentTxL_DMAChannel =1; Uint16 CurrentTxR_DMAChannel =1; // 1: L1, R1 channel // 2: L2, R2 channel // -3dB 1 KHz sine sampled at 48 KHz Int16 XmitL_Sine_1K[XMIT_BUFF_SIZE] = { 0x0000,0x0B6C,0x16A6,0x217C,0x2BC0,0x3544,0x3DDF,0x456B, 0x4BC7,0x50D7,0x5485,0x56C0,0x5780,0x56C0,0x5485,0x50D7, 0x4BC7,0x456B,0x3DDF,0x3544,0x2BC0,0x217C,0x16A6,0x0B6C, 0x0000,0xF494,0xE95A,0xDE84,0xD440,0xCABC,0xC221,0xBA95, 0xB439,0xAF29,0xAB7B,0xA940,0xA880,0xA940,0xAB7B,0xAF29, 0xB439,0xBA95,0xC221,0xCABC,0xD440,0xDE84,0xE95A,0xF494 }; //-3 dB 2 KHz sine sampled at 48 KHz Int16 XmitL_Sine_2K[XMIT_BUFF_SIZE] = { 0x0000,0x16A6,0x2BC0,0x3DDF,0x4BC7,0x5485,0x5780,0x5485, 0x4BC7,0x3DDF,0x2BC0,0x16A6,0x0000,0xE95A,0xD440,0xC221, 0xB439,0xAB7B,0xA880,0xAB7B,0xB439,0xC221,0xD440,0xE95A, 0x0000,0x16A6,0x2BC0,0x3DDF,0x4BC7,0x5485,0x5780,0x5485, 0x4BC7,0x3DDF,0x2BC0,0x16A6,0x0000,0xE95A,0xD440,0xC221, 0xB439,0xAB7B,0xA880,0xAB7B,0xB439,0xC221,0xD440,0xE95A }; // -3dB 1 KHz sine sampled at 48 KHz Int16 XmitR_Sine_1K[XMIT_BUFF_SIZE] = { 0x0000,0x0B6C,0x16A6,0x217C,0x2BC0,0x3544,0x3DDF,0x456B, 0x4BC7,0x50D7,0x5485,0x56C0,0x5780,0x56C0,0x5485,0x50D7, 0x4BC7,0x456B,0x3DDF,0x3544,0x2BC0,0x217C,0x16A6,0x0B6C, 0x0000,0xF494,0xE95A,0xDE84,0xD440,0xCABC,0xC221,0xBA95, 0xB439,0xAF29,0xAB7B,0xA940,0xA880,0xA940,0xAB7B,0xAF29, 0xB439,0xBA95,0xC221,0xCABC,0xD440,0xDE84,0xE95A,0xF494 }; //-3 dB 2 KHz sine sampled at 48 KHz Int16 XmitR_Sine_2K[XMIT_BUFF_SIZE] = { 0x0000,0x16A6,0x2BC0,0x3DDF,0x4BC7,0x5485,0x5780,0x5485, 0x4BC7,0x3DDF,0x2BC0,0x16A6,0x0000,0xE95A,0xD440,0xC221, 0xB439,0xAB7B,0xA880,0xAB7B,0xB439,0xC221,0xD440,0xE95A, 0x0000,0x16A6,0x2BC0,0x3DDF,0x4BC7,0x5485,0x5780,0x5485, 0x4BC7,0x3DDF,0x2BC0,0x16A6,0x0000,0xE95A,0xD440,0xC221, 0xB439,0xAB7B,0xA880,0xAB7B,0xB439,0xC221,0xD440,0xE95A }; //Int16 XmitL_Sine_1K[XMIT_BUFF_SIZE]={0}; //Int16 XmitL_Sine_2K[XMIT_BUFF_SIZE]={0}; //Int16 XmitR_Sine_1K[XMIT_BUFF_SIZE]={0}; //Int16 XmitR_Sine_2K[XMIT_BUFF_SIZE]={0}; Int16 RcvL_Sine[XMIT_BUFF_SIZE]={0}; Int16 RcvR_Sine[XMIT_BUFF_SIZE]={0}; Uint16 DMA_Count =0, Error_Count_L =0, Error_Count_R =0; Uint16 DMA_Done = 0; extern Uint16 fSineWave; void setDMA_address(void) { // just bypass with double buffering, for checking ping-pong buffer RxL1_DMA_address = (Uint32)RcvL1; RxL1_DMA_address = (RxL1_DMA_address<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA RxL2_DMA_address = (Uint32)RcvL2; RxL2_DMA_address = (RxL2_DMA_address<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA RxR1_DMA_address = (Uint32)RcvR1; RxR1_DMA_address = (RxR1_DMA_address<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA RxR2_DMA_address = (Uint32)RcvR2; RxR2_DMA_address = (RxR2_DMA_address<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA TxL1_DMA_address = (Uint32)RcvL2; TxL1_DMA_address = (TxL1_DMA_address<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA TxL2_DMA_address = (Uint32)RcvL1; TxL2_DMA_address = (TxL2_DMA_address<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA TxR1_DMA_address = (Uint32)RcvR2; TxR1_DMA_address = (TxR1_DMA_address<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA TxR2_DMA_address = (Uint32)RcvR1; TxR2_DMA_address = (TxR2_DMA_address<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA } void set_dma1_ch0_stop(void) { Uint16 temp; // DMA stop temp = DMA1_CH0_TC_MSW; temp &= 0x7FFF; DMA1_CH0_TC_MSW = temp; } void set_dma1_ch1_stop(void) { Uint16 temp; // DMA stop temp = DMA1_CH1_TC_MSW; temp &= 0x7FFF; DMA1_CH1_TC_MSW = temp; } Uint16 set_dma1_ch0_i2s2_Lout(void) { Uint16 temp; Uint32 add; DMA1_CH0_TC_LSW = XMIT_BUFF_SIZE*2; #if(AUTO_RELOAD ==1) DMA1_CH0_TC_MSW = 0x3204; //src incre, destination fix, sync, auto #else DMA1_CH0_TC_MSW = 0x2204; //src incre, destination fix, sync, No auto #endif temp = DMA1_CH10_EVENT_SRC; DMA1_CH10_EVENT_SRC = temp | 0x0001; // I2S2 transmit event // if(fSineWave ==1) // { // add = (Uint32)XmitL_Sine_1K; // } // else // { // add = (Uint32)XmitL_Sine_2K; // } // add = (Uint32)XmitL_Sine_1K; // add = (add<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA DMA1_CH0_SRC_LSW = (Uint16)TxL1_DMA_address; DMA1_CH0_SRC_MSW = 0xFFFF & (TxL1_DMA_address >> 16); DMA1_CH0_DST_LSW = 0x2A08; // is20 transmit left data register lsw // DMA starts temp = DMA1_CH0_TC_MSW; temp |= 0x8000; DMA1_CH0_TC_MSW = temp; return SUCCESS; } Uint16 set_dma1_ch1_i2s2_Rout(void) { Uint16 temp; Uint32 add; DMA1_CH1_TC_LSW = XMIT_BUFF_SIZE*2; // DMA0_CH1_TC_LSW = 8; #if(AUTO_RELOAD ==1) DMA1_CH1_TC_MSW = 0x3204; //src incre, destination fix, sync, auto #else DMA1_CH1_TC_MSW = 0x2204; //src incre, destination fix, sync, No auto #endif temp = DMA1_CH10_EVENT_SRC; DMA1_CH10_EVENT_SRC = temp | 0x0100; // I2S2 transmit event // if(fSineWave ==1) // { // add = (Uint32)XmitR_Sine_1K; // } // else // { // add = (Uint32)XmitR_Sine_2K; // } // add = (Uint32)XmitR_Sine_1K; // add = (add<<1) + 0x10000; //// change word address to byte address and add DARAM offset for DMA DMA1_CH1_SRC_LSW = (Uint16)TxR1_DMA_address; DMA1_CH1_SRC_MSW = 0xFFFF & (TxR1_DMA_address >> 16); DMA1_CH1_DST_LSW = 0x2A0C; // is20 transmit right data register lsw // DMA starts temp = DMA1_CH1_TC_MSW; temp |= 0x8000; DMA1_CH1_TC_MSW = temp; return SUCCESS; } Uint16 set_dma1_ch2_i2s2_Lin(void) { Uint16 temp; Uint32 add; DMA1_CH2_TC_LSW = XMIT_BUFF_SIZE*2; #if(AUTO_RELOAD ==1) DMA1_CH2_TC_MSW = 0x3084; //src fix, destination increase, sync, auto, int #else DMA1_CH2_TC_MSW = 0x2084; //src fix, destination increase,, No auto, int #endif temp = DMA1_CH32_EVENT_SRC; DMA1_CH32_EVENT_SRC = temp | 0x0002; // I2S2 receive event // add=(Uint16)RcvL_Sine; // add = (add<<1) + 0x10000; //// change word address to byte address and add DARAM offset for DMA DMA1_CH2_DST_LSW = RxL1_DMA_address; DMA1_CH2_DST_MSW = 0xFFFF & (RxL1_DMA_address >> 16); DMA1_CH2_SRC_LSW = 0x2A28; // is22 receive left data register lsw DMA1_CH2_SRC_MSW = 0; // CurrentRxL_DMAChannel =1; // DMA starts temp = DMA1_CH2_TC_MSW; temp |= 0x8000; DMA1_CH2_TC_MSW = temp; return SUCCESS; } Uint16 set_dma1_ch3_i2s2_Rin(void) { Uint16 temp; Uint32 add; DMA1_CH3_TC_LSW = XMIT_BUFF_SIZE*2; #if(AUTO_RELOAD ==1) DMA1_CH3_TC_MSW = 0x3084; //src fix, destination increase, sync, auto , int #else DMA1_CH3_TC_MSW = 0x2084; //src fix, destination increase,, No auto, int #endif temp = DMA1_CH32_EVENT_SRC; DMA1_CH32_EVENT_SRC = temp | 0x0200; // I2S2 receive event // add=(Uint16)RcvR_Sine; // add = (add<<1) + 0x10000; DMA1_CH3_DST_LSW = (Uint16)RxR1_DMA_address; DMA1_CH3_DST_MSW = 0xFFFF & (RxR1_DMA_address >> 16); DMA1_CH3_SRC_LSW = 0x2A2C; // is22 receive right data register lsw DMA1_CH3_SRC_MSW = 0; // CurrentRxR_DMAChannel =1; // DMA starts temp = DMA1_CH3_TC_MSW; temp |= 0x8000; DMA1_CH3_TC_MSW = temp; return SUCCESS; } void enable_dma_int(void) { DMA_MSK = 0x00F0; // enable all interrupts DMA_IFR = 0xFFFF; // clear interrupt flags } //#if 1 //interrupt void DMA_Isr(void) //{ // Uint16 temp,i; // Uint32 add; // temp = IFR0; // IFR0 = temp; // // temp = DMA_IFR; // DMA_IFR = temp; // clear interrupt flags // ////#if(AUTO_RELOAD ==0) //// if(temp&0xF000 != 0) // ch 2 of DMA3 //// { //// for(i=0; i < XMIT_BUFF_SIZE; i++) //// { //// if (XmitL_Sine[i] != RcvL_Sine[i]) //// { //// Error_Count_L++; //// break; //// } //// } //// for(i=0; i < XMIT_BUFF_SIZE; i++) //// { //// if (XmitR_Sine[i] != RcvR_Sine[i]) //// { //// Error_Count_R++; //// break; //// } //// }//for(temp=0; temp < XMIT_BUFF_SIZE; temp++) //// DMA_Done = 1; //// } ////#endif // //} //#endif interrupt void DMA_Isr(void) { Uint16 temp;//, dma_start; Uint32 add; temp = IFR0; IFR0 = temp&0x0100; temp = DMA_IFR; // DMA_IFR = temp; // clear interrupt flags if(temp&0x0010) { // // DMA TxL interrupt (channel 0) if(CurrentTxL_DMAChannel ==1) { CurrentTxL_DMAChannel =2; DMA1_CH0_SRC_LSW = (Uint16)TxL2_DMA_address; DMA1_CH0_SRC_MSW = 0xFFFF & (TxL2_DMA_address >> 16); } else { CurrentTxL_DMAChannel =1; DMA1_CH0_SRC_LSW = (Uint16)TxL1_DMA_address; DMA1_CH0_SRC_MSW = 0xFFFF & (TxL1_DMA_address >> 16); } // add = (Uint32)XmitL_Sine_1K; // add = (add<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA // DMA1_CH0_SRC_LSW = (Uint16)add; DMA_IFR = 0x0010; // clear interrupt flags // temp = DMA1_CH0_TC_MSW; // temp |= 0x8000; // DMA1_CH0_TC_MSW = temp; } else if(temp&0x0020) { // DMA TxR interrupt (channel 1) if(CurrentTxR_DMAChannel ==1) { CurrentTxR_DMAChannel =2; DMA1_CH1_SRC_LSW = (Uint16)TxR2_DMA_address; DMA1_CH1_SRC_MSW = 0xFFFF & (TxR2_DMA_address >> 16); } else { CurrentTxR_DMAChannel =1; DMA1_CH1_SRC_LSW = (Uint16)TxR1_DMA_address; DMA1_CH1_SRC_MSW = 0xFFFF & (TxR1_DMA_address >> 16); } // add = (Uint32)XmitR_Sine_1K; // add = (add<<1) + 0x10000; //// change word address to byte address and add DARAM offset for DMA // DMA1_CH1_SRC_LSW = (Uint16)add; DMA_IFR = 0x0020; // clear interrupt flags // temp = DMA1_CH1_TC_MSW; // temp |= 0x8000; // DMA1_CH1_TC_MSW = temp; // temp=I2S2_W0_MSW_R; } else if(temp&0x0040) { // RunFilterForL =1; // // DMA RxL interrupt (channel 2) if(CurrentRxL_DMAChannel ==1) { // change DMA Tx SRC address CurrentRxL_DMAChannel =2; DMA1_CH2_DST_LSW = (Uint16)RxL2_DMA_address; DMA1_CH2_DST_MSW = 0xFFFF & (RxL2_DMA_address >> 16); } else { CurrentRxL_DMAChannel =1; DMA1_CH2_DST_LSW = (Uint16)RxL1_DMA_address; DMA1_CH2_DST_MSW = 0xFFFF & (RxL1_DMA_address >> 16); } //// add=(Uint16)RcvL_Sine; //// add = (add<<1) + 0x10000; //// change word address to byte address and add DARAM offset for DMA // DMA1_CH2_DST_LSW = add; // DMA1_CH2_DST_MSW = 0xFFFF & (add >> 16); DMA_IFR = 0x0040; // clear interrupt flags // temp = DMA1_CH2_TC_MSW; // temp |= 0x8000; // DMA1_CH2_TC_MSW = temp; } else if(temp&0x0080) { // RunFilterForR =1; // // DMA RxR interrupt (channel 3) if(CurrentRxR_DMAChannel ==1) { // change DMA Tx SRC address CurrentRxR_DMAChannel =2; DMA1_CH3_DST_LSW = (Uint16)RxR2_DMA_address; DMA1_CH3_DST_MSW = 0xFFFF & (RxR2_DMA_address >> 16); } else { CurrentRxR_DMAChannel =1; DMA1_CH3_DST_LSW = (Uint16)RxR1_DMA_address; DMA1_CH3_DST_MSW = 0xFFFF & (RxR1_DMA_address >> 16); } // add=(Uint16)RcvR_Sine; // add = (add<<1) + 0x10000; // DMA1_CH3_DST_LSW = (Uint16)add; // DMA1_CH3_DST_MSW = 0xFFFF & (add >> 16); DMA_IFR = 0x0080; // clear interrupt flags // temp = DMA1_CH3_TC_MSW; // temp |= 0x8000; // DMA1_CH3_TC_MSW = temp; } }
TIMER:
void Timer0Init(void)
{
/* Timer0 Initialization */
// timer interval 10msec
// prescale = 0 (devide by 2)
// 100/2 = 50MHz ==> 20 nsec
// 10msec/20nsec = 500000 (0x7A120)
/* TIM0 EN | AutoReload disable | Prescale = 0(100/2 = 50MHz) ==> 20nsec */
*CPU_TIM0_CTRL = 0x8002; // autoReload
// *CPU_TIM0_CTRL = 0x8000; // disable autoReload
*CPU_TIM0_PLWR = 0xA120;
*CPU_TIM0_PHWR = 0x0007;
*CPU_TIM0_CLWR = 0x0000;
*CPU_TIM0_CHWR = 0x0000;
/* Clearing timer Aggregation register*/
*CPU_TIMINT_AGGR = 0x0007;
/* enable timer0 int flag*/
*CPU_TIM0_IER = 0x0001;
}
void StartTimer0(void)
{
/* Start the Timer 0*/
*CPU_TIM0_CTRL = *CPU_TIM0_CTRL | 0x0001;
}
interrupt void Timer_isr(void)
{
// clear timer int flag
IFR0 = IFR0&0x0010;
/* clear timer0 int flag*/
*CPU_TIM0_IER = 0x0001;
/* Clear Timer0 bit in Timer Aggregate register*/
*CPU_TIMINT_AGGR = *CPU_TIMINT_AGGR | 0x0001 ;
//StartTimer0();
}
DMA:
Uint16 set_dma1_ch0_i2s2_Lout(void)
{
Uint16 temp;
Uint32 add;
DMA1_CH0_TC_LSW = XMIT_BUFF_SIZE*2;
#if(AUTO_RELOAD ==1)
DMA1_CH0_TC_MSW = 0x3204; //src incre, destination fix, sync, auto
#else
DMA1_CH0_TC_MSW = 0x2204; //src incre, destination fix, sync, No auto
#endif
temp = DMA1_CH10_EVENT_SRC;
DMA1_CH10_EVENT_SRC = temp | 0x0001; // I2S2 transmit event
// if(fSineWave ==1)
// {
// add = (Uint32)XmitL_Sine_1K;
// }
// else
// {
// add = (Uint32)XmitL_Sine_2K;
// }
// add = (Uint32)XmitL_Sine_1K;
// add = (add<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA
DMA1_CH0_SRC_LSW = (Uint16)TxL1_DMA_address;
DMA1_CH0_SRC_MSW = 0xFFFF & (TxL1_DMA_address >> 16);
DMA1_CH0_DST_LSW = 0x2A08; // is20 transmit left data register lsw
// DMA starts
temp = DMA1_CH0_TC_MSW;
temp |= 0x8000;
DMA1_CH0_TC_MSW = temp;
return SUCCESS;
}
Uint16 set_dma1_ch1_i2s2_Rout(void)
{
Uint16 temp;
Uint32 add;
DMA1_CH1_TC_LSW = XMIT_BUFF_SIZE*2;
// DMA0_CH1_TC_LSW = 8;
#if(AUTO_RELOAD ==1)
DMA1_CH1_TC_MSW = 0x3204; //src incre, destination fix, sync, auto
#else
DMA1_CH1_TC_MSW = 0x2204; //src incre, destination fix, sync, No auto
#endif
temp = DMA1_CH10_EVENT_SRC;
DMA1_CH10_EVENT_SRC = temp | 0x0100; // I2S2 transmit event
// if(fSineWave ==1)
// {
// add = (Uint32)XmitR_Sine_1K;
// }
// else
// {
// add = (Uint32)XmitR_Sine_2K;
// }
// add = (Uint32)XmitR_Sine_1K;
// add = (add<<1) + 0x10000; //// change word address to byte address and add DARAM offset for DMA
DMA1_CH1_SRC_LSW = (Uint16)TxR1_DMA_address;
DMA1_CH1_SRC_MSW = 0xFFFF & (TxR1_DMA_address >> 16);
DMA1_CH1_DST_LSW = 0x2A0C; // is20 transmit right data register lsw
// DMA starts
temp = DMA1_CH1_TC_MSW;
temp |= 0x8000;
DMA1_CH1_TC_MSW = temp;
return SUCCESS;
}
Uint16 set_dma1_ch2_i2s2_Lin(void)
{
Uint16 temp;
Uint32 add;
DMA1_CH2_TC_LSW = XMIT_BUFF_SIZE*2;
#if(AUTO_RELOAD ==1)
DMA1_CH2_TC_MSW = 0x3084; //src fix, destination increase, sync, auto, int
#else
DMA1_CH2_TC_MSW = 0x2084; //src fix, destination increase,, No auto, int
#endif
temp = DMA1_CH32_EVENT_SRC;
DMA1_CH32_EVENT_SRC = temp | 0x0002; // I2S2 receive event
// add=(Uint16)RcvL_Sine;
// add = (add<<1) + 0x10000; //// change word address to byte address and add DARAM offset for DMA
DMA1_CH2_DST_LSW = RxL1_DMA_address;
DMA1_CH2_DST_MSW = 0xFFFF & (RxL1_DMA_address >> 16);
DMA1_CH2_SRC_LSW = 0x2A28; // is22 receive left data register lsw
DMA1_CH2_SRC_MSW = 0;
// CurrentRxL_DMAChannel =1;
// DMA starts
temp = DMA1_CH2_TC_MSW;
temp |= 0x8000;
DMA1_CH2_TC_MSW = temp;
return SUCCESS;
}
Uint16 set_dma1_ch3_i2s2_Rin(void)
{
Uint16 temp;
Uint32 add;
DMA1_CH3_TC_LSW = XMIT_BUFF_SIZE*2;
#if(AUTO_RELOAD ==1)
DMA1_CH3_TC_MSW = 0x3084; //src fix, destination increase, sync, auto , int
#else
DMA1_CH3_TC_MSW = 0x2084; //src fix, destination increase,, No auto, int
#endif
temp = DMA1_CH32_EVENT_SRC;
DMA1_CH32_EVENT_SRC = temp | 0x0200; // I2S2 receive event
// add=(Uint16)RcvR_Sine;
// add = (add<<1) + 0x10000;
DMA1_CH3_DST_LSW = (Uint16)RxR1_DMA_address;
DMA1_CH3_DST_MSW = 0xFFFF & (RxR1_DMA_address >> 16);
DMA1_CH3_SRC_LSW = 0x2A2C; // is22 receive right data register lsw
DMA1_CH3_SRC_MSW = 0;
// CurrentRxR_DMAChannel =1;
// DMA starts
temp = DMA1_CH3_TC_MSW;
temp |= 0x8000;
DMA1_CH3_TC_MSW = temp;
return SUCCESS;
}
void enable_dma_int(void)
{
DMA_MSK = 0x00F0; // enable all interrupts
DMA_IFR = 0xFFFF; // clear interrupt flags
}
interrupt void DMA_Isr(void)
{
Uint16 temp;//, dma_start;
Uint32 add;
temp = IFR0;
IFR0 = temp&0x0100;
temp = DMA_IFR;
// DMA_IFR = temp; // clear interrupt flags
if(temp&0x0010)
{
// // DMA TxL interrupt (channel 0)
if(CurrentTxL_DMAChannel ==1)
{
CurrentTxL_DMAChannel =2;
DMA1_CH0_SRC_LSW = (Uint16)TxL2_DMA_address;
DMA1_CH0_SRC_MSW = 0xFFFF & (TxL2_DMA_address >> 16);
}
else
{
CurrentTxL_DMAChannel =1;
DMA1_CH0_SRC_LSW = (Uint16)TxL1_DMA_address;
DMA1_CH0_SRC_MSW = 0xFFFF & (TxL1_DMA_address >> 16);
}
// add = (Uint32)XmitL_Sine_1K;
// add = (add<<1) + 0x10000; // change word address to byte address and add DARAM offset for DMA
// DMA1_CH0_SRC_LSW = (Uint16)add;
DMA_IFR = 0x0010; // clear interrupt flags
// temp = DMA1_CH0_TC_MSW;
// temp |= 0x8000;
// DMA1_CH0_TC_MSW = temp;
}
else if(temp&0x0020)
{
// DMA TxR interrupt (channel 1)
if(CurrentTxR_DMAChannel ==1)
{
CurrentTxR_DMAChannel =2;
DMA1_CH1_SRC_LSW = (Uint16)TxR2_DMA_address;
DMA1_CH1_SRC_MSW = 0xFFFF & (TxR2_DMA_address >> 16);
}
else
{
CurrentTxR_DMAChannel =1;
DMA1_CH1_SRC_LSW = (Uint16)TxR1_DMA_address;
DMA1_CH1_SRC_MSW = 0xFFFF & (TxR1_DMA_address >> 16);
}
// add = (Uint32)XmitR_Sine_1K;
// add = (add<<1) + 0x10000; //// change word address to byte address and add DARAM offset for DMA
// DMA1_CH1_SRC_LSW = (Uint16)add;
DMA_IFR = 0x0020; // clear interrupt flags
// temp = DMA1_CH1_TC_MSW;
// temp |= 0x8000;
// DMA1_CH1_TC_MSW = temp;
// temp=I2S2_W0_MSW_R;
}
else if(temp&0x0040)
{
// RunFilterForL =1;
// // DMA RxL interrupt (channel 2)
if(CurrentRxL_DMAChannel ==1)
{
// change DMA Tx SRC address
CurrentRxL_DMAChannel =2;
DMA1_CH2_DST_LSW = (Uint16)RxL2_DMA_address;
DMA1_CH2_DST_MSW = 0xFFFF & (RxL2_DMA_address >> 16);
}
else
{
CurrentRxL_DMAChannel =1;
DMA1_CH2_DST_LSW = (Uint16)RxL1_DMA_address;
DMA1_CH2_DST_MSW = 0xFFFF & (RxL1_DMA_address >> 16);
}
//// add=(Uint16)RcvL_Sine;
//// add = (add<<1) + 0x10000; //// change word address to byte address and add DARAM offset for DMA
// DMA1_CH2_DST_LSW = add;
// DMA1_CH2_DST_MSW = 0xFFFF & (add >> 16);
DMA_IFR = 0x0040; // clear interrupt flags
// temp = DMA1_CH2_TC_MSW;
// temp |= 0x8000;
// DMA1_CH2_TC_MSW = temp;
}
else if(temp&0x0080)
{
// RunFilterForR =1;
// // DMA RxR interrupt (channel 3)
if(CurrentRxR_DMAChannel ==1)
{
// change DMA Tx SRC address
CurrentRxR_DMAChannel =2;
DMA1_CH3_DST_LSW = (Uint16)RxR2_DMA_address;
DMA1_CH3_DST_MSW = 0xFFFF & (RxR2_DMA_address >> 16);
}
else
{
CurrentRxR_DMAChannel =1;
DMA1_CH3_DST_LSW = (Uint16)RxR1_DMA_address;
DMA1_CH3_DST_MSW = 0xFFFF & (RxR1_DMA_address >> 16);
}
// add=(Uint16)RcvR_Sine;
// add = (add<<1) + 0x10000;
// DMA1_CH3_DST_LSW = (Uint16)add;
// DMA1_CH3_DST_MSW = 0xFFFF & (add >> 16);
DMA_IFR = 0x0080; // clear interrupt flags
// temp = DMA1_CH3_TC_MSW;
// temp |= 0x8000;
// DMA1_CH3_TC_MSW = temp;
}
}