This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LS31x and FAPI

Hi I am trying to write a very simplistic firmware that would write data to flash. So far my code is as follows(call to Fapi_initializeFlashBanks happens earlier in the code):

	status = Fapi_setActiveFlashBank(bank); 
	if (status != ERROR_OK) {
		LOG("Failed to set bank %d active", bank_nr);
		return ERROR_FAIL;
	}

	status = Fapi_enableMainBankSectors(0xFF);
	if (status != ERROR_OK) {
		LOG("Failed to enable bank's sectors");
		return ERROR_FAIL;
	}

	status = f0xx_wait_for_fsm_to_finish(F0XX_DEFAULT_FSM_TIMEOUT);
	if (status != ERROR_OK) {
		LOG("Flash FSM did not finish after Fapi_enableMainBankSectors call");
		return ERROR_FAIL;
	}

	do {
		chunk_size = MIN(16, remainder);
		LOG("W @ %x (%d)", address, chunk_size);

		status = Fapi_issueProgrammingCommand((uint32_t *)address,
						      (uint8_t *) data_pointer,
						      chunk_size,
						      0,
						      0,
						      Fapi_AutoEccGeneration);

		if (status != Fapi_Status_Success) {
			LOG("Fapi_issueProgrammingCommand returned error: %d", status);
			return ERROR_FAIL;
		}
		
		status = f0xx_wait_for_fsm_to_finish(F0XX_DEFAULT_FSM_TIMEOUT);
		if (status != ERROR_OK) {
			LOG("Timed out waiting for flash FSM");
			return ERROR_FAIL;
		}

		if (FAPI_GET_FSM_STATUS != Fapi_Status_Success) {
			LOG("Flash FSM's status register indicated error %x", FAPI_GET_FSM_STATUS);
			return ERROR_FAIL;
		}

		remainder -= chunk_size;
		data_pointer += chunk_size;
		address   += chunk_size;
	} while (remainder);

If I try to do this with address 0x00000000 I get 0x1010 from FAPI_GET_FSM_STATUS which means that PGV bit is set. What are the reasons for this bit to be set? Is there something I am missing that needs to be done?

Thanks!