Jump to content

Rodrigo Valladares P

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Rodrigo Valladares P

  • Rank
    Newbrie

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Location
    Santiago, Chile
  • Interests
    4x4, Electronics and Electronics applied to 4x4
  1. hi, (my first post, hope not posted before ) i need to write eeprom to a 16f648a, apparently there is not a specific routine for that device, so i translate and adapt some found in the web. the datasheet is easy to translate to a c + asm mix, but i'm not shure about the bank selection done in assembler or c, the compiler take care about this and correct it after routine exit?, or what is the better form of doing that?, or any 16f648 specific write/read eeprom code to implement? thanks my adaptation, i can't remember from where i borrowed void write_flash( unsigned char addr, unsigned char data ) { unsigned char aux; //Write flash eeadr = addr; eedata = data; set_bit( status, RP0 ); set_bit( eecon1, WREN ); asm { lp_disint: bcf _intcon, GIE btfsc _intcon, GIE goto lp_disint }; eecon2 = 0x55; eecon2 = 0xAA; set_bit( eecon1, WR ); while(eecon1.WR) ; clear_bit( eecon1, WREN ); clear_bit( status, RP0 ); delay_us(15); aux = read_flash(addr); if (aux != data) { lcd_clear_display(); lcd_char('x'); lcd_3_digit(addr); lcd_char(' '); lcd_char('>'); lcd_3_digit(data); // lo original lcd_char(' '); lcd_char('<'); lcd_3_digit(aux); // lo leido for(;;); } } unsigned char read_flash( unsigned char addr ) { unsigned char aux; set_bit( status, RP0 ); //Read flash eeadr = addr; set_bit( eecon1, RD ); aux = eedata; clear_bit( status, RP0 ); return aux; // asm movf _eedata, W }
×
×
  • Create New...