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.

EMIF16 NOR TMS320C6678

Other Parts Discussed in Thread: TMS320C6678

Hello All,

In our customized board we are having a BPI NOR Flash(Micron - PC28F00AP30EFx). This chip is connected to both the FPGA and DSP(TMS320C6678).

During the power-up stage the FPGA will boot from the NOR flash and change the signal control to DSP EMIF16.

FPGA can able to write and read the NOR flash. But DSP Can't able to access the Nor Flash.

We are using then CE1 for the NOR Flash through DSP. I have attached the code that we are using to test the setup is attached along with this mail.

ISSUE FACING:

1. DSP cannot able to write and read the NOR Flash through EMIF16.

2. Any changes has to be done in the code that i have attached.

3. Can any sample project to test the EMI16 Nor C6678 is available.

thanks in Advance. Can any one provide any idea or suggestion to solve the issue. As it is very urgent.

Regards,

Avinash N

 

3113.main-new.c
/*
 * main.c
 *
 *  Created on: Apr 27, 2016
 *      Author: cornet
 */
#if 1

#include <stdio.h>

#define FLASH_CE1_ADDRESS 			0x74000000
#define EMIF_CTL_BASE               0x20c00000
#define EMIF_CTL_AWCCR				0x0004
#define EMIF_CTL_A1CR               0x0014
#define EMIF_CTL_IRR				0x0040
#define EMIF_CTL_NANDFCR            0x0060
#define EMIF_CTL_NOR_PMCR           0x0068
#define MANF_ID_OFFSET			    0x0
#define DEV_ID_OFFSET			    0x2
#define UNLOCK_CYCLE_1				0x555
#define UNLOCK_CYCLE_2				0x2AA
#define UInt16  					unsigned short
#define UInt32						unsigned long

/***************/
/* Enable EMIF access for NOR at this chip select  */
/***************/
void norEnableRegion()
{
	unsigned int a1cr,awccr,irr;

	a1cr = *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_A1CR));
	a1cr = a1cr & ~0x03;
	a1cr = a1cr | 0x01;  // NOR is 16-bit
	*((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_A1CR)) = a1cr;

	awccr = *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_AWCCR));
	awccr = awccr | 0xFF;
	*((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_AWCCR)) = awccr;

	irr = (1 | (1 << 2));
	*((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_IRR)) = irr;
}

void FEPB_EMIF16_NOR_WRITE(UInt32 Address, UInt16 value)
{
	UInt16 *ptr ;

	ptr = (UInt16 *) Address;

	*ptr = value;
}

UInt16 FEPB_EMIF16_NOR_READ(UInt32 Address)
{
	UInt16 *ptr,value = 0;

	ptr = (UInt16 *) Address;

	value = *ptr;

	return value;
}

void FEPB_EMIF16_NOR_MF_DEV_ID(UInt32 Address)
{
	UInt16 manuf_id,dev_id;

	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_1 ),0x00AA); /* write unlock cycle 1 */
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_2 ),0x0055); /* write unlock cycle 2 */
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_1 ),0x0090); /* write autoselect command */

	manuf_id = FEPB_EMIF16_NOR_READ(Address + 0x0000 ); /* read manuf. id */

	printf("Manufacturer ID : 0x%x\n",manuf_id);

	dev_id = FEPB_EMIF16_NOR_READ(Address + 0x0002 ); /* read manuf. id */

	printf("Device ID : 0x%x\n",dev_id);

	FEPB_EMIF16_NOR_WRITE((Address + 0x000 ),0x00F0); /* write reset command */
}

void FEPB_EMIF16_NOR_FLASH_RESET(UInt32 Address)
{
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_2), 0x00F0 );
}

void FEPB_EMIF16_NOR_FLASH_DELAY()
{
	UInt32 loop;

	for(loop = 0; loop < 0x10000;loop++);
}

void FEPB_EMIF16_NOR_FLASH_ERASE(UInt32 Address)
{

	UInt32 *addr = (UInt32 *)FLASH_CE1_ADDRESS;

	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_1 ),0x00AA);
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_2 ),0x0055);
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_1 ),0x0080);
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_1 ),0x00AA);
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_2 ),0x0055);
	FEPB_EMIF16_NOR_WRITE((Address ),0x3030);
	FEPB_EMIF16_NOR_FLASH_DELAY();


	while(!(*(addr)&0x00800080));
	addr=(UInt32 *)0xf0f0;

}

void FEPB_EMIF16_NOR_FLASH_TEST_WRITE(UInt32 Address)
{
	UInt32 value = 0;

	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_1 ),0x00AA);
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_2 ),0x0055);
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_1 ),0x00A0);

	FEPB_EMIF16_NOR_WRITE((Address + 0x0010 ),0x1122);

	value = FEPB_EMIF16_NOR_READ(Address + 0x0010);

	printf("0x%x\n",value);

	FEPB_EMIF16_NOR_FLASH_DELAY();
	FEPB_EMIF16_NOR_FLASH_DELAY();
	FEPB_EMIF16_NOR_FLASH_DELAY();
	FEPB_EMIF16_NOR_FLASH_DELAY();
	FEPB_EMIF16_NOR_FLASH_DELAY();

	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_1 ),0x00AA);
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_2 ),0x0055);
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_1 ),0x00A0);

	FEPB_EMIF16_NOR_WRITE((Address + 0x0014 ),0x1122);

	value = FEPB_EMIF16_NOR_READ(Address + 0x0014);

	printf("0x%x\n",value);

	FEPB_EMIF16_NOR_FLASH_DELAY();
	FEPB_EMIF16_NOR_FLASH_DELAY();
	FEPB_EMIF16_NOR_FLASH_DELAY();
	FEPB_EMIF16_NOR_FLASH_DELAY();
	FEPB_EMIF16_NOR_FLASH_DELAY();

	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_1 ),0x00AA);
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_2 ),0x0055);
	FEPB_EMIF16_NOR_WRITE((Address + UNLOCK_CYCLE_1 ),0x00A0);

	FEPB_EMIF16_NOR_WRITE((Address + 0x0018 ),0x1122);

	value = FEPB_EMIF16_NOR_READ(Address + 0x0018);

	printf("0x%x\n",value);

	FEPB_EMIF16_NOR_WRITE((Address),0x00F0);


}

int main()
{

	UInt32 loop = 0,i = 0;

	/*Enabling the EMIF-16 NOR Device*/
	norEnableRegion();

	printf("Entering EMIF16 BPI NOR FLASH\n");

	FEPB_EMIF16_NOR_MF_DEV_ID((UInt32)FLASH_CE1_ADDRESS);

	FEPB_EMIF16_NOR_FLASH_TEST_WRITE((UInt32)FLASH_CE1_ADDRESS);

}
#endif