not enough ram

Discuss with MikroElektronika software developers about current library development.
Post Reply
Author
Message
jaladinafghan
Posts: 2
Joined: 11 Nov 2019 14:29

not enough ram

#1 Post by jaladinafghan » 11 Nov 2019 22:52

Hi, I used pic16f877a in my project in order to measure the PVI value when the length of the array increase from 45 i get that massage while I need the length about 1200 elements for both of arries when i searched up on this topic found that the RAM should be copied to the ROM so how can I do that tried lot but couldn't find any way to solve this problem so please help :(

this the relative code for


sbit LCD_RS at RB4_bit; // Lcd pinout settings
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;


sbit LCD_RS_Direction at TRISB4_bit; // Pin direction
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;

char txt[7];
unsigned read_adc;
unsigned int ADCsamples[77];
unsigned int Average[40];
unsigned int samplecount=0;
unsigned int elements=512;
float Pmax;
float Pmin;
char PVI;
char length;
char i=0;
char sum=0;

void main() {
TRISA=0b00000001;
TRISB=0b00000000; // these three ports are set as output but in program the b port will be used as output
TRISC=0b00000000;
TRISD=0b00000000;

PORTA=0;
PORTB=0;
PORTC=0;
PORTD=0;
ADCON1=0b10001110; // the regiter of ADCON1 is set as right shifted and the ADC input is taken from port'A pinA0

// ADC_Init_Advanced(_ADC_INTERNAL_REF);ADCON1=0b10001110; // the regiter of ADCON1 is set as right shifted and the ADC input is taken from port'A pinA0
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_CLEAR);
Delay_ms(100);



while(1){


for(samplecount=0;samplecount<elements;samplecount++) // In order to read the port'A pinA0
{
//ADCsamples[samplecount]=ADC_GET_SAMPLE(0);
read_adc=ADC_Read(0);
ADCsamples[samplecount]=read_adc;

}
for(samplecount=0;samplecount<elements-length;samplecount++) // to reduce noise and make the singnal as stable as possable
{
for(i=samplecount;i<samplecount+length;i++)
{
sum=sum+ADCsamples;
}
Average[samplecount]=sum/length;
}
for(samplecount=0;samplecount<elements;samplecount++) // in order to find Pmax and Pmin we use for loop
{
if(Average[samplecount]>Pmax)
{
Pmax=Average[samplecount];
}
else if(Average[samplecount]<Pmin)
{
Pmin=Average[samplecount];
}
}

PVI=(Pmax-Pmin)/Pmax*100; // to find value of pleth varaibilty index we use the basic formula

ByteToStr(PVI,txt);//to convert Float number to string
Lcd_Out(1,3,txt); // to display on LCD value of PVI



}







}

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: not enough ram

#2 Post by jovana.medakovic » 22 Nov 2019 16:32

Hello,

I believe that I answered you on this forum:
viewtopic.php?f=176&t=75566

Kind regards,
Jovana

Post Reply

Return to “Library Development Discussion”