程序没有加入iap前,各项功能都很正常,加入iap写flash后iap功能正常,但串口就不能正常执行. 具体表现:在串口的通讯数据出错,好象频率错误,把pll去掉后也不对.
请指教!
uint8 iap(uint32 dst, uint32 src, uint32 no, uint8 sec1, uint8 sec2) { MAMCR = 0; // 关闭MAM // PLLCON = 0; // 关闭PLL // PLLFEED = 0xaa; // PLLFEED = 0x55;
if(ReadParID() !=0){ return FALSE; } if(BootCodeID() != 0){ return FALSE; } if(SelSector(sec1, sec2) != 0){ // 选择扇区 return FALSE; } if(EraseSector(sec1, sec2) != 0){ // 擦除扇区 return FALSE; } if(BlankCHK(sec1, sec2) != 0){ // 查空扇区 return FALSE; } if(SelSector(sec1, sec2) != 0){ return FALSE; } if(RamToFlash(dst, src, no) != 0){ return FALSE; } if(BlankCHK(sec1, sec2) == 0){ return FALSE; } if(Compare(dst, src, no) != 0){ // 比较数据 return FALSE; }
return TRUE; }
uint8 iapTask(uint32 dst, uint32 src, uint32 no, uint8 sec1, uint8 sec2) { uint32 temp1; //防止狗复位,喂数 //关中断 temp1 =VICIntEnable; VICIntEnClr =temp1;
if (iap(dst, src, no, sec1, sec2)==0){
VICIntEnable =temp1;
/* PLLCON = 1; // 使能PLL PLLFEED = 0xaa; PLLFEED = 0x55; while((PLLSTAT & (1 << 10)) == 0); //判断pll锁定 PLLCON = 3; PLLFEED = 0xaa; PLLFEED = 0x55; */ return FALSE; }
VICIntEnable =temp1;
/* PLLCON = 1; // 使能PLL PLLFEED = 0xaa; PLLFEED = 0x55; while((PLLSTAT & (1 << 10)) == 0); //判断pll锁定 PLLCON = 3; PLLFEED = 0xaa; PLLFEED = 0x55; */
return TRUE; }
|