sahu
Member
i have need microc source code conversion with 16f72 to 16f676.
16f72 microc source code as...
16f676 microc source code as...
found error as..
pl help me...for conversion ..
16f72 microc source code as...
Code:
float ch; //
unsigned int adc_rd; // Declare variables
long tlong;
void main()
{
TRISA = 0x3F; // setting AD0 for input
TRISB = 0x00; // setting port B as output.
TRISC = 0b11000000; // selecting port c as output
ADCON0=0x01;
ADCON1=0x00;
//PORTB = 0x00;
loop:
RC0_bit = 1; // delay indicator on
RC1_bit = 0; // mains indicator off
RC5_bit = 0; // Output relay off
/*................................................. ...............................
Delay mode selection for user friendly...
.................................................. ...............................*/
if(RC6_bit = 0)
{
Delay_ms(5000);
}
else
{
Delay_ms(100);
}
/* .................................................. .............................
Main working starts here
.................................................. ................................*/
RC0_bit = 0; // delay indicator off.
while(1)
{
adc_rd = ADC_Read(0); // A/D conversion. Pin RA2 is an input.
tlong = (long)adc_rd * 5000; // Convert the result in millivolts
tlong = tlong / 255; // 0..1023 -> 0-5000mV
ch =(float) tlong / 1000; // Extract volts (thousands of millivolts)
/*................................................. ...............................
Main stabilizing is done here
.................................................. ...............................*/
if((ch<=1.9)&&(ch>=1.30))
{
if(ch>1.33)
{
if(ch>1.40)
{
if(ch>1.48)
{
if(ch>1.56)
{
if(ch>1.63)
{
if(ch>1.704)
{
if(ch>1.78)
{
if(ch>1.85)
{
PORTB =0b00000001;
}
else
PORTB =0b00000011;
}
else
PORTB =0b00000111;
}
else
PORTB =0b00001111;
}
else
PORTB =0b00011111;
}
else
PORTB =0b00111111;
}
else
PORTB =0b01111111;
}
else
PORTB =0b11111111;
}
else
PORTB = 0x00;
RC5_bit = 1; // output relay on.
RC1_bit = 1; // mains indicator on
RC3_bit = 1; // normal indicator on.
RC4_bit = 0; // high voltage indicator off
RC2_bit = 0; // low voltage indicator off
}
/*................................................. ...............................
High voltage protection for load is done here
.................................................. ...............................*/
if(ch > 2.10)
{
RC4_bit = 1; // high voltage indicator on
RC2_bit = 0; // low voltage indicator off
RC5_bit = 0; // relay off
RC1_bit = 0; // Mains normal indicator off
RC3_bit = 0; // normal indicator off.
PORTB = 0x00;
goto loop;
}
/*................................................. ...............................
Low voltage protection is done here
.................................................. ...............................*/
if(ch <= 1.30)
{
RC2_bit = 1; // low voltage indicator on
RC5_bit = 0; // O/P relay off
RC3_bit = 0; // Mains normal indicator off
RC4_bit = 0; // high indicator on.
RC1_bit = 0; // Mains normal indicator off
PORTB = 0x00;
goto loop;
}
}
}
16f676 microc source code as...
Code:
float ch;
unsigned int ADC_Value;
long tlong;
/*................................................. ...............................
Define relay selection port pins
.................................................. ...............................*/
sbit RL1 @ PORTA:1;
sbit RL2 @ PORTC:0;
sbit RL3 @ PORTC,1;
sbit RL4 @ PORTC,2;
sbit RL5 @ PORTA,2;
//defined RL1 at PORTA,1;//PIN 12
//sbit RL2 at RC0_bit;//PIN 10
//sbit RL3 at RC1_bit;//PIN 09
//sbit RL4 at RC2_bit;//PIN 08
//sbit RL5 at PORTA,2;//PIN 11
/*................................................. ...............................
Define LED/ bzr selection port pins
.................................................. ...............................*/
sbit L1 at Rc5_bit;//PIN 05 hi\lo cut
sbit L2 at Rc4_bit;//PIN 06 mains normal
sbit BZR at Rc3_bit;//PIN 07 SOUND
/*................................................. ...............................
Define LED/ bzr selection port pins
.................................................. ...............................*/
sbit SW1 at PORTA,5;//PIN 03 hi\lo cut enabol
sbit SW2 at PORTA,4;//PIN 02 QEK SATART
void main()
{
//ANSEL = 0x01; // RA0 analog input
TRISA = 0x39; // setting RA0 analog input & RA3 -RA5 digital i\p
TRISC = 0x00; // setting port C as output.
// Configure ADCON0 for channel AN0
ADCON0=0x01;
ADCON1=0x00;
loop_01:
L2 = 1;// mains normal on
L1 = 0;// hi\lo cut off
BZR = 0;// SOUND off
RL4 = 0;// Output relay off R4
/*................................................. ...............................
Delay mode selection for user friendly...
.................................................. ...............................*/
if(SW2 == 0)
{
Delay_ms(5);
}
else
{
Delay_ms(1);
}
/* .................................................. .............................
Main working starts here
.................................................. ................................*/
L1 = 0; // delay indicator off.
while(1)
{
ADC_Value = ADC_Read(0); // A/D conversion. Pin RA2 is an input.
tlong =(long)ADC_Value*5000; // Convert the result in millivolts
tlong = tlong/1023; // 0..1023 -> 0-5000mV
ch =(float)tlong/1000; // Extract volts (thousands of millivolts)
/*................................................. ...............................
Main stabilizing is done here
.................................................. ...............................*/
if((ch<=4.60)&&(ch>=1.40))
{
if(ch>4.65)
{
if(ch>4.00)
{
if(ch>3.65)
{
if(ch>3.15)
{
if(ch>2.56)
{
if(ch>1.48)
{
//if(ch>1.40)
//{
RL5 = 1;
RL3 = 1;
RL2 = 1;
RL1 = 0;//STP7
}
//else
RL5 = 1;
RL2 = 1;
RL1 = 0;
RL3 = 0;//STP6
}
//else
RL3 = 1;
RL2 = 1;
RL1 = 0;
RL5 = 0;//STP5
}
//else
RL2 = 1;
RL1 = 0;
RL5 = 0;
RL3 = 0;//STP4
}
//else
RL3 = 1;
RL1 = 0;
RL5 = 0;
RL2 = 0;//STP3
}
//else
RL1 = 0;
RL3 = 1;
RL5 = 0;
RL2 = 0;//STP2
}
//else
RL3 = 1;
RL1 = 0;
RL5 = 0;
RL2 = 0;//STP1
}
//else
RL5 = 1;
RL3 = 1;
RL2 = 1;
RL1 = 0;
RL4 = 1;// output relay on.
L2 = 1; // mains indicator on
L1 = 0; // high //low voltage indicator off
BZR = 0; // high //low voltage indicator off
}
/*................................................. ...............................
High voltage protection for load is done here
.................................................. ...............................*/
if(ch > 4.80)
{
L1 = 1; // high // low voltage indicator on
BZR = 1; // cret sound
RL4 = 0; // relay off
L2 = 0; // Mains normal indicator off
goto loop_01;
}
/*................................................. ...............................
Low voltage protection is done here
.................................................. ...............................*/
if(ch <= 1.30)
{
L1 = 1; // high // low voltage indicator on
BZR = 1; // cret sound
RL4 = 0; // relay off
L2 = 0; // Mains normal indicator off
goto loop_01;
}
} // End main()
found error as..
Code:
error: 102****342****There is not enough ROM space****__Lib_MathDouble.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 27****392****Address must be greater than 0 main****MyProject.c
error: 1091****392****Address must be greater than 0 Div_32x32_S****__Lib_Math.c
error: 1091****392****Address must be greater than 0 Div_32x32_S****__Lib_Math.c
error: 49****392****Address must be greater than 0 ADC_Read****__Lib_ADC_A_B.c
error: 1903****392****Address must be greater than 0 Longint2Double****__Lib_MathDouble.c
error: 24****392****Address must be greater than 0 __CC2DW****__Lib_System.c
error: 761****392****Address must be greater than 0 Div_32x32_FP****__Lib_MathDouble.c
error: 761****392****Address must be greater than 0 Div_32x32_FP****__Lib_MathDouble.c
error: 761****392****Address must be greater than 0 Div_32x32_FP****__Lib_MathDouble.c
error: 761****392****Address must be greater than 0 Div_32x32_FP****__Lib_MathDouble.c
error: 245****392****Address must be greater than 0 NRM4032****__Lib_MathDouble.c
error: 245****392****Address must be greater than 0 NRM4032****__Lib_MathDouble.c
error: 245****392****Address must be greater than 0 NRM4032****__Lib_MathDouble.c
error: 245****392****Address must be greater than 0 NRM4032****__Lib_MathDouble.c
error: 0****102****Finished (with errors): 12 Aug 2011, 21:43:39****MyProject.mcppi
pl help me...for conversion ..