User manual
322
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
main:
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
Inc(eeData)
while (WR_bit) ‘ Wait for write to nish,
nop
wend
LATB = Eeprom_Read(eeAddr) ‘ then, read the just-written data.
eeAddr = eeAddr + 2 ‘ Next address of EEPROM memory location
Delay_ms(100)
wend
Delay_ms(1000) ‘ Wait 1 second.
eeData = 0xAAAA
for i = 0 to 1 ‘ Initializing array of 16 integers with data
dArr[i] = eeData
eeData = not eeData
next i
Eeprom_Write_Block(0x7FFC20, dArr) ‘ Write entire row of EEPROM data
while(WR_bit) ‘ Wait for write to nish
nop
wend
eeAddr = 0x7FFC20 ‘ Address of EEPROM where reading should start
for i = 0 to 15 ‘ Read the data back
LATB = Eeprom_Read(eeAddr) ‘ and show it on PORTB
eeAddr = eeAddr + 2 ‘ Next address of EEPROM memory location
Delay_ms(500)
next i
end.