完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在做CC2530烧录的时候需要用到如下函数:
void write_flash_memory_block(unsigned char *src, unsigned long start_addr, unsigned short num_bytes) [ u8 retry = 0; unsigned char len[2]; len[0] = HIBYTE(num_bytes); len[1] = LOBYTE(num_bytes); //log("write_flash_memory_blockn"); // 1. Write the 2 DMA descriptors to RAM write_xdata_memory_block(ADDR_DMA_DESC_0, dma_desc_0, 8); write_xdata_memory_block(ADDR_DMA_DESC_1, dma_desc_1, 8); // 2. Update LEN value in DUP's DMA descriptors write_xdata_memory_block((ADDR_DMA_DESC_0+4), len, 2); // LEN, DBG => ram write_xdata_memory_block((ADDR_DMA_DESC_1+4), len, 2); // LEN, ram => flash // 3. Set DMA controller pointer to the DMA descriptors write_xdata_memory(DUP_DMA0CFGH, HIBYTE(ADDR_DMA_DESC_0)); write_xdata_memory(DUP_DMA0CFGL, LOBYTE(ADDR_DMA_DESC_0)); write_xdata_memory(DUP_DMA1CFGH, HIBYTE(ADDR_DMA_DESC_1)); write_xdata_memory(DUP_DMA1CFGL, LOBYTE(ADDR_DMA_DESC_1)); // 4. Set Flash controller start address (wants 16MSb of 18 bit address) write_xdata_memory(DUP_FADDRH, HIBYTE( (start_addr>>2) )); write_xdata_memory(DUP_FADDRL, LOBYTE( (start_addr>>2) )); // 5. ARM DBG=>buffer DMA channel and start burst write write_xdata_memory(DUP_DMAARM, CH_DBG_TO_BUF0); burst_write_block(src, num_bytes); // 6. Start programming: buffer to flash write_xdata_memory(DUP_DMAARM, CH_BUF0_TO_FLASH); write_xdata_memory(DUP_FCTL, 0x06); // 7. Wait until flash controller is done while (read_xdata_memory(DUP_FCTL) & 0x80); ] 发现该函数只能烧录【0x0000 -- 0x7FFF】地址的内容,start_addr超过该范围后超出部分的内容烧录不进,不知道写到内部什么地方去了。 但是datasheet中描述 DUP_FADDR的地址是32位的,这里为什么只有15位有效? 如果我要烧录的文件大于32kB(地址超出0x7FFF),超出的部分要如何烧录? 有没有类似读falsh的函数: void read_flash_memory_block(unsigned char bank,unsigned short flash_addr, unsigned short num_bytes, unsigned char *values) [ unsigned char instr[3]; unsigned short i; unsigned short xdata_addr = (0x8000 + flash_addr); //log("read_flash_memory_blockn"); // 1. Map flash memory bank to XDATA address 0x8000-0xFFFF write_xdata_memory(DUP_MEMCTR, bank); // 2. Move data pointer to XDATA address (MOV DPTR, xdata_addr) instr[0] = 0x90; instr[1] = HIBYTE(xdata_addr); instr[2] = LOBYTE(xdata_addr); debug_command(CMD_DEBUG_INSTR_3B, instr, 3); for (i = 0; i < num_bytes; i++) [ // 3. Move value pointed to by DPTR to accumulator (MOVX A, @DPTR) instr[0] = 0xE0; values = debug_command(CMD_DEBUG_INSTR_1B, instr, 1); // 4. Increment data pointer (INC DPTR) instr[0] = 0xA3; debug_command(CMD_DEBUG_INSTR_1B, instr, 1); ] ] 可以指定内部bank来写? |
|
相关推荐
5 个讨论
|
|
只有小组成员才能发言,加入小组>>
334 浏览 1 评论
528 浏览 2 评论
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
773 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
649 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1126 浏览 1 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
55浏览 29评论
119浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
250浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
199浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
54浏览 13评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 16:53 , Processed in 1.085803 second(s), Total 49, Slave 43 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号