CC2530通过SmartRFFlashProgrammer下载后FLASH无法写入?通过IAR下载就可以了,为什么? 因为公司批量下载,不可能把源文件拿去用,用SmartRFFlashProgrammer下载后,通过按键修改FLASH内容不可,待解决,急!!!!
在这里调用的
HalFlashErase( SAVE_BASE_PAGE );
HalFlashWrite( SAVE_BASE_ADDR, write_flash_buffer, 6 );
其中参数:
#define SAVE_BASE_ADDR (0xfa00) //参数保存起始地址
uint8 write_flash_buffer[64];
主要就是这个函数,下载完修改FLASH不可以。。。。。
void HalFlashWrite(uint16 addr, uint8 *buf, uint16 cnt)
{
//HalDmaInit();
halDMADesc_t *ch = HAL_NV_DMA_GET_DESC();
HAL_DMA_SET_SOURCE(ch, buf);
HAL_DMA_SET_DEST(ch, &FWDATA);
HAL_DMA_SET_VLEN(ch, HAL_DMA_VLEN_USE_LEN);
HAL_DMA_SET_LEN(ch, (cnt * HAL_FLASH_WORD_SIZE));
HAL_DMA_SET_WORD_SIZE(ch, HAL_DMA_WORDSIZE_BYTE);
HAL_DMA_SET_TRIG_MODE(ch, HAL_DMA_TMODE_SINGLE);
HAL_DMA_SET_TRIG_SRC(ch, HAL_DMA_TRIG_FLASH);
HAL_DMA_SET_SRC_INC(ch, HAL_DMA_SRCINC_1);
HAL_DMA_SET_DST_INC(ch, HAL_DMA_DSTINC_0);
// The DMA is to be polled and shall not issue an IRQ upon completion.
HAL_DMA_SET_IRQ(ch, HAL_DMA_IRQMASK_DISABLE);
HAL_DMA_SET_M8( ch, HAL_DMA_M8_USE_8_BITS);
HAL_DMA_SET_PRIORITY(ch, HAL_DMA_PRI_HIGH);
HAL_DMA_CLEAR_IRQ(HAL_NV_DMA_CH);
HAL_DMA_ARM_CH(HAL_NV_DMA_CH);
FADDRL = (uint8)addr;
FADDRH = (uint8)(addr >> 8);
HalFlashWriteTrigger();
}
VV:
检查下是不是Flash被Lock了,看下Flash的lockbit
user4340224:
回复 VV:
问题解决了 再操作写FLASH的时候 有这么一个函数:
static __monitor void HalFlashWriteTrigger(void)
__monitor 不知道是什么意思 只要改成 static void HalFlashWriteTrigger(void)就可以了
这是为什么呢?
Dake Tan:
回复 user4340224:
The __monitor keyword causes interrupts to be disabled during execution of the function. This allows atomic operations to be performed, such as operations on semaphores that control access to resources by multiple processes. A function declared with the __monitor keyword is equivalent to any other function in all other respects.Avoid using the __monitor keyword on large functions since the interrupt will otherwise be turned off for too long.