Hello all.
I use CC2510F32 and I need write some configuration data to flash memory.
For this I use the next code:
__no_init volatile struct
{
addr_t F_Addr;
uint8_t F_Num_group[NUM_OF_GROUP];
} F_Data @ 0x7C00;
//reserving space in flash memory
....................
static uint8_t Write_addr_to_Flash (addr_t* addr)
{
/* DMA configuration descriptor used for memory copy. */
static DMA_DESC dmaConfig0;
BSP_DISABLE_INTERRUPTS();
dmaConfig0.SRCADDRH = ((uint16)(addr) >> 8) & 0x00FF;
dmaConfig0.SRCADDRL = (uint16)(addr) & 0x00FF;
dmaConfig0.DESTADDRH = ((uint16)FWDATA >> 8) & 0x00FF;
dmaConfig0.DESTADDRL = (uint16)FWDATA & 0x00FF;
dmaConfig0.VLEN = DMA_VLEN_USE_LEN;
dmaConfig0.LENH = (NET_ADDR_SIZE >> 8) & 0x00FF;
dmaConfig0.LENL = NET_ADDR_SIZE & 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;
FADDRH = ((((uint16)(&F_Data))>>1)>>8) & 0x00FF;
FADDRL = (((uint16)(&F_Data))>>1) & 0x00FF;
/* 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;
/* Arm the DMA channel, so that a DMA trigger can initiate DMA writing,
and apply 45 NOP’s to allow the DMA arming to actually take effect. */
DMAARM |= DMAARM0;
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");
/* Trigger the DMA channel by setting FCTL.WRITE */
FCTL |= FCTL_WRITE;
/* Wait for the DMA transfer to complete. */
while ( !(DMAIRQ & DMAIRQ_DMAIF0) );
/* 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;
return 0;
}
When it execute FCTL |= FCTL_WRITE; it hang.
I've also tried another way to write data into flash:
__no_init volatile struct
{
addr_t F_Addr;
uint8_t F_Num_group[NUM_OF_GROUP];
} F_Data @ 0x7C00;
//reserving space in flash memory
....................
static uint8_t Write_addr_to_Flash (addr_t* addr)
{
BSP_DISABLE_INTERRUPTS();
while (FCTL&FCTL_BUSY);
FADDRH = ((((uint16)(&F_Data))>>1)>>8) & 0x00FF;
FADDRL = (((uint16)(&F_Data))>>1) & 0x00FF;
FCTL |= FCTL_WRITE;
FWDATA=(*addr).addr[0];
FWDATA=(*addr).addr[1];
while (FCTL&FCTL_SWBSY);
BSP_ENABLE_INTERRUPTS();
return 0;
}
But it doesn't do anything. It executes all commands, but doesn't write anything in flash memory.