Hello,
I am developing a program that at some point stores information in flash. After the information is stores any call to simpliciTI API results in my program hanging.
Any tip?
Here is part of my code:
Everything goes fine until here (I transmit and receive information with simpliciTI). I use CC1110mini DK. When I press the slave button it triggers a flash write.
#define PAGE_SIZE 1024
#define DATA_AMOUNT 16
char data[DATA_AMOUNT];
__no_init extern const char __code flashDataAddr[PAGE_SIZE] @ 0x7400;
static DMA_DESC dmaConfig0;
void halFlashStartErase(void);
void halFlashStartWrite(void);
if( BSP_BUTTON2() ){ // If SLAVE button pushed
data[2]=0x03; // Data to be stored in flash
data[3]=0x00;
//I write here
dmaConfig0.SRCADDRH = ((uint16)data >> 8) & 0x00FF;
dmaConfig0.SRCADDRL = (uint16)data & 0x00FF;
dmaConfig0.DESTADDRH = ((uint16)&X_FWDATA >> 8) & 0x00FF;
dmaConfig0.DESTADDRL = (uint16)&X_FWDATA & 0x00FF;
dmaConfig0.VLEN = DMA_VLEN_USE_LEN;
dmaConfig0.LENH = (DATA_AMOUNT >> 8) & 0x00FF;
dmaConfig0.LENL = DATA_AMOUNT & 0x00FF;
dmaConfig0.WORDSIZE = DMA_WORDSIZE_BYTE;
dmaConfig0.TMODE = DMA_TMODE_SINGLE;
dmaConfig0.TRIG = DMA_TRIG_FLASH;
dmaConfig0.SRCINC = DMA_SRCINC_1;
dmaConfig0.DESTINC = DMA_DESTINC_0;
dmaConfig0.IRQMASK = DMA_IRQMASK_DISABLE;
dmaConfig0.M8 = DMA_M8_USE_8_BITS;
dmaConfig0.PRIORITY = DMA_PRI_HIGH;
/* The DMA configuration data structure may reside at any location in
* unified memory space, and the address location is passed to the DMA
* through DMA0CFGH:DMA0CFGL.
*/
DMA0CFGH = ((uint16)&dmaConfig0 >> 8) & 0x00FF;
DMA0CFGL = (uint16)&dmaConfig0 & 0x00FF;
/* Waiting for the flash controller to be ready */
while (FCTL & FCTL_BUSY);
/* Configuring the flash controller. Setings:
* FWT: 0x11 (default setting, matches 13 MHz clock frequency).
* FADDRH:FADDRL: point to the area in flash to write to - flashDataAddr.
*/
FWT = 0x11;
FADDRH = (int)flashDataAddr >> 9;
FADDRL = ((int)flashDataAddr >> 1) & ~0xFF00;
/* Erase the page that will be written to. */
halFlashStartErase();
/* Wait for the erase operation to complete. */
while (FCTL & FCTL_BUSY);
/* Arm the DMA channel, so that a DMA trigger will initiate DMA writing. */
DMAARM |= DMAARM0;
/* Enable flash write. Generates a DMA trigger. Must be aligned on a 2-byte
* boundary and is therefor implemented in assembly.
*/
halFlashStartWrite();
/* Wait for DMA transfer to complete. */
while (!(DMAIRQ & DMAIRQ_DMAIF0));
/* Wait until flash controller not busy. */
while (FCTL & (FCTL_BUSY | FCTL_SWBSY));
/* By now, the transfer is completed, so the transfer count is reached.
* The DMA channel 0 interrupt flag is then set, so we clear it here.
*/
DMAIRQ &= ~DMAIRQ_DMAIF0;
//This call makes my device hang
SMPL_Send(sLinkID , radioMsg, sizeof(radioMsg));
Many thanks in advance,
Jorge