arunbharathi.arasu
Full Member level 2
- Joined
- Feb 28, 2013
- Messages
- 134
- Helped
- 7
- Reputation
- 14
- Reaction score
- 6
- Trophy points
- 1,298
- Location
- Chennai, Tamil Nadu, India
- Activity points
- 2,151
Dear all,
Im using PIC18F4550, im writing some data to EEPROM.
Then read form the eeprom and write in to another memory.(Just Check)
i could not find any error in my code .
Please give me some suggestion. in proteus i'm seasoning EEPROM data.
Here is the code.
Im using PIC18F4550, im writing some data to EEPROM.
Then read form the eeprom and write in to another memory.(Just Check)
i could not find any error in my code .
Please give me some suggestion. in proteus i'm seasoning EEPROM data.
Here is the code.
Code:
// PIC18F4550 Configuration Bit Settings
// 'C' source line config statements
#include <htc.h>
//#pragma config CONFIG1L = 0x0
__CONFIG(1, PLLDIV_1 & CPUDIV_OSC1_PLL2 & USBDIV_1);
//#pragma config CONFIG1H = 0x5
__CONFIG(2, FOSC_EC_EC & FCMEN_OFF & IESO_OFF);
//#pragma config CONFIG2L = 0x1F
__CONFIG(3, PWRT_OFF & BOR_ON & BORV_3 & VREGEN_OFF);
//#pragma config CONFIG2H = 0x1E
__CONFIG(4, WDT_OFF & WDTPS_32768);
//#pragma config CONFIG3H = 0x2
__CONFIG(5, CCP2MX_OFF & PBADEN_ON & LPT1OSC_OFF & MCLRE_OFF);
//#pragma config CONFIG4L = 0x80
__CONFIG(6, STVREN_OFF & LVP_OFF & ICPRT_OFF & XINST_OFF);
//#pragma config CONFIG5L = 0xF
__CONFIG(7, CP0_OFF & CP1_OFF & CP2_OFF & CP3_OFF);
//#pragma config CONFIG5H = 0xC0
__CONFIG(8, CPB_OFF & CPD_OFF);
//#pragma config CONFIG6L = 0xF
__CONFIG(9, WRT0_OFF & WRT1_OFF & WRT2_OFF & WRT3_OFF);
//#pragma config CONFIG6H = 0x60
__CONFIG(10, WRTC_OFF & WRTB_OFF & WRTD_ON);
//#pragma config CONFIG7L = 0xF
__CONFIG(11, EBTR0_OFF & EBTR1_OFF & EBTR2_OFF & EBTR3_OFF);
//#pragma config CONFIG7H = 0x40
__CONFIG(12, EBTRB_OFF);
#include "strings.h"
unsigned char ReadData;
void delay(unsigned int de)
{
unsigned int maxde,minde;
for(maxde=0;maxde<de;maxde++)
for(minde=0;minde<453;minde++);
}
void Write_b_eep( unsigned int badd,unsigned char bdat )
{
//EEADR =0x00;
EEADR = (badd & 0x0ff);
EEDATA =bdat;
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 1;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
//while(EECON1bits.WR);
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;
}
unsigned char Read_b_eep( unsigned int badd )
{
EEADR = (badd & 0x0ff);
EECON1bits.CFGS = 0;
EECON1bits.EEPGD = 0;
EECON1bits.RD = 1;
return( EEDATA ); // return with read byte
}
void main(void)
{
port1_init();
UART_init();
trans_string("PIC18F4550 EEPROM");
while(1)
{
Write_b_eep(0x0069,0x0010);
delay(100);
ReadData=Read_b_eep(0x0069);
delay(100);
Write_b_eep(0x006C,ReadData);
delay(1000);
}
}