Jump to content

tibe

Members
  • Content Count

    2
  • Joined

  • Last visited

    Never

Everything posted by tibe

  1. software mplab 5.30 with c2c puls compiler 3.28.03e // write/read eeprom data for PIC 16F876 #pragma CLOCK_FREQ 4000000 asm __config 0x3D39 Write_eeprom(char addrw,char dataw) { set_bit(STATUS, RP0); set_tris_a(0); clear_bit(STATUS, RP0); //Write eeprom set_bit( STATUS, RP1 ); clear_bit( STATUS, RP0 ); EEADR = addrw; EEDATA = dataw; set_bit( STATUS, RP0 ); clear_bit( EECON1, EEPGD ); set_bit( EECON1, WREN ); EECON2 = 0x55; EECON2 = 0xAA; set_bit( EECON1, WR ); // while(EECON1); nop(); nop(); nop(); nop(); clear_bit( EECON1, WREN ); clear_bit( STATUS, RP0 ); delay_ms(100); //return 0; clear_bit( STATUS, RP1 ); } main() { char dat1; set_bit(STATUS, RP0); set_tris_b(255); set_tris_c(128); //asm movlw 07h //asm movwf ADCON1 clear_bit(STATUS, RP0); output_port_b(0); output_port_c(0); delay_ms(100); Write_eeprom(0,3); delay_ms(100); //read from eeprom set_bit(STATUS, RP1); clear_bit(STATUS, RP0); EEADR = 0x00; set_bit(STATUS, RP0); clear_bit(EECON1, EEPGD); set_bit(EECON1, RD); delay_ms(100); clear_bit(STATUS, RP0); dat1 = EEDATA; delay_ms(100); //write to eeprom data Write_eeprom(2,dat1); Write_eeprom(3,5); while(1); } output eeprom data: address 00h = 03 address 02h = 00 address 03h = 05 the address 02H must be = 03. Why is it = 00 ??? Where is the error ?
  2. I would some rutine for write/read to eeprom of 16F876 with C2C plus compiler v.3.28. Thanks.
×
×
  • Create New...