Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

interfacing external EEPROM with PIC16F877A

Status
Not open for further replies.

john120

Banned
Full Member level 5
Joined
Aug 13, 2011
Messages
257
Helped
11
Reputation
22
Reaction score
10
Trophy points
1,298
Activity points
0
hELLO every body,I have a long program which is demonstrated here below, it not being executed because the pic memory has been become full so I want to use the external EERPOM can you plz help me to handle the issue I have 24lc256
Thanks;see the codes below:the if...else...if teste and evaluate the value of frequency read on the T1CKI pin;or help me about the array whic hreduces those if....else....if statements I think those arrays can also help:

#include <16F877A.h>
#DEVICE ADC=10
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include "lcd.c"
#define ka PIN_C3
#use fast_io(c)
#use fast_io(b)
#use fast_io(a)


void tempdisplay();
void kagaba();
void messagedisplay();
void final();

float voltsf,volts;
float period;
double jean;
float value;
double value1;
unsigned int adc_value;

void final(void)
{
if((value>=1234900) && (value1<=1235900))
{
jean=7.2;
}
else if((value>=1234100) && (value1<=1234800))
{
jean=7.3;
}
else if((value>=1234000) && (value1<=1231900))
{
jean=7.4;
}
else if((value>=1231500) && (value1<=1231800))
{
jean=7.5;
}
else if((value>=1230090) && (value1<=1230300))

{
jean=7.6;
}
else if((value>=1228900) && (value1<=1230100))
{
jean=7.7;
}
else if((value>=122600) && (value1<=1228000))
{
jean=7.8;
}
else if((value>=1226200) && (value1<=1226400))
{
jean=7.9;
}
else if((value>=1224800) && (value1<=1226120))
{
jean=8.0;
}
else if((value>=1223001) && (value1<=1224500))
{
jean=8.1;
}
else if((value>=1222999) && (value1<=1223000))

{
jean=8.2;
}
else if((value>=1220999) && (value1<=1223000))
{
jean=8.3;
}
else if((value>=1220001) && (value1<=1221000))
{
jean=8.4;
}
else if((value>=1219999) && (value1<=1220000))
{
jean=8.5;
}
else if((value>=1217995) && (value1<=1219999))
{
jean=8.6;
}
else if((value>=1218000) && (value1<=1219996))
{
jean=8.7;
}
else if((value>=1217939) && (value1<=1217999))
{
jean=8.9;
}
else if((value>=1217000) && (value1<=1217938))
{
jean=9.0;
}
else if((value>=1216000) && (value1<=1216999))
{
jean=9.1;
}
else if((value>=1215130) && (value1<=1215999))
{
jean=9.2;
}
else if((value>=1215000) && (value1<=1215129))
{
jean=9.3;
}
else if((value>=1212000) && (value1<=1214999))
{
jean=9.4;
}
else if((value>=1210000) && (value1<=1212000))
{
jean=9.5;
}
else if((value>=1209900) && (value1<=1209999))
{
jean=9.6;
}
else if((value>=1209500) && (value1<=1209899))
{
jean=9.7;
}
else if((value>=1209800) && (value1<=1209499))
{
jean=9.8;
}
else if((value>=1208500) && (value1<=1209799))
{
jean=9.9;
}
else if((value>=1207000) && (value1<=1208499))
{
jean=10;
}
else if((value>=1205000) && (value1<=1206999))

{
jean=10.1;
}
else if((value>=1202500) && (value1<=1204999))
{
jean=10.2;
}
else if((value>=1201500) && (value1<=1202499))
{
jean=10.3;
}
else if((value>=1201000) && (value1<=1201499))
{
jean=10.4;
}
else if((value>=1200000) && (value1<=1200999))
{
jean=10.5;
}
else if((value>=1199500) && (value1<=1199999))
{
jean=10.6;
}
else if((value>=1199000) && (value1<=1199499))
{
jean=10.7;
}
else if((value>=1198500) && (value1<=1198999))
{
jean=10.8;
}
else if((value>=1197000) && (value1<=1198000))
{
jean=10.9;
}
else if((value>=1196900) && (value1<=1196899))
{
jean=10.9;
}
else if((value>=1196000) && (value1<=1196899))
{
jean=11.0;
}
else if((value>=1195500) && (value1<=1195999))

{
jean=11.1;
}
else if((value>=1195000) && (value1<=1195499))
{
jean=11.2;
}
else if((value>=1194500) && (value1<=1194999))
{
jean=11.3;
}
else if((value>=1194000) && (value1<=1194499))
{
jean=11.4;
}
else if((value>=1193500) && (value1<=1193999))
{
jean=11.5;
}
else if((value>=1193000) && (value1<=1193499))
{
jean=11.6;
}
else if((value>=1190000) && (value1<=1192999))
{
jean=11.7;
}
else if((value>=1188500) && (value1<=1189999))
{
jean=11.8;
}
else if((value>=1187000) && (value1<=1188000))
{
jean=11.9;
}
else if((value>=1184100) && (value1<=1186999))
{
jean=12.0;
}
else if((value>=1183240) && (value1<=1184099))
{
jean=12.1;
}
else if((value>=1182230) && (value1<=1183239))
{
jean=12.2;
}
else if((value>=1181200) && (value1<=1182229))
{
jean=12.3;
}
else if((value>=1181000) && (value1<=1181199))
{
jean=12.4;
}
else if((value>=1180000) && (value1<=1180999))
{
jean=12.5;
}
else if((value>=1179000) && (value1<=1179999))
{
jean=12.6;
}
else if((value>=1173850) && (value1<=1174949))
{
jean=12.7;
}
else if((value>=1173650) && (value1<=1173849))

{
jean=12.8;
}
else if((value>=1173500) && (value1<=1173649))
{
jean=12.9;
}
else if((value>=1172500) && (value1<=1173499))
{
jean=13.0;
}
else if((value>=1171500) && (value1<=1172499))
{
jean=13.1;
}
else if((value>=1170000) && (value1<=1171499))
{
jean=13.2;
}
else if((value>=1168500) && (value1<=1169999))
{
jean=13.3;
}
else if((value>=1167500) && (value1<=1168499))
{
jean=13.4;
}
else if((value>=1166000) && (value1<=1167499))
{
jean=13.5;
}
else if((value>=1164500) && (value1<=1165999))
{
jean=13.6;
}
else if((value>=1163000) && (value1<=1164499))
{
jean=13.7;
}
else if((value>=1159999) && (value1<=1162999))
{
jean=13.8;
}
else if((value>=1158500) && (value1<=1159997))
{
jean=13.9;
}
else if((value>=1157500) && (value1<=1158499))
{
jean=13.9;
}
else if((value>=1156500) && (value1<=1157499))
{
jean=14.0;
}
else if((value>=1155000) && (value1<=1156499))
{
jean=14.1;
}
else if((value>=1153500) && (value1<=1154999))
{
jean=14.2;
}
else if((value>=1151500) && (value1<=1152500))
{
jean=14.3;
}
else if((value>=1150500) && (value1<=1151499))
{
jean=14.4;
}
else if((value>=1149880) && (value1<=1150499))
{
jean=14.5;
}
else if((value>=1144000) && (value1<=1149870))
{
jean=14.6;
}
else if((value>=1143000) && (value1<=1143999))
{
jean=14.7;
}
else if((value>=1141800) && (value1<=1142999))
{
jean=14.8;
}
else if((value>=1141500) && (value1<=1141799))

{
jean=14.9;
}
else if((value>=1142600) && (value1<=1143499))
{
jean=15.0;
}
else if((value>=1141500) && (value1<=1142599))
{
jean=15.1;
}
else if((value>=1140400) && (value1<=1141499))
{
jean=15.2;
}
else if((value>=1139600) && (value1<=1140399))
{
jean=15.3;
}
else if((value>=1138560) && (value1<=1139599))
{
jean=15.4;
}
else if((value>=1137500) && (value1<=1138559))
{
jean=15.5;
}
else if((value>=1136500) && (value1<=1137499))
{
jean=15.6;
}
else if((value>=1135500) && (value1<=1136499))
{
jean=15.7;
}
else if((value>=1134500) && (value1<=1135499))
{
jean=15.8;
}
else if((value>=1133500) && (value1<=1134499))
{
jean=15.9;
}
else if((value>=1129999) && (value1<=1133499))
{
jean=16.0;
}
else if((value>=1128500) && (value1<=1129998))
{
jean=16.1;
}
else if((value>=1127500) && (value1<=1128499))
{
jean=16.2;
}
else if((value>=1127500) && (value1<=1127499))
{
jean=16.3;
}
else if((value>=1123500) && (value1<=1124998))
{
jean=16.4;
}
if((value>=1122500) && (value1<=1123499))
{
jean=16.5;
}
else if((value>=1121500) && (value1<=1122499))
{
jean=16.6;
}
else if((value>=1119950) && (value1<=1121499))
{
jean=16.7;
}
else if((value>=1118500) && (value1<=1119949))
{
jean=16.8;
}
else if((value>=1117500) && (value1<=1118499))
{
jean=16.9;
}
else if((value>=1116500) && (value1<=1117499))
{
jean=17.0;
}
else if((value>=1115000) && (value1<=1116499))
{
jean=17.1;
}
else if((value>=1113500) && (value1<=1114999))
{
jean=17.2;
}
else if((value>=1112000) && (value1<=1113499))
{
jean=17.3;
}
else if((value>=1110500) && (value1<=1111999))
{
jean=17.4;
}
if((value>=1108000) && (value1<=1109000))
{
jean=17.5;
}
else if((value>=1106500) && (value1<=1107999))
{
jean=17.6;
}
else if((value>=1105200) && (value1<=1106499))
{
jean=17.7;
}
else if((value>=1103500) && (value1<=1105199))
{
jean=17.8;
}
else if((value>=1102500) && (value1<=1103499))
{
jean=17.9;
}
else if((value>=1101000) && (value1<=1102499))
{
jean=18.0;
}
if((value>=1099799) && (value1<=1100999))
{
jean=18.1;
}
else if((value>=1098500) && (value1<=1099798))
{
jean=18.2;
}}
/*else if((value>=1097500) && (value1<=1098499))
{
jean=18.3;
}
else if((value>=1096400) && (value1<=1097499))
{
jean=18.4;
}
else if((value>=1095200) && (value1<=1096399))
{
jean=18.5;
}
else if((value>=1094000) && (value1<=1095199))
{
jean=18.6;
}
else if((value>=1092500) && (value1<=1093999))
{
jean=18.7;
}
else if((value>=1091500) && (value1<=1092499))
{
jean=18.8;
}
if((value>=1090000) && (value1<=1091499))
{
jean=18.9;
}
else if((value>=1088500) && (value1<=1089999))
{
jean=19.0;
}
else if((value>=1087500) && (value1<=1088499))
{
jean=19.1;
}
else if((value>=1086200) && (value1<=1087499))
{
jean=19.2;
}
if((value>=1085000) && (value1<=1086199))
{
jean=19.2;
}
else if((value>=1082000) && (value1<=1084999))

{
jean=19.3;
}
else if((value>=1080000) && (value1<=1081999))
{
jean=19.4;
}
else if((value>=1078500) && (value1<=1079999))
{
jean=19.5;
}
else if((value>=1077500) && (value1<=1078499))
{
jean=19.6;
}
else if((value>=1076500) && (value1<=1077499))
{
jean=19.7;
}
else if((value>=1075900) && (value1<=1076499))
{
jean=19.8;
}
else if((value>=1075860) && (value1<=1075899))
{
jean=19.9;
}
else if((value>=1075830) && (value1<=1075859))
{
jean=20.0;
}}
/*
else if((value>=1074820) && (value1<=1075829))
{
jean=20.1;
}
else if((value>=1073500) && (value1<=1074819))
{
jean=20.2;
}
else if((value>=1072500) && (value1<=1073499))
{
jean=20.3;
}
else if((value>=1071200) && (value1<=1072499))
{
jean=20.4;
}
else if((value>=1070000) && (value1<=1071199))
{
jean=20.5;
}
else if((value>=1068500) && (value1<=1069999))
{
jean=20.6;
}
else if((value>=1067200) && (value1<=1068499))
{
jean=20.7;
}
else if((value>=1066100) && (value1<=1067199))
{
jean=20.8;
}
else if((value>=1065000) && (value1<=1066099))
{
jean=20.9;
}
else if((value>=1063200) && (value1<=1064999))
{
jean=21.0;
}
else if((value>=1062400) && (value1<=1063199))
{
jean=21.1;
}
else if((value>=1061300) && (value1<=1062399))
{
jean=21.2;
}
else if((value>=1061000) && (value1<=1061299))
{
jean=21.3;
}
else if((value>=1060000) && (value1<=1060999))
{
jean=21.4;
}
else if((value>=1058000) && (value1<=1059999))
{
jean=21.5;
}
else if((value>=1056000) && (value1<=1057999))
{
jean=21.6;
}
else if((value>=1055000) && (value1<=1055999))
{
jean=21.7;
}
else if((value>=1054000) && (value1<=1054999))
{
jean=21.8;
}

else if((value>=1053000) && (value1<=1053999))
{
jean=21.9;
}
else if((value>=1051950) && (value1<=1052999))
{
jean=22.0;
}
else if((value>=1051500) && (value1<=1051949))
{
jean=22.1;
}
if((value>=1050000) && (value1<=1051499))
{
jean=22.2;
}
//if((value1>=1048500) && (value1<=1049999))
//{
//jean=22.3;
//}
else if((value1>=1047000) && (value1<=1048499))
{
jean=22.4;
}
else if((value1>=1045500) && (value1<=1046999))
{
jean=22.5;
}
else if((value1>=1044000) && (value1<=1045499))
{
jean=22.6;
}
else if((value1>=1042500) && (value1<=1043999))
{
jean=22.7;
}
else if((value1>=1041200) && (value1<=1042499))
{
jean=22.8;
}
else if((value1>=1040000) && (value1<=1041199))
{
jean=22.9;
}
else if((value1>=1038500) && (value1<=1039999))
{
jean=23.0;
}
else if((value1>=1037000) && (value1<=1038499))
{
jean=23.1;
}
else if((value1>=1035500) && (value1<=1036999))
{
jean=23.2;
}
else if((value1>=1034000) && (value1<=1035499))
{
jean=23.3;
}
else if((value1>=1032000) && (value1<=1033000))
{
jean=23.4;
}
else if((value1>=1030000) && (value1<=1031999))
{
jean=23.5;
}
else if((value1>=1028999) && (value1<=1029999))
{
jean=23.6;
}
else if((value1>=1027500) && (value1<=1028998))
{
jean=23.7;
}
else if((value1>=1026500) && (value1<=1027499))
{
jean=23.8;
}
else if((value1>=1026000) && (value1<=1026499))
{
jean=23.9;
}
else if((value1>=1025000) && (value1<=1025999))
{
jean=24.0;
}
else if((value1>=1024000) && (value1<=1024999))
{
jean=24.1;
}
else if((value1>=1022500) && (value1<=1023999))
{
jean=24.2;
}
else if((value1>=1021500) && (value1<=1022499))
{
jean=24.3;
}
else if((value1>=1021000) && (value1<=1021499))
{
jean=24.4;
}
else if((value1>=1020000) && (value1<=1020999))
{
jean=24.5;
}
else if((value1>=1018500) && (value1<=1019999))
{
jean=24.6;
}
else if((value1>=1018200) && (value1<=1018499))
{
jean=24.7;
}
else if((value1>=1018000) && (value1<=1018199))
{
jean=24.8;
}
else if((value1>=1017500) && (value1<=1017999))
{
jean=24.9;
}
else if((value1>=1017000) && (value1<=1017499))
{
jean=25.0;
}}
/*else if((value1>=1016500) && (value1<=1016999))
{
jean=25.1;
}
else if((value1>=1016000) && (value1<=1016499))
{
jean=25.2;
}
else if((value1>=1015500) && (value1<=1015999))
{
jean=25.3;
}
else if((value1>=1015500) && (value1<=1015999))
{
jean=25.4;
}
else if((value1>=1014500) && (value1<=1014999))
{
jean=25.5;
}
else if((value1>=1014000) && (value1<=1014499))
{
jean=25.6;
}
else if((value1>=1013500) && (value1<=1013999))
{
jean=25.7;
}

else if((value1>=1012500) && (value1<=1012999))
{
jean=25.9;
}
else if((value1>=1012000) && (value1<=1012499))
{
jean=26.0;
}
else if((value1>=1013000) && (value1<=1013499))
{
jean=25.8;
}
else
{
printf(lcd_putc,"\fConnect Probe");
delay_ms(1500);
}*/



