PIC18F248

Michal Krestan krestan@hw.cz
Sobota Duben 16 00:23:46 CEST 2005



Nejak se tu snazim rozchodit EEPROMku u PIC18F248 a nedari se mi do ni 
zapisovat:-( Pro zapis a cteni pouzivam nasledujici:

unsigned char readbyte(unsigned char adr)
{
EEADR=adr;
EECON1bits.EEPGD=0;
EECON1bits.CFGS=0;
EECON1bits.RD=1;
return EEDATA;
}

void writebyte(unsigned char adr, unsigned char dt)
{
tryagain:
PIR2bits.EEIF=0;
INTCONbits.GIE=0;
EEADR=adr;
EEDATA=dt;
EECON1=0;
EECON1bits.WREN=1;

_asm
 movlw 0x55
 movwf EECON2, ACCESS
 movlw 0xAA
 movwf EECON2, ACCESS
 bsf  EECON1, 1, ACCESS
 nop
 _xx:
 btfsc EECON1, 1, ACCESS
 bra  _xx
_endasm
PIR2bits.EEIF=0;
if (readbyte(adr)!=dt) goto tryagain;
}

At s tim delam cokoliv, tak proste zapis neprobehne:-( Write protect bit mam 
nastaven spravne. Poradi mi nekdo?

        Michal




Další informace o konferenci Hw-list