eeprom
Posted: Fri Sep 14, 2012 5:13 pm
hi,
i am doing course of programming embeded pic, I have problem to write eeprom with assembler.
I have passed course programm to pic and does not work.
unsigned char counter;
asm{
movlw 0 // the first memory location
movwf _counter
next:
movff _counter, _eeadr // counter as address and data
movff _counter, _eedata
bcf _eecon1,7 // set access data memory
bcf _eecon1,6 // set EEPROM
bsf _eecon1,2 // enable wren
clrf _intcon // stop interrupts (if any)
movlw 0x55 // mandatory sequence
movwf _eecon2
movlw 0xAA
movwf _eecon2
bsf _eecon1,1
bcf _eecon1,2 // clear wren
wait:
btfsc _eecon1,1 // wait for bit 1 is zero
goto wait
incfsz _counter,1 // increment and skip if zero
goto next
movlw 0b11111110 // b0 to output
movwf _trisb
bsf _portb,0 // light LED0
}
Result light is set but memory does not change. It is allways FF.
Any idea about how to solve it? I have passed this programm to C and memory change according program.
Thanks.
i am doing course of programming embeded pic, I have problem to write eeprom with assembler.
I have passed course programm to pic and does not work.
unsigned char counter;
asm{
movlw 0 // the first memory location
movwf _counter
next:
movff _counter, _eeadr // counter as address and data
movff _counter, _eedata
bcf _eecon1,7 // set access data memory
bcf _eecon1,6 // set EEPROM
bsf _eecon1,2 // enable wren
clrf _intcon // stop interrupts (if any)
movlw 0x55 // mandatory sequence
movwf _eecon2
movlw 0xAA
movwf _eecon2
bsf _eecon1,1
bcf _eecon1,2 // clear wren
wait:
btfsc _eecon1,1 // wait for bit 1 is zero
goto wait
incfsz _counter,1 // increment and skip if zero
goto next
movlw 0b11111110 // b0 to output
movwf _trisb
bsf _portb,0 // light LED0
}
Result light is set but memory does not change. It is allways FF.
Any idea about how to solve it? I have passed this programm to C and memory change according program.
Thanks.