void main(void)
{
set_tris_c(0xff);
set_tris_b(0x00);
lcd_init();
delay_us(200);
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
adc_value = read_adc();
volts = ((float)(adc_value * 500)/1023.0);
delay_ms(400);


delay_ms(1500);
printf(lcd_putc, "\fWELCOME");
delay_ms(1500);
break;



while(true)
{
if((input(PIN_C5)==0))
{
final();

if(input(PIN_C5)==0)
{
delay_ms(150);
lcd_gotoxy(7,1);
printf(lcd_putc,"\fWait");
delay_ms(2500);
printf(lcd_putc,"\f%3.1f",volts);

printf(lcd_putc,"\°C");
delay_ms(2500);

lcd_gotoxy(7,1);

printf(lcd_putc,"\f%2.1f"jean);
printf(lcd_putc,"\%%");
delay_ms(3500);
}
}

if(input(PIN_C4)==0)
{
if(input(PIN_C4)==0)
{
printf(lcd_putc,"\fSinusoidal");
delay_ms(2000);
}
}

if(input(PIN_C1)==0)
{
if(input(PIN_C1)==0)
{
printf(lcd_putc,"\fSquare");
delay_ms(2000);
}
}
}
}
 

what is your problem now? in your eeprom interfacing or have to reduce the program size?
 

what is your problem now? in your eeprom interfacing or have to reduce the program size?
My problem is to reduce the program size first but also if possible tell me a little bit how I can interface with External EEPROM.

Thanks.
 

what is that value1, where you reading this input.

you cant reduce your code size, because you comparing the in between two ranges,

can you go for switch statement if possible.
 

what is that value1, where you reading this input.

you cant reduce your code size, because you comparing the in between two ranges,

can you go for switch statement if possible.

this value1 is the frequency read by the pic on its T1CKI pin,I am seeking how Ican reduce the codes but it is not going,can you plz help me with two arrays then search for index of a number (value1) which is located between those two :example

const int k[]={1,2,3,4,5,6}
const int g[]={7,8,9,10,11,12}

if for example the value1 (read by the pic) is 9.5
this means 4<=9.5<=10 ;like this for example to find the index of 4 which is the same as the index of 10.

Plz help

Help plz
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top