Mega 5MP SPI on STM32F103 – readFifoLength returns 0x00800778

I downloaded rep in Arducam Mega.
We are using STMF32103C8t6 dev board as for MCU.
Our camera is Mega 5MP SPI Camera with M12 Lens (NOIR) for any controller. We bought it direrctly from arducam. Arducam order no is 96571.(June 23 2023).
The document in the box says it is B0437.
We get the Camera ID as 0x83. When camera begins.

Then commented the UART part for the code. and take 1 picture. The pinning is the same as the sample code.
camera->receivedLength = readFifoLength(camera);
returns 0x00800778
which is a very strange value.
We are stucked with this.

We know camera is running with the same cabling we also tested with arduino and Arducam_Mega.exe and it is running fluently.

The code with the comments are as below

/*

  • This file is part of the Arducam SPI Camera project.
  • Copyright 2021 Arducam Technology co., Ltd. All Rights Reserved.
  • This work is licensed under the MIT license, see the file LICENSE for details.

*/
#include “ArducamCamera.h”
#include “Platform.h”
#include <stdbool.h> // for bool

static volatile bool cameraBusy = false;
int CS = 4;
uint8_t temp = 0xff;
uint8_t commandBuff[20] = {0};
uint8_t commandLength = 0;
uint8_t sendFlag = TRUE;
uint32_t readImageLength = 0;
uint8_t jpegHeadFlag = 0;
ArducamCamera myCAM;

uint8_t ReadBuffer(uint8_t* imagebuf, uint8_t length)
{
if (imagebuf[0] == 0xff && imagebuf[1] == 0xd8) {

}
if (jpegHeadFlag == 1) {
    readImageLength += length;


}
if (readImageLength == myCAM.totalLength) {
    readImageLength = 0;
    jpegHeadFlag    = 0;

}
return sendFlag;

}

void stop_handle()
{
readImageLength = 0;
jpegHeadFlag = 0;
uint32_t len = 9;

}

int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
delayInit();
myCAM = createArducamCamera(CS);
begin(&myCAM);
while (1) {
if (!cameraBusy) {
cameraBusy = true;
takePicture(&myCAM, (CAM_IMAGE_MODE)CAM_IMAGE_MODE_VGA , (CAM_IMAGE_PIX_FMT)CAM_IMAGE_PIX_FMT_JPG);

    }
}

}