Hi all,
I am writing a program for CC2530 to get analog data using ADC sequentila conversion every 1 ms and using DMA to transfer it to memory. I am keep getting " warning: stack overflow....." Here is the code I am using. I would appreciate it if any one could help me.
Thanks in advance,
// Application parameters#define RF_CHANNEL 26 // 2.4 GHz RF channel
// BasicRF address definitions#define APP_PAYLOAD_LENGTH 100#define PAN_ID 0x2010#define LOCAL_ADDR 0xdead#define DEST_ADDR 0xbeef/************************************************************************************ LOCAL VARIABLES***********************************************************************************/static uint8 pTxData[APP_PAYLOAD_LENGTH];static basicRfCfg_t basicRfConfig;static uint8 dma_conf [8]; //DMA configuration data structure
void main(void){ uint16 seq_no = 1; // Initalize board peripherals halBoardInit();
// initialize the RF basicRfConfig.panId = PAN_ID; basicRfConfig.channel = RF_CHANNEL; basicRfConfig.myAddr = LOCAL_ADDR; basicRfConfig.ackRequest = TRUE;
if(basicRfInit(&basicRfConfig)==FAILED) { HAL_ASSERT(FALSE); }
basicRfReceiveOn();
// set maximum TX power, 4dBm halRfSetTxPower(0xF5); /* DMA initial configuration *****************************/ //We use DMA channel 0 and sends the address of data structure to the channel 0 DMA0CFGH = (uint8)(((uint16)dma_conf & 0xFF00) >> 8); DMA0CFGL = (uint8)((uint16)dma_conf & 0xFF); //Source address dma_conf[0] = (uint8)((uint16)(&X_ADCL)>> 8); dma_conf[1] = (uint8)((uint16)(&X_ADCL)); //Destination Address packet index #4 dma_conf[2] = (uint8)((uint16)(&pTxData[4]) >> 8); // Detination address high dma_conf[3] = (uint8)((uint16)(&pTxData[4])); // Destination Address low // VLEN disabled dma_conf[4] = 0; // LEN is set to the maximum transfer of 48 dma_conf[5] = 48; //16-bit word size - TMODE: Single - trigger source # 20 - dma_conf[6] = 0; dma_conf[6] |= BIT7 |0x14; // SRC address No icr - DST Address +1 word - DMA channel interupt Enabled - High priority - dma_conf[7] = 0x1A; //Enable DMA interrupt DMAIE = 1; //Clear general DMA interrupt flag- ARM DMA DMAARM = 1;
// Indicate that device is ready halLedSet(1); APCFG |= BIT0 | BIT1 | BIT7 ;
ADCCON1 = 0x2F
ADCCON2 = 0x71;// Controls how the sequence of conversions is performed- //sets ADCCON2.SCH to end at channel 1 (AIN1 single-ended input), ADCCON2.SDIV to use 12 bit resolution, and //ADCCON2.SREF to use AIN7 single-ended reference voltage /******************************************************************************************************************* CLOCK SOURCE IS BY DEFAULT 16MHz RCOSC - WE USE TIMER TICK SPPED OF 1MHz IN ORTHER TO GET .001ms TIMER SPEED TIMER1 CHANNEL 0 IS USED IN COMPARE AND MODULO MODE WITH COUNTER OF 1000 TO GET 1ms ADC SENSING TIME (1000*.001)*******************************************************************************************************************/ //TIMER TICK SPEED CLKCONCMD = 0x69; /********************************************** Timer 1 channel 0 configuration***********************************************/ //TIMER 1 CHANNEL0 COMPARE MODE - INTERRUPT DISALBLED T1CCTL0 = 0x04; //COMPARE VALUE TO COUNT 0-999 INCLUSIVELY T1CC0H = 0x03; T1CC0L = 0xEF; T1IE = 0; //interrupt disabled TIMIF = 0; //Timer 1 overflow interrupt mask disabled T1STAT = 0; //T1STAT.CH0IF = 0, clear channel 0 interrupt //NO PRESCALER, MODULO MODE T1CTL = 0x02; while(1) { pTxData[0] = 0xFF; // Indicate packet start pTxData[1] = 0xFF; pTxData[2] = (seq_no & 0xFF00) >> 8; pTxData[3] = (seq_no & 0x00FF); while(DMAIRQ != 1); //Clear general DMA interrupt flag- ARM DMA DMAARM = 1; while(basicRfSendPacket(0xbeef, pTxData, APP_PAYLOAD_LENGTH) == FAILED); seq_no++; halLedToggle(1); } }
void basicRfProcessPacket(void) {}