Hello,
I am having trouble getting the DMA channel 0 example to correctly work.
I am using the Keil uVision5 IDE which has required me to rewrite the DMA_DESC table to reverse the order of the bits to MSB to LSB. I followed an example posted elsewhere. I can not use the #pragma bitfields = reversed directive with Keil.
Here is the result of this change.
typedef struct {
BYTE SRCADDRH;
BYTE SRCADDRL;
BYTE DESTADDRH;
BYTE DESTADDRL;
BYTE LENH : 5;
BYTE VLEN : 3;
BYTE LENL : 8;
BYTE TRIG : 5;
BYTE TMODE : 2;
BYTE WORDSIZE : 1;
BYTE PRIORITY : 2;
BYTE M8 : 1;
BYTE IRQMASK : 1;
BYTE DESTINC : 2;
BYTE SRCINC : 2;
} DMA_DESC;
When i load the bytes into the structure, I do it in the same order as listed below,
SET_WORD(dmaConfigTX.SRCADDRH, dmaConfigTX.SRCADDRL, txBuffer);
SET_WORD(dmaConfigTX.DESTADDRH, dmaConfigTX.DESTADDRL, &X_RFD);
dmaConfigTX.VLEN = DMA_VLEN_FIRST_BYTE_P_1;
SET_WORD(dmaConfigTX.LENH, dmaConfigTX.LENL, N+1);
dmaConfigTX.WORDSIZE = DMA_WORDSIZE_BYTE;
dmaConfigTX.TRIG = DMA_TRIG_RADIO;
dmaConfigTX.TMODE = DMA_TMODE_SINGLE;
dmaConfigTX.SRCINC = DMA_SRCINC_1;
dmaConfigTX.DESTINC = DMA_DESTINC_0;
dmaConfigTX.IRQMASK = DMA_IRQMASK_DISABLE;
dmaConfigTX.M8 = DMA_M8_USE_8_BITS;
dmaConfigTX.PRIORITY = DMA_PRI_HIGH;
SET_WORD(DMA0CFGH, DMA0CFGL, &dmaConfigTX);
When I go into debug mode of the Keil uVision5 IDE I can see the XDATA registers filled with values below:
X Memory 0x000000 = 00
0x000001 = 08
0x000002 = DF
0x000003 = D9
0x000004 = 20
0x000005 = 0B
0x000006 = 13
0x000007 = 42
This is Setting the PKTLEN = 10 which then begins writing to the 0x000008 XDATA memory with the PKTLEN and the txBuffer values after the 0x000007.
I do not see any values change for the DMA0CFGH or DMA0CFGL register values in Data of XData memory address 0xD4, 0xD5 or 0xDFD4 and 0xDFD5.
UINT16 i;
initpins(); // Function that returns 0000 0110 Make Pin P1_1 and P1_2 Output pins.
radioreg(); // Function that returns all the radio register values;
clkc(); // Function that sets the high speed crystal and turns off the RC crystal.
PKTLEN = N;
SET_WORD(dmaConfigTX.SRCADDRH, dmaConfigTX.SRCADDRL, txBuffer);
SET_WORD(dmaConfigTX.DESTADDRH, dmaConfigTX.DESTADDRL, &X_RFD);
dmaConfigTX.VLEN = DMA_VLEN_FIRST_BYTE_P_1;
SET_WORD(dmaConfigTX.LENH, dmaConfigTX.LENL, N+1);
dmaConfigTX.WORDSIZE = DMA_WORDSIZE_BYTE;
dmaConfigTX.TRIG = DMA_TRIG_RADIO;
dmaConfigTX.TMODE = DMA_TMODE_SINGLE;
dmaConfigTX.SRCINC = DMA_SRCINC_1;
dmaConfigTX.DESTINC = DMA_DESTINC_0;
dmaConfigTX.IRQMASK = DMA_IRQMASK_DISABLE;
dmaConfigTX.M8 = DMA_M8_USE_8_BITS;
dmaConfigTX.PRIORITY = DMA_PRI_HIGH;
SET_WORD(DMA0CFGH, DMA0CFGL, &dmaConfigTX);
tempd(); //Function which returns temp values from a sensor
// 1. Clear interrupt flags
// For pulsed or edge shaped interrupt sources one should clear the CPU
// interrupt flag prior to clearing the module interrupt flag
S1CON &= ~RFIF_1_0;
RFIF &= ~IRQ_DONE;
// 2. Set individual interrupt enable bit in the peripherals SFR, if any
RFIM = IM_DONE;
// 3. Set the corresponding individual, interrupt enable bit in the IEN0,
// IEN1, or IEN2 registers to 1
HAL_INT_ENABLE(INUM_RF, INT_ON);
// 4. Enable global interrupt
INT_GLOBAL_ENABLE(INT_ON);
while (TRUE) {
txBuffer[0] = N;
for (i = 1; i <=N; i++){
txBuffer[i] = i;}
P1_1 = 1;
DMAARM = DMAARM_CHANNEL0;
RFST = 0x03;
//while(!packetSent); The board will hang here is i do not comment it out because the ISR below is never reached
//packetSent= FALSE;
BDelay(50);
}
}
//The following ISR function is never called using any of the Interrupt values associated with the radio or dma (i.e. 0, 8, and 16) in order to make the packetSent flag go be changed. This is the syntax required by the Keil uVision IDE for ISR functions.
void RFINT(void) interrupt 8 {
P1_1=0;
S1CON &= ~0x03;
RFIF &= ~0x10;
packetSent = TRUE;
P1_1=0;
}
I can get the radio to work doing a fixed PKTLEN configuration and sending a single byte. This is without setting up the DMA. However, when I try to do variable PKTLEN configuration and the DMA setup I cannot get the radio to transmit. It loops but it does not transmit. (as long as the while (!packetSent) is commented out)
INterestingly, when trying to do the DMA example and variable PKTLEN and if I do go to the RF Studio and change the Sync Word to No Preamble I get a stream of bytes and when I turn on the radio I get many bytes of aa or 55 and when i turn off the radio the stream of received bytes is random. So my radio is transmitting something just not the txBuffer i should be. These packets are also tallied as "Recieved not ok". But the 55 and aa stream is associated with my radio on and me switching it off.
So long story short I am stuck. Is my DMA configuration not working with changing the table structure of DMA_DESC or am I not enabling an interrupt? The DMA example provided by TI is said to work. The only thing I have really had to change is this table, so does anyone know what the register values should read if the MSB to LSB is followed?