User manual
346
mikoC PRO for dsPIC
MikroElektronika
ADPCFG = 0xFFFF; // Disable analog inputs
TRISB = 0; // PORTB as output
LATB = 0xFFFF;
eeAddr = 0x7FFC00; // Start address of EEPROM
eeData = 0; // Data to be written
while (eeData <= 0x00FF) {
EEPROM_Write(eeAddr, eeData++); // Write data into EEPROM
while(WR_bit); // Wait for write to nish,
LATB = EEPROM_Read(eeAddr); // then, read the just-written
// data.
eeAddr += 2; // Next address of EEPROM memory location
Delay_ms(30);
}
Delay_ms(1000); // Wait 1 second.
eeData = 0xAAAA;
for (i=0; i<16; i++){ // Initializing array of 16 integers with data
dArr[i] = eeData;
eeData = ~eeData;
}
EEPROM_Write_Block(0x7FFC20, dArr); // Write entire row of EEPROM data
while(WR_bit)
; // Wait for write to nish
eeAddr = 0x7FFC20; // Address of EEPROM where reading should start
for (i=0; i<16; i++){ // Read the data back
LATB = EEPROM_Read(eeAddr); // and show it on PORTB
eeAddr += 2; // Next address of EEPROM memory location
Delay_ms(500);
}
}