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.

adding 2 float using mikroc and proteus

Status
Not open for further replies.

ederelk

Newbie level 4
Joined
Nov 20, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,333
my code compiles fine.but whenever i run the simulation in proteus it gives me error like stack overflow. but when i comment the statement in red it simulates fine without any error.please help me. :sad:











// Lcd pinout settings
sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D4 at RD4_bit;

// Pin direction
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D7_Direction at TRISD7_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
char* ValueRD;
char buf[15];
float data1=10.1234567891234;
float addme=2.0;
float newfloat=2.3 ;
char outBuff[21];
float xbuff;
float adc, adc2;
void StoreBytesIntoEEprom(unsigned int address, unsigned short *ptr, unsigned int SizeinBytes)
{
unsigned short j;

for (j = 0; j < SizeinBytes; j++)
{
EEprom_Write(address+j, *(ptr+j));
Delay_ms(50);
};
}

void ReadBytesFromEEprom(unsigned int address, unsigned short *ptr, unsigned int SizeinBytes)
{
unsigned int j;

for (j = 0; j < SizeinBytes; j++)
{
*(ptr+j) = Eeprom_Read( address+j);
Delay_ms(50);
}
}


void Init_Main() {

TRISD = 0;
PORTD = 0xFF;
TRISD = 0xff;
//ANSEL = 0; // Configure AN pins as digital I/O
//ANSELH = 0;
ADCON1=7;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD display
Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off

Lcd_Out(1,1,ValueRD); // Prepare and output static text on LCD
/* Delay_ms(8000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,gotbyte); */
}

// void WriteAndRead(){}
void main() {





// declare array
//WriteAndRead();
ValueRD="start";

Init_Main();
ADCON1=7; // Configure AN pins as digital I/O


delay_ms(100); //settle time for lcd
lcd_init(); // initialization of lcd
Lcd_Cmd(_LCD_CLEAR);

data1=newfloat + addme;
//ceil((double)data1);
delay_ms( 500);
// Lcd_Config(&PORTB,4,5,6,3,2,1,0);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);

LCD_Out(1,1,"Save to EEPROM:");
StoreBytesIntoEEprom( 0, (unsigned short *)&data1, 4);
FloatToStr( data1, &outBuff);
LCD_Out(2,1,&OutBuff);
Delay_ms(2000);

data1 = 0; // clear data, to see if it comes realy from eeprom back!

LCD_Out(1,1,"Get From EEPROM:");
ReadBytesFromEEprom( 0, (unsigned short *)&data1, 4);

FloatToStr(data1, &outBuff);
LCD_Out(2,1,&OutBuff);


}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top