We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi gays I need some help with my code I use kiel 4.1 when I want to creat it it shows the target not created with no errors or warnings,thanks advance for your help.
#include<REGX51.H> //#include<reg51.h> #include<stdio.h> #include<math.h>
//------------------------------------------------------ //ADC config. #define adc_port P1 #define sc P3_0 #define eoc P3_1
#define ADD_A P0_0 #define ADD_B P0_1 #define ADD_C P0_2 // LCD config. #define lcd_port P2 #define rs P3_6 #define en P3_7 //------------------------------------------------------ //#define red P0_3 //#define ir P0_4 #define red P0_3 #define ir P0_4 //------------------------------------------------------ // function using void delay(unsigned int); void lcd_data(unsigned char value); void ADC_0808(); void calc(); //------------------------------------------------------ unsigned int sum1=0,sum2=0; unsigned char spo2[100],l[6],s; char adc,avg1,avg2; //------------------------------------------------------ //------------------------------------------------------ void calc() { unsigned int i,j,k,n=0; ADD_A=0; ADD_B=0; ADD_C=0; for(i=0;i<6;i++) { for(j=0;j<100;j++) { ADC_0808(); spo2[j]=adc ; } l[n]=spo2[0] ; for(k=0;k<100;k++) {if(spo2[k]>l[n]) l[n]=spo2[k];} n++; s=spo2[0] ; for(k=0;k<100;k++) {if(spo2[k]<s) s=spo2[k];} sum2+=s; } for(n=0;n<6;n++) {sum1+=l[n];} avg1=sum1/6 ; avg2=sum2/6 ; } //------------------------------------------------------ void ADC_0808() { sc=1; sc=0; while(eoc==0); adc=adc_port; } //------------------------------------------------------ // Generate Delay void delay(unsigned int count) // Function to provide time delay in msec. { int i,j; for(i=0;i<count;i++) for(j=0;j<1275;j++); } //------------------------------------------------------ //Sending Command to LCD void lcd_cmd(unsigned char item) // Function to send commands to LCD { lcd_port= item; rs= 0; en=1; delay(1); en=0; return; }
//Sending Data to LCD void lcd_data(unsigned char value) // Function to send data to LCD (Letter or even any symbol in ASCII code) { lcd_port= value; rs= 1; en=1; delay(1); en=0; return; } //------------------------------------------------------ //Sending String to LCD void lcd_str(unsigned char *str) { int i=0; while(str[i]!='\0') { lcd_data(str[i]); i++; delay(1); } return; } //------------------------------------------------------ void main() { float ratio,num,den; while(1) { adc_port=0xff; red=1; ir=0; calc(); num=(avg1-avg2)/avg2; red=0; ir=0; calc(); den=(avg1-avg2)/avg2; ratio=num/den; } }
You are writing "kiel" instead "Keil". You are using software delay loops, a big no-no in any serious application and totally illegal in commercial software development. You are using float variables where integer arithmetic would be sufficient.
My assumption is that you are using the free Keil evaluation version of the compiler without reading and understanding its limitations.
when I want to creat it shows : warnings: "uncalled segment,ignored for overlay process" "segment?pr?LCD_CMD?AA" "uncalled segment,ignored for overlay process" "segment?pr?LCD_STR?AA"
error L107: "adress space overflow" space DATA segment_DATA_GROUp length: 0012H program size: data=146.0 xdata=0 code=1106 the target not created
#include<REGX51.H> //#include<reg51.h> #include<stdio.h> #include<math.h> //------------------------------------------------------ //ADC config. #define adc_port P1 #define sc P3_0 #define eoc P3_1 #define ADD_A P0_0 #define ADD_B P0_1 #define ADD_C P0_2 // LCD config. #define lcd_port P2 #define rs P3_6 #define en P3_7 //------------------------------------------------------ //#define red P0_3 //#define ir P0_4 #define red P0_3 #define ir P0_4 //------------------------------------------------------ // function using void delay(unsigned int); void lcd_data(unsigned char value); void ADC_0808(); void calc(); //------------------------------------------------------ unsigned int sum1=0,sum2=0; unsigned char spo2[100],l[6],s; char adc,avg1,avg2; //------------------------------------------------------ //------------------------------------------------------ void calc() { unsigned int i,j,k,n=0; ADD_A=0; ADD_B=0; ADD_C=0; for(i=0;i<6;i++) { for(j=0;j<100;j++) { ADC_0808(); spo2[j]=adc ; } l[n]=spo2[0] ; for(k=0;k<100;k++) {if(spo2[k]>l[n]) l[n]=spo2[k];} n++; s=spo2[0] ; for(k=0;k<100;k++) {if(spo2[k]<s) s=spo2[k];} sum2+=s; } for(n=0;n<6;n++) {sum1+=l[n];} avg1=sum1/6 ; avg2=sum2/6 ; } //------------------------------------------------------ void ADC_0808() { sc=1; sc=0; while(eoc==0); adc=adc_port; } //------------------------------------------------------ // Generate Delay void delay(unsigned int count) // Function to provide time delay in msec. { int i,j; for(i=0;i<count;i++) for(j=0;j<1275;j++); } //------------------------------------------------------ //Sending Command to LCD void lcd_cmd(unsigned char item) // Function to send commands to LCD { lcd_port= item; rs= 0; en=1; delay(1); en=0; return; } //Sending Data to LCD void lcd_data(unsigned char value) // Function to send data to LCD (Letter or even any symbol in ASCII code) { lcd_port= value; rs= 1; en=1; delay(1); en=0; return; } //------------------------------------------------------ //Sending String to LCD void lcd_str(unsigned char *str) { int i=0; while(str[i]!='\0') { lcd_data(str[i]); i++; delay(1); } return; } //------------------------------------------------------ void main() { float ratio,num,den; while(1) { adc_port=0xff; red=1; ir=0; calc(); num=(avg1-avg2)/avg2; red=0; ir=0; calc(); den=(avg1-avg2)/avg2; ratio=num/den; } }
if the problem in my program could you help me by making Hex file. I need the HEX file to finish my project.