完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我目前正在编写一个微型SD卡启动加载器为这个设备,我已经找到了很多信息写在Flash,但似乎没有什么工作,这里有一些事情我已经尝试。我使用分区分区1中的引导加载程序和分区2中的主代码,在双分区模式下工作。现在如果我用双统一的HEX文件编程,并且在板上没有SD卡,它跳过并跳转到第二分区,没有问题,如果它加载了SD卡,则打印CONT。文件的内容,因为它显然是写到内存,但它不跳正确,并重置环。首先,我试图擦除内存的上半部分。然后我尝试写在一个循环使用这些功能之一,没有错误被检测为NoTeliPPIC30.H.但数据表。说无论我尝试什么都不为这部分工作,非常感谢任何帮助。
以上来自于百度翻译 以下为原文 Hi I am currently writing a micro sdcard boot loader for this device, I have found a lot of info on writing to the flash but nothing seems to work here's a few things I have tried. I am working in dual partition mode with the bootloader in the partition 1 and the main code in partition 2. Now if I program with a dual unified hex file and have no sdCard in the board it skips and jumps to the second partition with no problem, and if it has the sdcard in it loads, prints the contents of the file as it apparently is writing to the memory, but then it does not jump correctly and resets the loop. firstly I try to erase the top half of memory in its entirety. void EraseFlashBlock(unsigned long progAddr) { // Erase 1024 instructions (8 rows, 3072 bytes) //Set up pointer to the first memory location to be written NVMADRH = progAddr >> 16; // Initialise PM Page Boundary SFR NVMADRL = progAddr & 0xFFFF; // Initialise lower word of address NVMCON = 0x4003; // Initialise NVMCON // } __builtin_disi(5); // Block interrupts with priority <7 for next 5 instructions __builtin_write_NVM(); // check function to perform unlock sequence and set WR while (NVMCONbits.WR) { }; if(NVMCONbits.WRERR){ ASSERT(0,"rnWRERR "); } } void EraseMainProgram(void) { unsigned long addr = 0x400000; unsigned long i; ASSERT(0,"rn Erasing memory"); for(i=0; i<344; i++){ EraseFlashBlock(addr); addr+=1024; } } then I try to write in a loop using one of these functions, no errors are detected as a note libpic30.h #define _FLASH_ERASE_CODE 0x4042 #define _FLASH_WRITE_ROW_CODE 0x4001 #define _FLASH_WRITE_WORD_CODE 0x4003 but the data sheet says that it is #define _FLASH_ERASE_CODE 0x4001 #define _FLASH_WRITE_ROW_CODE 0x4002 #define _FLASH_WRITE_WORD_CODE 0x4003 void write_flash_word24(void) { unsigned int offset; NVMCON = _FLASH_WRITE_WORD_CODE;//0x4001;// offset = (writeAddressL);// & 0xFFFE); TBLPAG = writeAddressH; __builtin_tblwtl(offset, writeDataL); __builtin_tblwth(offset, writeDataH); asm("DISI #16"); __builtin_write_NVM(); while (NVMCONbits.WR) { }; if(NVMCONbits.WRERR){ ASSERT(0,"rnWRERR "); } } void write_flash_doubleWord(void) { unsigned int offset; NVMCON = 0x4001; TBLPAG = 0xFA; NVMADRU = writeAddressH; NVMADR = writeAddressL; offset = (writeAddressL & 0xFFFE); TBLPAG = writeAddressH; __builtin_tblwtl(0, writeDataL); __builtin_tblwth(0, writeDataH); __builtin_tblwtl(1, writeDataL2); __builtin_tblwth(1, writeDataH2); __builtin_disi(10); __builtin_write_NVM(); while (NVMCONbits.WR) { }; if(NVMCONbits.WRERR){ ASSERT(0,"rnWRERR "); } } however whatever I try nothing works for this part, many thanks for any help |
|
相关推荐
4个回答
|
|
|
|
|
|
好的,现在我有了一些进步,我现在可以读取和擦除内存,但仍然写不起作用,我认为可能有一个bug /问题,编译器如何解释UIT32和UTIN 32类型的定义,因为如果我使用UIT32的内存地址地址,WOR的上半部分。没有人知道为什么写的双字不工作,我已经从数据表复制了代码,所有的配置词都是根据我所看到的正确设置的。哦,我认为数据表中有一个错误,在那里它读取:-我的配置和函数:
以上来自于百度翻译 以下为原文 Ok, so I'm now making a bit of progress, I can now read and erase memory but still the write does not seem to work, and I think there may be a BUG / issue with how the compiler interprets uint32 and uint32_t type defines because if I use uint32_t for memory location addresses the top half of the word is missing. Does anyone have any idea why the write double word does not work I have copied the code from the datasheet, all the config words are set correctly as far as I can see. Oh and I think there is an error in the datasheet where it reads :- __builtin_tblwtl(0, progData1L); __builtin_tblwth(0, progData2H); // Error here __builtin_tblwtl(1, progData2L); __builtin_tblwth(1, progData2H); My config and functions :- // FSEC #pragma config BWRP = OFF // Boot Segment Write-Protect bit->Boot Segment may be written #pragma config BSS = DISABLED // Boot Segment Code-Protect Level bits->No Protection (other than BWRP) #pragma config BSEN = OFF // Boot Segment Control bit->No Boot Segment #pragma config GWRP = OFF // General Segment Write-Protect bit->General Segment may be written #pragma config GSS = DISABLED // General Segment Code-Protect Level bits->No Protection (other than GWRP) #pragma config CWRP = OFF // Configuration Segment Write-Protect bit->Configuration Segment may be written #pragma config CSS = DISABLED // Configuration Segment Code-Protect Level bits->No Protection (other than CWRP) #pragma config AIVTDIS = OFF // Alternate Interrupt Vector Table bit->Disabled AIVT // FOSCSEL #pragma config FNOSC = FRCPLL // Oscillator Source Selection->Fast RC Oscillator with divide-by-N with PLL module (FRCPLL) #pragma config PLLMODE = PLL96DIV2 // PLL Mode Selection->96 MHz PLL. (8 MHz input) #pragma config IESO = OFF // Two-speed Oscillator Start-up Enable bit->Start up with user-selected oscillator source // FOSC #pragma config POSCMD = NONE // Primary Oscillator Mode Select bits->Primary Oscillator disabled #pragma config OSCIOFCN = ON // OSC2 Pin Function bit->OSC2 is general purpose digital I/O pin #pragma config SOSCSEL = OFF // SOSC Power Selection Configuration bits->Digital (SCLKI) mode #pragma config PLLSS = PLL_FRC // PLL Secondary Selection Configuration bit->PLL is fed by the on-chip Fast RC (FRC) oscillator #pragma config IOL1WAY = ON // Peripheral pin select configuration bit->Allow only one reconfiguration #pragma config FCKSM = CSDCMD // Clock Switching Mode bits->Both Clock switching and Fail-safe Clock Monitor are disabled // FWDT #pragma config WDTPS = PS256 // Watchdog Timer Postscaler bits->1:256 #pragma config FWPSA = PR128 // Watchdog Timer Prescaler bit->1:128 #pragma config FWDTEN = OFF // Watchdog Timer Enable bits->WDT and SWDTEN disabled #pragma config WINDIS = OFF // Watchdog Timer Window Enable bit->Watchdog Timer in Non-Window mode #pragma config WDTWIN = WIN25 // Watchdog Timer Window Select bits->WDT Window is 25% of WDT period #pragma config WDTCMX = WDTCLK // WDT MUX Source Select bits->WDT clock source is determined by the WDTCLK Configuration bits #pragma config WDTCLK = LPRC // WDT Clock Source Select bits->WDT uses LPRC // FPOR #pragma config BOREN = ON // Brown Out Enable bit->Brown Out Enable Bit #pragma config LPCFG = OFF // Low power regulator control->No Retention Sleep #pragma config DNVPEN = ENABLE // Downside Voltage Protection Enable bit->Downside protection enabled using ZPBOR when BOR is inactive // FICD #pragma config ICS = PGD2 // ICD Communication Channel Select bits->Communicate on PGEC2 and PGED2 #pragma config JTAGEN = OFF // JTAG Enable bit->JTAG is disabled //#pragma config BTSWP = OFF // BOOTSWP Disable->BOOTSWP instruction disabled #pragma config BTSWP = ON // FDEVOPT1 #pragma config ALTCMPI = DISABLE // Alternate Comparator Input Enable bit->C1INC, C2INC, and C3INC are on their standard pin locations #pragma config TMPRPIN = OFF // Tamper Pin Enable bit->TMPRN pin function is disabled #pragma config SOSCHP = ON // SOSC High Power Enable bit (valid only when SOSCSEL = 1->Enable SOSC high power mode (default) #pragma config ALTVREF = ALTREFEN // Alternate Voltage Reference Location Enable bit->VREF+ and CVREF+ on RA10, VREF- and CVREF- on RA9 // FBOOT #pragma config BTMODE = DUAL // Boot Mode Configuration bits->Device is in Single Boot (legacy) mode void PROG_Erase(void) { uint32 address = 0x400000; uint32 offset; NVMADRU = address>>16; NVMADR = address & 0xFFFFFF; NVMCON = 0x4003; // Perform Erase of a Full Page (8 rows) asm volatile ("disi #5"); // Issue Unlock Sequence & Start Write Cycle __builtin_write_NVM(); while(NVMCONbits.WR) ; } void PROG_WriteDouble(uint32 address, uint32 data1, uint32 data2) { TBLPAG = 0xFA; __builtin_tblwtl(0, (data1 & 0xFFFF)); __builtin_tblwth(0, (data1 >> 16)); __builtin_tblwtl(1, (data2 & 0xFFFF)); __builtin_tblwth(1, (data2 >> 16)); NVMADRU = address>>16; NVMADR = address & 0xFFFF; NVMCON = 0x4001; // Perform Write of 2 words // Disable Interrupts For 5 Instructions asm volatile ("disi #5"); // Issue Unlock Sequence & Start Write Cycle __builtin_write_NVM(); while(NVMCONbits.WR) ; void putHexLong(unsigned long i) { putHex((unsigned char)(i>>24)); putHex((unsigned char)(i>>16)); putHex((unsigned char)(i>>8)); putHex((unsigned char)(i&0xFF)); } } |
|
|
|
|
|
|
|
这对我(写作,GB6系列)基于…MLAIV2017Y03Y06AppsUSB设备BooTouls固件PIC24YDSPICExp16PIC24FJ1024GB610XPIM .xAppHythBooToLoad .C
以上来自于百度翻译 以下为原文 This works for me (writing, GB6 family) TBLPAG = 0xFA; __builtin_tblwtl(0, (data1 & 0xFFFF)); __builtin_tblwth(1, (data1 >> 16)); __builtin_tblwtl(2, (data2 & 0xFFFF)); __builtin_tblwth(3, (data2 >> 16)); ... asm("DISI #16"); ... based on ... mla_v2017_03_06appsu***devicebootloadersfirmwarepic24_dspicexp16_pic24fj1024gb610_pim.xapp_hid_boot_loader.c |
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2027 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3202 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
772浏览 1评论
663浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
590浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
672浏览 0评论
572浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 15:45 , Processed in 1.297884 second(s), Total 85, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号