ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Суббота
27 апреля
89843 Топик полностью
abivan (21.05.2007 17:30, просмотров: 1) ответил koden на PIC18F66J15 компилятор хайтек 9.50 PL3 Раньше программил контроллер 18F4520 - у него флеши поменьше. Стандартные функции хайтека записи во флеш работали без проблем. А с этим контроллером не хотят.
А никак не боролся, свои написал 8722 <c> void EE_WriteMemBlock(){ BYTE index; DWORD dwAddr; dwAddr=(DWORD)wMemBlockNumb*MAX_MEMBLOCK_SIZE; // Erase flash sector before writing TBLPTRL=LOBYTE(LSBWORD(dwAddr)); TBLPTRH=HIBYTE(LSBWORD(dwAddr)); TBLPTRU=LOBYTE(MSBWORD(dwAddr)); EECON1=0x94; InitiateWrite(); // now begin to copy the buffer to the destination area for(index=0;index<64;index++){ TABLAT=MemBlockBuff[index]; // copy the data buffer to the if(index==0) asm("\tTBLWT*"); // load the 8 internal write registers else asm("\tTBLWT+*"); if((index & 7)==7){ // after every 8th byte, the // the write buffer is written to flash. InitiateWrite(); } } TBLPTRU=0; } static void InitiateWrite(void){ EEPGD=1; WREN=1; // this is the required sequence CARRY=0;if(GIE)CARRY=1;GIE=0; DC=0;if(PEIE)DC=1;PEIE=0; EECON2=0x55; EECON2=0xAA; WR=1; asm("\tNOP"); if(CARRY)GIE=1; if(DC)PEIE=1; WREN=0; } </c>