Adafruit Fona SIM800l gets reinitialized when RI pin goes LOW

Hello,

I have a requirement like when user sends "STATUS" SMS, the device must send a reply, i.e., data from an energy meter

I am using Arduino MEGA as an interface to energy-meter and FONA GSM. I have seperate program functions written for GSM module and to read serial data from the energy-meter. Both the functions works fine when executed seperately.

Hardware Serial 1 is used for energy-meter and Software Serial is used for GSM module

When combining these functions, the energy-meter functions works fine, but when the GSM module receives a message, RI pin goes LOW and system is restated.

code for loop() is as follows

void loop()
{
    while(!digitalRead(FONA_RI)
    {
       gsm_module();
    }
    
    if(Serial1.available() > 0)
    {
       energy_meter();
     }
}

Thanks in advance,
umesh