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.

the START number in uPP Transmission of c6748

Other Parts Discussed in Thread: OMAPL138

Now I am using c6748 to transmit and receive data to and from  FPGA.When DSP send data to FPGA,,there has one line in window, but 2 START pulse can be watch ,what's the reason for this? 

=============my dsp code====================

void upp_set(uint16_t * recv_addr) //upp port set
{
upp_config_t upp_config;//init upp part use
//upp reg set

//config UPCTL---uPP Channel Control Register (UPCTL)
upp_config.UPCTL.bits.IWA = 0x01; //interface wide of CHA = 16位数据总线
upp_config.UPCTL.bits.IWB = 0x01; //interface wide of CHB = 16位数据总线 add by wh 20140211
upp_config.UPCTL.bits.DPWA = 0; //设置A通道对齐模式
upp_config.UPCTL.bits.DPWB = 0; //设置B通道对齐模式 add by wh 20140211
upp_config.UPCTL.bits.CHN = 1; //使用A通道和B通道组建双向通道 add by wh 20140211
upp_config.UPCTL.bits.MODE = 2; //双向通讯模式,A通道接收,B通道发送 add by wh 20140211

upp_config.UPCTL.bits.DRA = 0; //设置A通道为单倍数据传输速度double data rate--add by wh 20140328 PMU 用单速率方式
upp_config.UPCTL.bits.DRB = 0; //设置B通道为单倍数据传输速度double data rate
upp_config.UPCTL.bits.DDRDEMUX = 0; //Each peripheral channel is associated with its own DMA channel.

//config UPICR ---uPP Interface Configuration Register (UPICR)
upp_config.UPICR.bits.ENAA = 0x01;//使能CHA的ENABLE信号(接收模式)
upp_config.UPICR.bits.STARTA = 0x01;//使能CHA的START信号(接收模式)
upp_config.UPICR.bits.ENAB = 0x01;//使能CHB的ENABLE信号(发送模式)add by wh 20140211
upp_config.UPICR.bits.STARTB = 0x01;//使能CHB的START信号(发送模式)add by wh 20140211
upp_config.UPICR.bits.WAITB = 0x01;//使能CHB的WAIT信号(发送模式)add by wh 20140211
upp_config.UPICR.bits.CLKDIVB =0x01;//CHB的clock 2分频 clockin/(2*(CLKDIVB+1))= 456/2/(2(1+1))=57 双倍速率为114MHz
add by wh 20140211

//config UPTCR---uPP Threshold Configuration Register (UPTCR)

upp_config.UPTCR.bits.RDSIZEI = 3;//Read threshold for DMA Channel I. Controls burst size for DMA Channel I.

//0h-64B,1h-128B,2h-reserved,3h-256B
upp_config.UPTCR.bits.TXSIZEB = 3; //设置通道B的发送大小门槛为256Byte add by wh 20140211
//0h-64B,1h-128B,2h-reserved,3h-256B

//config UPIES---uPP Interrupt Enabled Status Register (UPIER)
upp_config.UPIES.bits.EOLI= 0x01; //turn on EOL(end of line) interrupt for CHA(DMA channel I)
upp_config.UPIES.bits.EOWI= 0x01; //turn on EOW(end of window)interrupt for CHA(DMA channel I)
upp_config.UPIES.bits.EOLQ= 0x01; //turn on EOL(end of line) interrupt for CHB(DMA channel Q)add by wh 20140211
upp_config.UPIES.bits.EOWQ= 0x01; //turn on EOW(end of window)interrupt for CHB(DMA channel Q)add by wh 20140211

upp_config.UPPCR.bits.EN = 0x01; //Set the EN bit in the uPP peripheral control register (UPPCR) to 1 to turn on
the uPP peripheral.
//UPISR---uPP Interrupt Raw Status Register (UPISR) 中断状态寄存器

UPP_init(&upp_config);//初始化UPP口

}

===========================================

收发寄存器设置:

while(CHKBIT(UPP->UPIS2, 0x00000002)){};
UPP->UPID0 = (uint32_t)&upp_data_recv[0]; //接收缓冲区
UPP->UPID1 = 0x00040800; //4 lines per window 256*4 words per line
UPP->UPID2 = 0x00000800;
UPP->UPID2 = 0x00000800;

UPP->UPQD0 = (uint32_t)&upp_data_send; //发送缓冲区
UPP->UPQD1 = 0x00010800; //1 lines per window ,256*4 words per line
UPP->UPQD2 = 0x00000800;
UPP->UPQD2 = 0x00000800;

目前在调试TMS320VC6748 dsp,使用UPP口与FPGA接口,使用CHA从FPGA接收数据到DSP内计算,将计算结果通过UPP口的CHB通道发送 给FPGA;

遇到的问题:CHB发送时,在FPGA侧每个ENABLE信号为高期间,会有2个START信号,明显不符合时序,这是什么原因?

我自己分析可能与如下设置有关:

upp_config.UPTCR.bits.TXSIZEB = 3; //设置通道B的发送大小门槛为256Byte add by wh 20140211
//0h-64B,1h-128B,2h-reserved,3h-256B

是不是每次发送256Byte就会有一个START脉冲?通过调整发送窗口的总量,及TXSIZEB的设置值,好像没有什么规律,请各位大神
帮忙分析一下啊。

  • Hi Hong,

    This seems misconfiguration of uPP peripheral,

    Is this own code or provided by TI?

    If TI provided, Have you modified the code?

    In your project, Are the uPP peripheral want to communicate to FPGA (Rxx as well Rx through different channel) ?

    Correct me if I'm  wrong,

    I'm checking your configurations,

  • Hi,

    From your uPP configuration,

    I presume that you are using "Duple mode 0"  ie CHA = Rx  & CHB = Tx

    Correct me if I'm wrong.

    upp_config.UPICR.bits.STARTA = 0x01;//使能CHA的START信号(接收模式)
    upp_config.UPICR.bits.ENAB = 0x01;//使能CHB的ENABLE信号(发送模式)add by wh 20140211
    upp_config.UPICR.bits.STARTB = 0x01;//使能CHB的START信号(发送模式)add by wh 20140211

    I'm suspecting the UPICR configuration, I think that you have configured & enabled the START signal for both the channels CHA as well CHB,

    Please refer the chapter 33.3.5 in TRM of OMAPL138

    STARTA

    0 - START signal is disabled. Channel A ignores START in receive mode.
    1 - START signal is enabled. Channel A honors START in receive mode.

    STARTB

    0 - START signal is disabled. Channel B ignores START in receive mode.
    1 - START signal is enabled. Channel B honors START in receive mode.

  • Dear  

               Thanks a lot for your reply!

    I am using "Duple mode 0" mode,set CHA = Rx  & CHB = Tx;

     I have changed my UPICR configuration,but there is no change, 2 START signal  still  there.

    //upp_config.UPICR.bits.STARTA = 0x01;//使能CHA的START信号(接收模式)
    upp_config.UPICR.bits.ENAB = 0x01;//使能CHB的ENABLE信号(发送模式)add by wh 20140211
    //upp_config.UPICR.bits.STARTB = 0x01;//使能CHB的START信号(发送模式)add by wh 20140211

    It is quitely strange.

        best  regard !

               

  • Dear  

               Thanks a lot for your reply!

               The code is modified from OMAPL138 example code.

     best rregards! 

  • My code:

    //-----------------------------------------------------------------------------
    // \file    main.c
    // \brief   implementation of main() to test bsl drivers.
    //
    //-----------------------------------------------------------------------------
    #include "stdio.h"
    #include "types.h"
    #include "evmomapl138.h"
    #include "evmomapl138_uPP.h"
    #include "ys_c6748_define.h"
    #include "evmomapl138_emac.h"
    #include "ys_c6748_cache.h"
    #include "evmomapl138_timer.h"
    
    //#include "ys_faultcal.h"
    //#include "evmomapl138_timer.h"
    //#include "evmomapl138_i2c.h"
    
    //#include "test_rtc.h"
    
    //-----------------------------------------------------------------------------
    // Private Defines and Macros
    //-----------------------------------------------------------------------------
    // uncomment this define if running without gel initialization.
    // #define NO_GEL    (1)
    
    //-----------------------------------------------------------------------------
    // Static Variable Declarations
    //-----------------------------------------------------------------------------
    
    //-----------------------------------------------------------------------------
    // Private Function Prototypes
    //-----------------------------------------------------------------------------
    
    //-----------------------------------------------------------------------------
    // Public Function Definitions
    //-----------------------------------------------------------------------------
    
    //-----------------------------------------------------------------------------
    // \brief   entry point for bsl test code.
    //
    // \param   none.
    //
    // \return  none.
    //-----------------------------------------------------------------------------
    extern cregister volatile unsigned int AMR;     /* Address Mode Register      */
    extern cregister volatile unsigned int CSR;     /* Control Status Register    */
    extern cregister volatile unsigned int IFR;     /* Interrupt Flag Register    */
    extern cregister volatile unsigned int ISR;     /* Interrupt Set Register     */
    extern cregister volatile unsigned int ICR;     /* Interrupt Clear Register   */
    extern cregister volatile unsigned int IER;     /* Interrupt Enable Register  */
    extern cregister volatile unsigned int ISTP;    /* Interrupt Service Tbl Ptr  */
    extern cregister volatile unsigned int IRP;     /* Interrupt Return Pointer   */
    extern cregister volatile unsigned int NRP;     /* Non-maskable Int Return Ptr*/
    extern cregister volatile unsigned int IN;      /* General Purpose Input Reg  */
    extern cregister volatile unsigned int OUT;     /* General Purpose Output Reg */
    
    extern void intcVectorTable (void);            // Add this to top of file
    
    extern uint16_t g_param_recv_count;//��ֵ���մ�������
    #pragma DATA_SECTION(upp_data_recv,".smpbuf")//progbuf/smpbuf/cache2
    uint16_t upp_data_recv[UPP_RECV_BUF_LENGTH][1024];//UPP recv BUF, UPP_RECV_BUF_LENGTH/32768000
    #pragma DATA_SECTION(upp_data_send,".smpbuf")//UPP���ݷ��ͻ����� add by wh 20140212
    //uint16_t upp_data_send[1024];//
    uint16_t upp_data_send[UPP_RECV_BUF_LENGTH][1024];//
    
    //add by wh 20130428
    #pragma DATA_SECTION(upp_kg_last1,".smpbuf")
    uint16_t upp_kg_last1[4][RECV_KG_LENGTH];//ÿ��UPP�ж���4��������ݣ�ռ��4x12��word
    #pragma DATA_SECTION(upp_kg_last2,".smpbuf")
    uint16_t upp_kg_last2[4][RECV_KG_LENGTH];//ÿ��UPP�ж���4��������ݣ�ռ��4x12��word
    //volatile
    volatile uint32_t g_int_count=0;
    volatile uint32_t g_int_count_old=0;//add by wh 20120905 �����ж�UPP�ж��Ƿ�������������upp�жϼ���g_int_count�ޱ仯��˵��UPP�������⣬��Ҫ�澯;
    volatile uint32_t g_slide_count=0;
    volatile uint32_t g_thiscnt=0;
    volatile uint32_t g_nowcnt=0;
    volatile uint32_t g_uppsendflag=0;
    volatile uint32_t g_uppsendcnt=0;
    
    
    uint32_t upp_err_cnt=0;
    uint16_t g_send_idx=0;//���ͻ�������ţ� 0~3200��RE_SEND_BUF_LENGTH=3200 ��1������ݣ�
    
    
    //uint32_t lostcntraw[1000];
    //uint32_t lost_seq[1000];
    //uint8_t nandflashdata[1000];//test nandflash
    uint16_t m=0;
    uint16_t g_judge_times=0;//�����ۼƼ򱨷��͵�ʱ�����Լ20ms���ҷ��μ򱨣�����򱨹��ࡣby����
    uint16_t g_while_times=0;
    uint16_t g_while_times2=0;
    
    
    int main(void)
    {
    	
    	uint32_t rtn, j,i=0;	
    //	board_init();
    //��ʼ��UPP���պͷ��ͻ�������ֵ
    	for(j=0;j<UPP_RECV_BUF_LENGTH;j++) 
    		{
    			memset(upp_data_recv[j],0,2048);// ��0
    			memset(upp_data_send[j],1,2048);// ��0
    //			for(i=0;i<1024;i++)
    //			upp_data_send[j][i]=j;// �ù�����
    		}
    //	memset(upp_data_send,0,2048);// ��0	
    	UPP->UPID0 = 0;//clear UPID0 //(uint32_t)&upp_data_recv[0];
    	UPP->UPID1 = 0;//clear UPID1
    	UPP->UPID2 = 0;//clear UPID2
    	UPP->UPQD0 = 0;//clear UPQD0 //(uint32_t)&upp_data_send[0];
    	UPP->UPQD1 = 0;//clear UPQD1
    	UPP->UPQD2 = 0;//clear UPQD2
       //��ʼ��
       	EVMOMAPL138_enableDsp();
     	//clk inital
       	EVMOMAPL138_init();
     	//ram inital
       	EVMOMAPL138_initRAM();
    
      	CSR &= ~0x01;   // intrrupt gloabe GIE disabel    //ISTP = (uint32_t)vectors;   ---1
    	EVTCLR0 &= ~0xFFFFFFFF;    //----2
    	EVTCLR1 &= ~0xFFFFFFFF;
    	EVTCLR2 &= ~0xFFFFFFFF;
    	EVTCLR3 &= ~0xFFFFFFFF;
    	
    	//set HW_INT4 for UPP   
        INTMUX1 &= ~0xFFFF;   // clear out INTSEL4 field
        INTMUX1 |= 94;      // INTSEL4=94
        //set HW_INT9 for TIME1   
        INTMUX2 &= ~0xFFFF;
        INTMUX2 |= 48<<8;   // INTSEL9= timer1-34 int
       	//set HW_INT12 for TIME0   
        INTMUX3 &= ~0xFFFF;
        INTMUX3 |= 64;   // INTSEL12= timer0-34 int
       	ISTP = (unsigned int)intcVectorTable;  //-----4
       	ICR = 0xFFF0;
       	IER |= 0x00001213;   // IE4=1ʹ���ж�4 ;NMIE=1ʹ�����з������ж�
    						 // IE9=1 
    						 // IE12=1
    //    IER |= 0x00000013;
       						 
     	CSR |= 0x00000001;   // intrrupt gloabe enabel   -----6
       	//timer initial
       	USTIMER_init();
       	upp_set(upp_data_recv[0]);//UPP set;
    
    	while(CHKBIT(UPP->UPIS2, 0x00000002)){};
    	UPP->UPID0 = (uint32_t)&upp_data_recv[0];
    	UPP->UPID1 = 0x00040800;  //1 lines 256*4 words per line 0x200--512byte
    	UPP->UPID2 = 0x00000800; 
    	UPP->UPID2 = 0x00000800;
    	
    	UPP->UPQD0 = (uint32_t)&upp_data_send;
    	UPP->UPQD1 = 0x00010800;  //����1�����ݣ�256*4 words per line 
    	UPP->UPQD2 = 0x00000800; 
    	UPP->UPQD2 = 0x00000800;
    	
    	IO1_HIGH//initial IO1=1
    	//initial ETH
    	rtn = EMAC_init(EMAC_INTERFACE_MII);//EMAC_INTERFACE_RMII
    	//GPIO initial
    	GPIO_init();//GPIO initial
    	//NandFlash initial
    	NAND_init();//for test nandflash
    
    
    //�忨��ʼ��
    
    	while(1)
    	{		
    		
    		
    		
    		if(g_while_times2 !=g_while_times && g_judge_times == 0)
    		{
    			g_while_times2 = g_while_times;
    //			IO_LOW
    		 	//KgFaultCal();//���㿪�����оݣ�Ϊ��֤���������ȣ����ڶ�ʱ������㡣
    //			IO_HIGH
    		}
     		
          asm(" nop");
    	}
    }
    /*******************************************************
    *�������ƣ�timer0�жϷ������ISR 
    ********************************************************/
    
    uint16_t i=0;
    uint32_t sec2_count=0;//2�������ÿ2�뷢��һ�θ澯��Ϣ
    uint16_t upp_i=0,upp_j=0,upp_up=0;
    interrupt void timer0_isr(void)//timer0 interrupt ISR
    {
    	
    //		upp_up++;
    //		for(upp_i=0;upp_i<4;upp_i++)
    //		{
    //			for(upp_j=0;upp_j<1024;upp_j++)
    //				upp_data_send[upp_i][upp_j]=upp_up;// �ù�����
    //		}
    //		UPP->UPQD0 = (uint32_t)&upp_data_send[0];
    //		UPP->UPQD1 = 0x00040800;  //����1�����ݣ�256*4 words per line 
    //		UPP->UPQD2 = 0x00000800; 
    //		UPP->UPQD2 = 0x00000800;
    		
    		
    		
    //IO_LOW
    
    //IO_HIGH
     	return;
    }
    /*******************************************************
    *�������ƣ�timer1�жϷ������ISR 
    ********************************************************/
    //timer1�жϷ������ISR --Interrupt severice rotine
    
    uint16_t Fault_cnt=0;
    uint16_t upp_send_index=0;
    
    interrupt void timer1_isr(void)//timer1 interrupt ISR
    {
    		if(g_uppsendflag &&(g_int_count/2!=g_uppsendcnt))//upp�������
    		{
    //			for(upp_j=0;upp_j<1024;upp_j++)
    //				upp_data_send[0][upp_j]=upp_j+upp_up;// �ù�����
    //			for(upp_j=0;upp_j<1024;upp_j++)
    //				upp_data_send[1][upp_j]=upp_j+upp_up+1024;// �ù�����
    //			for(upp_j=0;upp_j<1024;upp_j++)
    //				upp_data_send[2][upp_j]=upp_j+upp_up+2048;// �ù�����
    //			for(upp_j=0;upp_j<1024;upp_j++)
    //				upp_data_send[3][upp_j]=upp_j+upp_up+3072;// �ù�����
    //			upp_up +=4096;
    			UPP->UPQD0 = (uint32_t)&upp_data_send;
    			UPP->UPQD1 = 0x00010800;  //����1�����ݣ�256*4 words per line 
    			UPP->UPQD2 = 0x00000800; 
    			UPP->UPQD2 = 0x00000800; 
    			g_uppsendflag =0;
    //			g_int_count_old = g_int_count;
    			g_uppsendcnt++;
    		}
    	return;	
    }
    //upp�жϷ������ISR --Interrupt severice rotine
    interrupt void upp_isr(void)
    {
    
      UPISR_t interrupt_status;
      interrupt_status.value = UPP->UPIER;
      while (interrupt_status.value != 0)
      {
        if (interrupt_status.bits.EOLI)
        {
    		//interrupt_status.bits.EOLI = 1; // clear EOLI
    		UPP->UPIER |= (0x10);//clear EOLI bit in UPIER
        	if (interrupt_status.bits.EOWI)
        	{
    		    UPP->UPIER |= (0x08);
    		    UPP->UPID0 = (uint32_t)&upp_data_recv[0];//[0+g_count.m_UppIntCount*256];//add next DMA transfer
    			UPP->UPID1 = 0x00040800;  //1 lines 256*4 words per line 0x200--512byte
    			UPP->UPID2 = 0x00000800; 
       		}
        	//interrupt times count
        	g_int_count++;//			
    	}
    	if (interrupt_status.bits.DPEI)
        {
    		//interrupt_status.bits.DPEI = 1; // clear DPEI
    		UPP->UPIER |=(0x01);//clear DPEI bit in UPIER
    		// Handle DPEI...
    	}
    	if(interrupt_status.bits.EOLQ)
    	{
    		UPP->UPIER |=(0x1000);//�� EOLQ bit in UPIER Ϊ1 ������������жϣ�
    	}
    	if(interrupt_status.bits.EOWQ)
    	{
    		UPP->UPIER |=(0x0800);//�� EOLQ bit in UPIER Ϊ1 ��������ʹ����жϣ�
    		if(!g_uppsendflag)
    			g_uppsendflag = 1;
    //		if(g_int_count&2)//upp�ж�2�Σ�����һ��
    		{
    //			for(upp_j=0;upp_j<1024;upp_j++)
    //				upp_data_send[0][upp_j]=upp_j+upp_up;// �ù�����
    //			for(upp_j=0;upp_j<1024;upp_j++)
    //				upp_data_send[1][upp_j]=upp_j+upp_up+1024;// �ù�����
    //			for(upp_j=0;upp_j<1024;upp_j++)
    //				upp_data_send[2][upp_j]=upp_j+upp_up+2048;// �ù�����
    //			for(upp_j=0;upp_j<1024;upp_j++)
    //				upp_data_send[3][upp_j]=upp_j+upp_up+3072;// �ù�����
    //			upp_up +=4096;
    //			UPP->UPQD0 = (uint32_t)&upp_data_send;
    //			UPP->UPQD1 = 0x00040800;  //����1�����ݣ�256*4 words per line 
    //			UPP->UPQD2 = 0x00000800; 
    //			UPP->UPQD2 = 0x00000800; 
    			
    		}
    	}
    	if (interrupt_status.bits.DPEQ)
    	{
    		UPP->UPIER |=(0x0100);//�� DPEQ bit in UPIER Ϊ1 ���������DPEQ��
    	}
    
        // loop again if any interrupts are left
        interrupt_status.value = UPP->UPIER;
      } // end of while
      // write end of interrupt vector to allow future calls
      UPP->UPEOI = 0;
    // //close led
     } // end of function
     
    /*////////////////////////////////////////////////////////////////////////////////////////////////
    //upp�жϷ������ISR --Interrupt severice rotine
    interrupt void upp_isr(void)
    {
    	UPISR_t interrupt_status;
    	interrupt_status.value = UPP->UPIER;
    	while(interrupt_status.value != 0)
    	{
    		if (interrupt_status.bits.EOLI)
    		{
    			
    			UPP->UPIER.value.EOLI= 1; // clearEOLI
    			// Handle EOLI...
    		}
    		if (interrupt_status.bits.EOWI)
    		{
    			UPP->UPIER.EOWI= 1; // clearEOWI
    			// Handle EOWI...
    			UPP->UPIER |= (0x08);
    		    UPP->UPID0 = (uint32_t)&upp_data_recv[0];//[0+g_count.m_UppIntCount*256];//add next DMA transfer
    			UPP->UPID1 = 0x00040800;  //1 lines 256*4 words per line 0x200--512byte
    			UPP->UPID2 = 0x00000800; 
    			
    			g_int_count++;//
    		}
    		if (interrupt_status.bits.ERRI)
    		{
    			UPIER.ERRI= 1; // clearERRI
    			// Handle ERRI...
    		}
    		if (interrupt_status.bits.UORI)
    		{
    			UPIER.UORI= 1; // clearUORI
    			// Handle UORI...
    		}
    		if (interrupt_status.bits.DPEI)
    		{
    			UPIER.DPEI= 1; // clearDPEI
    			// Handle DPEI...
    		}
    		if (interrupt_status.bits.EOLQ)
    		{
    			UPIER.EOLQ= 1; // clearEOLQ
    			// Handle EOLQ...
    		}
    		if (interrupt_status.bits.EOWQ)
    		{
    			UPIER.EOWQ= 1; // clearEOWQ
    			// Handle EOWQ...
    		}
    		if (interrupt_status.bits.ERRQ)
    		{
    			UPIER.ERRQ= 1; // clearERRQ
    			// Handle ERRQ...
    		}
    		if (interrupt_status.bits.UORQ)
    		{
    			UPIER.UORQ= 1; // clearUORQ
    			// Handle UORQ...
    		}
    		if (interrupt_status.bits.DPEQ)
    		{
    			UPIER.DPEQ= 1; // clearDPEQ
    			// Handle DPEQ...
    		}
    		// loop againif any interruptsare left
    		interrupt_status = UPIER;
    	} // end of while
    	// writeend of interrupt vector to allowfuture calls
    	UPP->UPEOI= 0;
    } // end of function
    *////////////////////////////////////////////////////////////////////////////////////////////////
     

    //-----------------------------------------------------------------------------
    // \file    evmomapl138.c
    // \brief   implementation of initialization functions for OMAP-L138.
    //
    //-----------------------------------------------------------------------------
    
    #include "types.h"
    #include "evmomapl138.h"
    #include "evmomapl138_ddr.h"
    #include "evmomapl138_sysconfig.h"
    //#include "evmomapl138_i2c_gpio.h"
    
    #ifdef DEBUG
    #include "stdio.h"
    #endif
    
    //-----------------------------------------------------------------------------
    // Private Defines and Macros
    //-----------------------------------------------------------------------------
    
    #define PINMUX_GPIO_UI_IO_EXP_REG   (6)
    #define PINMUX_GPIO_UI_IO_EXP_MASK  (0x0000000F)
    #define PINMUX_GPIO_UI_IO_EXP_VAL   (0x00000008)
    #define GPIO_UI_IO_EXP_BANK         (2)
    #define GPIO_UI_IO_EXP_PIN          (7)
    
    //-----------------------------------------------------------------------------
    // Global Variable Initializations
    //-----------------------------------------------------------------------------
    const uint32_t bitval_u32[32] =  // ����������
    {
       0x00000001, 0x00000002, 0x00000004, 0x00000008,
       0x00000010, 0x00000020, 0x00000040, 0x00000080,
       0x00000100, 0x00000200, 0x00000400, 0x00000800,
       0x00001000, 0x00002000, 0x00004000, 0x00008000,
       0x00010000, 0x00020000, 0x00040000, 0x00080000,
       0x00100000, 0x00200000, 0x00400000, 0x00800000,
       0x01000000, 0x02000000, 0x04000000, 0x08000000,
       0x10000000, 0x20000000, 0x40000000, 0x80000000
    };
    
    //-----------------------------------------------------------------------------
    // Static Variable Declarations
    //-----------------------------------------------------------------------------
    
    //-----------------------------------------------------------------------------
    // Private Function Prototypes
    //-----------------------------------------------------------------------------
    static uint32_t init_psc(void);
    static uint32_t init_clocks(void);
    
    //-----------------------------------------------------------------------------
    // Public Function Definitions
    //-----------------------------------------------------------------------------
    
    //-----------------------------------------------------------------------------
    // \brief   initializes psc, pll, and pinmuxes.
    //
    // \param   none.
    //
    // \return  uint32_t
    //    ERR_NO_ERROR - everything is ok...cpu ready to use.
    //    ERR_INIT_FAIL - something happened during initialization.
    //-----------------------------------------------------------------------------
    void upp_set(uint16_t * recv_addr) //upp port set
    {
    	
    	upp_config_t  upp_config;//init upp part use
    //upp reg set
    	//config UPDLB---uPP Digital Loopback Register(UPDLB) �����Ի��Ĵ�����B���ͣ�A����
    //	upp_config.UPDLB.bits.BA = 0x01;//ʹ��B��A���ͣ����ڲ���
    //	upp_config.UPDLB.bits.AB = 0;   //�ر�A��B���ͣ����ڲ���
    	//config UPCTL---uPP Channel Control Register (UPCTL)
    	upp_config.UPCTL.bits.IWA = 0x01;	//interface wide of CHA = 16�������
    	upp_config.UPCTL.bits.IWB = 0x01;	//interface wide of CHB = 16������� add by wh 20140211
    	upp_config.UPCTL.bits.DPWA = 0;     //����Aͨ������ģʽ
    	upp_config.UPCTL.bits.DPWB = 0;     //����Bͨ������ģʽ add by wh 20140211
    	upp_config.UPCTL.bits.CHN = 1;	    //ʹ��Aͨ����Bͨ���齨˫��ͨ�� add by wh 20140211
    	upp_config.UPCTL.bits.MODE = 2;	    //˫��ͨѶģʽ��Aͨ�����գ�Bͨ������ add by wh 20140211 
    
    	upp_config.UPCTL.bits.DRA = 0;	//����Aͨ��Ϊ�������ݴ����ٶ�double data rate--add by wh 20140328 PMU �õ����ʷ�ʽ
    	upp_config.UPCTL.bits.DRB = 0;	//����Bͨ��Ϊ�������ݴ����ٶ�double data rate
    	upp_config.UPCTL.bits.SDRTXIL =0; //��������ʱ���ý���ģʽ add by wh 20140403
    	upp_config.UPCTL.bits.DDRDEMUX = 0; //˫������ʱ���ý���ģʽ add by wh 20140403	//Each peripheral channel is associated with its own DMA channel.
    
    	//config UPICR ---uPP Interface Configuration Register (UPICR)
    	upp_config.UPICR.bits.ENAA = 0x01;//ʹ��CHA��ENABLE�ź�(����ģʽ)
    //	upp_config.UPICR.bits.STARTA = 0x00;//ʹ��CHA��START�ź�(����ģʽ)
    	upp_config.UPICR.bits.ENAB = 0x01;//ʹ��CHB��ENABLE�ź�(����ģʽ)add by wh 20140211
    //	upp_config.UPICR.bits.STARTB = 0x00;//ʹ��CHB��START�ź�(����ģʽ)add by wh 20140211
    	upp_config.UPICR.bits.WAITB = 0x01;//ʹ��CHB��WAIT�ź�(����ģʽ)add by wh 20140211
    	upp_config.UPICR.bits.CLKDIVB =0x01;//CHB��clock 2��Ƶ  clockin/(2*(CLKDIVB+1))= 456/2/(2(1+1))=57 ˫������Ϊ114MHz  add by wh 20140211
    	
    	//config UPIVR---uPP Interface Idle Value Register (UPIVR)  �����ÿ���ʱA,B�����ϵ�ȱʡֵ add by wh 20140211
    	//config UPTCR---uPP Threshold Configuration Register (UPTCR)
    	upp_config.UPTCR.bits.RDSIZEI = 3;//Read threshold for DMA Channel I. Controls burst size for DMA Channel I.
    										   //0h-64B,1h-128B,2h-reserved,3h-256B
    	upp_config.UPTCR.bits.TXSIZEB = 3;   //����ͨ��B�ķ��ʹ�С�ż�Ϊ256Byte add by wh 20140211
    	                                       //0h-64B,1h-128B,2h-reserved,3h-256B
    //	upp_config.UPTCR.bits.RDSIZEI =0;
    //	upp_config.UPTCR.bits.RDSIZEQ =0;                                      
    	//config UPIES---uPP Interrupt Enabled Status Register (UPIER)
    	upp_config.UPIES.bits.EOLI= 0x01;	//turn on EOL(end of line) interrupt for CHA(DMA channel I)
    	upp_config.UPIES.bits.EOWI= 0x01;	//turn on EOW(end of window)interrupt for CHA(DMA channel I)
    	upp_config.UPIES.bits.EOLQ= 0x01;	//turn on EOL(end of line) interrupt for CHB(DMA channel Q)add by wh 20140211
    	upp_config.UPIES.bits.EOWQ= 0x01;	//turn on EOW(end of window)interrupt for CHB(DMA channel Q)add by wh 20140211
    	
    	upp_config.UPPCR.bits.EN = 0x01;  //Set the EN bit in the uPP peripheral control register (UPPCR) to 1 to turn on the uPP peripheral.
    	//UPISR---uPP Interrupt Raw Status Register (UPISR) �ж�״̬�Ĵ���
    
    //upp DMA set
    	//UPID0 set ---uPP DMA Channel I Descriptor 0 Register (UPID0)
    //	upp_config.UPID0 = (uint32_t) recv_addr[0];//recv_addr:UPP��DMA�������ݴ�ŵĵ�ַ
    ////	upp_config.UPID1 = 0x00100800;  //4 lines 512 bytes per line  0x00030080;
    ////	upp_config.UPID2 = 0x00000800;  //no offset between lines
    //	upp_config.UPID1 = 0x7d000800;  //4 lines 512 bytes per line  0x00030080;
    //	upp_config.UPID2 = 0x00000800;  //no offset between lines
    
    	//UPID1 set ---uPP DMA Channel I Descriptor 1 Register (UPID1)
    //	upp_config.UPID1 = ((UPP_DMA_LINE_NUM<<16)+(UPP_DMA_BYTE_NUM_PER_LINE<<1));	//0:0;1~15:BCNTH ---DMA����ÿ���ֽ���;16~31:LNCNT---DMA���������
    	//UPID2 set ---uPP DMA Channel I Descriptor 2 Register (UPID2)
    //	upp_config.UPID2 = (UPP_DMA_LINE_OFFSET_ADDR <<3) ;//UPP DMA��ƫ�Ƶ�ַ
    	UPP_init(&upp_config);//��ʼ��UPP��
    }
    
    uint32_t EVMOMAPL138_init(void)//��ʼ��PSC��PLL
    {
       uint32_t rtn = 0,test_value=0;
    
       // configure power, sysconifg, and clocks.
       rtn = init_psc();
       test_value = SYSCONFIG->BOOTCFG;//test by wh
       SETBIT(SYSCONFIG->CFGCHIP[0], PLL0_MASTER_LOCK);
       SYSCONFIG->KICKR[0] = KICK0R_UNLOCK;
       SYSCONFIG->KICKR[1] = KICK1R_UNLOCK;
       rtn |= init_clocks();
       
       if (rtn)
          return (ERR_INIT_FAIL);
       else
          return (ERR_NO_ERROR);
    }
    
    //-----------------------------------------------------------------------------
    // \brief   initializes ram on EMIFB.
    //
    // \param   none.
    //
    // \return  uint32_t
    //    ERR_NO_ERROR - everything is ok...ram ready to use.
    //    ERR_INIT_FAIL - something happened during initialization.
    //-----------------------------------------------------------------------------
    uint32_t EVMOMAPL138_initRAM(void)//��ʼ��RAM
    {
       uint32_t rtn = 0;
       
       // unlock the system config registers and set the ddr 2x clock source.
       SYSCONFIG->KICKR[0] = KICK0R_UNLOCK;
       SYSCONFIG->KICKR[1] = KICK1R_UNLOCK;
       CLRBIT(SYSCONFIG->CFGCHIP[3], CLK2XSRC);	//	�ֲ���CFGCHIP��bit3��Ч
       
       // enable emif3a clock. //PSC������ʱ�Ӻ͸�λ��������Ҫ����RAMʱ��
       EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_EMIF3A, PSC_ENABLE);
       
       // check if vtp calibration(��) is enabled. //voltage temperature procese = VTP
       if (CHKBIT(VTPIO_CTL, 0x00000040))
       {
          // vtp cal disabled, begin cal.
    
          // enable input buffer and vtp.
          SETBIT(VTPIO_CTL, 0x00004000);//bit14:IOPWRDN
          CLRBIT(VTPIO_CTL, 0x00000040);//bit6 :POWERDN
          
          // pulse clrz to init vtp cal.
          SETBIT(VTPIO_CTL, 0x00002000);//bit13:CLKRZ
          CLRBIT(VTPIO_CTL, 0x00002000);
          SETBIT(VTPIO_CTL, 0x00002000);
          
          // poll ready bit to wait for cal to complete.
          while (!CHKBIT(VTPIO_CTL, 0x00008000)) {} //�ȴ���������//bit15: READY
          
          // set lock and power save bits.
          SETBIT(VTPIO_CTL, 0x00000180);  //bit7:LOCK bit8:PWRSAVE
       }
    //*****************************************************
    	   DDR->DDRPHYCTL1 = 0x000000C4;
    	   CLRBIT(SYSCONFIG1->DDR_SLEW,0x00000030 );//clear DDR_PDENA (bit5) and CMOSEN(bit4)
    	   SETBIT(DDR->SDCR, 0x00800000);//unlock BOOTUNLOCKλ
    //	   SETBIT(DDR->SDCR, 0x00008000); //unlock TIMUNLOCK
    	   
    	   DDR->SDCR = 0x0013C632; //����SDCR
    // 		   (0x0               << 27)  |  // DDR2TERM1  //Ӧ��Ϊ0
    // 		   (0x0               << 26)  |  // IBANK_POS  //Ӧ��Ϊ0,-������ַģʽ
    // 		   (0x0               << 25)  |  // MSDRAMEN  //ʹ��mDDR�����ʹ�õ���DDR2������0
    // 		   (0x0               << 24)  |  // DDRDRIVE1
    // 		   (0x0               << 23)  |  // BOOTUNLOCK
    // 		   (0x0               << 22)  |  // DDR2DDQS:1 line
    // 		   (0x0               << 21)  |  // DDR2TERM0
    // 		   (0x1               << 20)  |  // DDR2EN   
    // 		   (0x0               << 19)  |  // DDRDLL_DIS
    // 		   (0x0               << 18)  |  // DDRDRIVE0
    // 		   (0x1               << 17)  |  // DDREN
    // 		   (0x1               << 16)  |  // SDRAMEN
    // 		   (0x1               << 15)  |  // TIMUNLOCK:unlock timeset reg
    // 		   (0x1               << 14)  |  // NM
    // 		   (0x0               << 12)  |  // Reserved
    // 		   (0x3               << 9)   |  // CL=3 ԽС�ڴ���Ӧcpu���ٶ�Խ��
    // 		   (0x0               << 7)   |  // Reserved
    // 		   (0x3               << 4)   |  // IBANK :8BANK
    // 		   (0x0               << 3)   |  // Reserved
    // 		   (0x2               << 0);     // PAGESIZE :1024
    	  DDR->SDTIMR1 = 0x26923209;//0x20923A89;
    // 		  (((unsigned int) ((97.5 * freq / 1000) - 0.5)) << 25) |  // tRFC = 127.5
    // 		  (((unsigned int) ((18.0 * freq / 1000) - 0.5)) << 22) |  // tRP  = 15
    // 		  (((unsigned int) ((18.0 * freq / 1000) - 0.5)) << 19) |  // tRCD = 15
    // 		  (((unsigned int) ((15.0 * freq / 1000) - 0.5)) << 16) |  // tWR  = 15
    // 		  (((unsigned int) ((42.0 * freq / 1000) - 0.5)) << 11) |  // tRAS = 45
    // 		  (((unsigned int) ((60.0 * freq / 1000) - 0.5)) << 6)  |  // tRC  = 60
    // 		  (((unsigned int) ((12.0 * freq / 1000) - 0.5)) << 3)  |  // tRRD = 10
    // 		  (EMIF3A_SDTIMR1 & 0x4)                                |  // Reserved
    // 		  (((unsigned int) ((2.0 * freq / 1000) - 0.5))  << 0);    // tWTR = 7.5
    
    	  DDR->SDTIMR2 = 0x4414C722;//0x0015C720;
    // 	      (((unsigned int) ((70000 * freq / 1000) - 1))   << 27)  |  // tRASMAX =70000ns
    // 		  (0x2                                            << 25)  |  // tXP  = 2
    // 		  (0x0                                            << 23)  |  // tODT (Not supported)
    // 		  (((unsigned int) ((120.0 * freq / 1000) - 0.5)) << 16)  |  // tXSNR =tRFC+10=137.5
    // 		  ((200 - 1)                                      << 8)   |  // tXSRD (200 Cycles)
    // 		  ((1 - 1)                                        << 5)   |  // tRTP (1 Cycle)
    // 		  (0x0                                            << 0);     // tCKE =3 
    
    	  CLRBIT(DDR->SDCR, 0x00008000); //lock TIMUNLOCK
    	  DDR->SDCR2 = 0x04;//13 row address line
    	  DDR->SDRCR = 0xC0000492; //0x492=1170  7.8us
    // 		     (0x1                        << 31)  |  // LPMODEN
    //           (0x1                        << 30)  |  // MCLKSTOPEN
    //           (0x0                        << 24)  |  // Reserved
    //           (0x0                        << 23)  |  // SR_PD
    //           (0x0                        << 16)  |  // Reserved
    //           (((unsigned int) ((7.8 * freq) + 0.5))    << 0);     // RR
    //	  
    	  //CLRBIT(DDR->SDCR, 0x00800000);//lock BOOTUNLOCKλ
    // 	  // set ddr2 to sync reset.
    //     SETBIT(DDR->SDRCR, 0xC0000000);
    //*****************************************************
    //   // config ddr timing.
    //    DDR->DDRPHYCTL1 = 0x000000C6; //11000100 EXT_STRBEN =1(bit7),PWRDNEN =1(bit6),RL=6=CL+1
    //    
    //    //DDR->SDCR = 0x0893C532;         //SDCR--SDRAM configuration register 
    // 	DDR->SDCR = 0x0013CA32; //����SDCR
    //    //PAGESIZE=1024,IBANK=8,CL=5,NM=1,TIMUNLOCK=1,
    //    DDR->SDCR &= ((DDR->SDCR & 0xFF0FFFFF) | 0x00800000);//����BOOTUNLOCKλbit23
    //    DDR->SDCR = ((DDR->SDCR & 0xFF0FFFFF) | 0x02000000);//??ʹ��MSDRAMENλbit25 --����mDDR����Ӧ��ʹ��
    //    DDR->SDCR &= (~0x00008000);//����ʱ�����üĴ��� set TIMUNLOCK=0
    //    
    ////    DDR->SDTIMR1 = 0x20923A89;
    //	DDR->SDTIMR1 = 0x26923209;
    ////    DDR->SDTIMR2 = 0x0015C720;
    //    DDR->SDTIMR2 = 0x4414C722;
    //    DDR->SDCR2 = 0x0;
    //    DDR->SDRCR = 0x00000492;//SDRCR--SDRAM refresh control register
    // // set ddr2 to sync reset.
    //    SETBIT(DDR->SDRCR, 0xC0000000);
     //********************************************************************  
     
     
       // sync reset the ddr clock.
       EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_EMIF3A, PSC_SYNCRESET);
      // enable the clock.
       EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_EMIF3A, PSC_ENABLE);
      // disable self refresh.
       CLRBIT(DDR->SDRCR, 0xC0000000);
       DDR->PBBPR =0x00000030;
       
       if (rtn)
          return (ERR_INIT_FAIL);
       else
          return (ERR_NO_ERROR);
    }
    
    //-----------------------------------------------------------------------------
    // \brief   releases the dsp core from reset.
    //
    // \param   none.
    //
    // \return  none.
    //-----------------------------------------------------------------------------
    void EVMOMAPL138_enableDsp(void)
    {
       // power dsp core.
       EVMOMAPL138_lpscTransition(PSC0, DOMAIN0, LPSC_DSP, PSC_ENABLE);
    
       // wake up dsp core and release from reset.
       SETBIT(PSC0->MDCTL[LPSC_DSP], LRST);
    }
    
    //�������Ÿ���--����20��32λ�Ĵ����������ŵĸ��ã�ÿ��32λ�Ĵ�������8���ŵĸ���ѡ��
    //-----------------------------------------------------------------------------
    // \brief   configures the desired pin mux register.
    //
    // \param   uint32_t in_reg - pin mux register to be configured. //0~19
    //
    // \param   uint32_t in_mask - bits to be set in pin mux register.
    //
    // \param   uint32_t in_val - value to set the pin mux register.
    //
    // \return  none.
    //-----------------------------------------------------------------------------
    void EVMOMAPL138_pinmuxConfig(uint32_t in_reg, uint32_t in_mask, uint32_t in_val)
    {
       // unlock the system config registers.
       SYSCONFIG->KICKR[0] = KICK0R_UNLOCK;
       SYSCONFIG->KICKR[1] = KICK1R_UNLOCK;
       
       // make sure the pinmux register is cleared for the mask bits before
       // setting the value.
       CLRBIT(SYSCONFIG->PINMUX[in_reg], in_mask);
       SETBIT(SYSCONFIG->PINMUX[in_reg], in_val);
       
       // lock the system config registers.
       SYSCONFIG->KICKR[0] = KICK0R_LOCK;
       SYSCONFIG->KICKR[1] = KICK1R_LOCK;
    }
    
    //-----------------------------------------------------------------------------
    // \brief   transitions a local psc module to a new state.
    //
    // \param   psc_regs_t *psc - psc register that contains the local module.
    //
    // \param   uint32_t in_domain - input power domain (always on / internal).
    //
    // \param   uint8_t in_module - module to be set.
    //
    // \param   uint8_t in_next_state - next state for the local module.
    //
    // \return  none.
    //-----------------------------------------------------------------------------
    void EVMOMAPL138_lpscTransition(psc_regs_t *psc, uint32_t in_domain, uint8_t in_module, uint8_t in_next_state)
    {
       // spin until existing transitions are done.//�ж��Dz�����ת��״̬��=1ʱ��ʾ��ת��״̬��
       while (CHKBIT(psc->PTSTAT, in_domain)) {}
    
       // if we are already in the requested state...just return.
       if (CHKBIT(psc->MDSTAT[in_module], MASK_STATE) == in_next_state)//MASK_STATE=0x3F
       {
          return;
       }
    
       // setup the transition...clear the bits before setting the next state.
       CLRBIT(psc->MDCTL[in_module], NEXT);//NEXT=0x07 mask
       SETBIT(psc->MDCTL[in_module], in_next_state);
    
       // kick off the transition.
       SETBIT(psc->PTCMD, in_domain);
    
       // spin until transition is done.
       while (CHKBIT(psc->PTSTAT, in_domain)) {}
    
       while (CHKBIT(psc->MDSTAT[in_module], MASK_STATE) != in_next_state) {}
    }
    
    
    //-----------------------------------------------------------------------------
    // helper function to initialize power and sleep config module.
    //-----------------------------------------------------------------------------
    uint32_t init_psc(void)
    {
       //-----------------------------------------
       // PSC0, domain 0 - all modules, always on.
       //-----------------------------------------
    
       // configure the next state for psc0 modules.
       
       EVMOMAPL138_lpscTransition(PSC0, DOMAIN0, LPSC_EMIFA, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC0, DOMAIN0, LPSC_SPI0, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC0, DOMAIN0, LPSC_MMCSD0, PSC_ENABLE);
       EVMOMAPL138_lpscTransition(PSC0, DOMAIN0, LPSC_AINTC, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC0, DOMAIN0, LPSC_UART0, PSC_ENABLE);
       EVMOMAPL138_lpscTransition(PSC0, DOMAIN0, LPSC_SCR0, PSC_ENABLE);
       EVMOMAPL138_lpscTransition(PSC0, DOMAIN0, LPSC_SCR1, PSC_ENABLE);
       EVMOMAPL138_lpscTransition(PSC0, DOMAIN0, LPSC_SCR2, PSC_ENABLE);
    
       //-----------------------------------------
       // PSC1, domain 0 - all modules, always on.
       //-----------------------------------------
    
       // configure the next state for psc1 modules.
       
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_USB0, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_USB1, PSC_ENABLE);
       EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_GPIO, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_HPI, PSC_ENABLE);
       EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_EMAC, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_MCASP0, PSC_ENABLE);
    //    EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_SATA, PSC_ENABLE);
       EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_VPIF, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_SPI1, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_I2C1, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_UART1, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_UART2, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_MCBSP0, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_MCBSP1, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_LCDC, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_PWM, PSC_ENABLE);
    //   EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_MMCSD1, PSC_ENABLE);
       EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_RPI, PSC_ENABLE);  //UPP�� 19
    //    EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_ECAP, PSC_ENABLE);
        EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_SCR8, PSC_ENABLE);
        EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_SCR7, PSC_ENABLE);
        EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_SCR12, PSC_ENABLE);
        EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_SHRAM, PSC_ENABLE);
       
       return (ERR_NO_ERROR);
    }
    
    //-----------------------------------------------------------------------------
    // helper function to initialize cpu, system, and pheripheral clocks.
    // configure arm and dsp to 300 MHz and emif to 133MHz.
    //-----------------------------------------------------------------------------
    uint32_t init_clocks(void)
    {
       uint32_t rtn;
       
       // unlock the system config registers.
       SYSCONFIG->KICKR[0] = KICK0R_UNLOCK;
       SYSCONFIG->KICKR[1] = KICK1R_UNLOCK;
    // //set for 300Mhz C6748   
    //   rtn = config_pll0(0,24,1,0,1,2,5);
    //   rtn |= config_pll1(24,1,0,1,2);
    
     //set for 456Mhz C6748   
       rtn = config_pll0(0,18,0,0,1,4,9);
       rtn |= config_pll1(24,1,0,1,5);
       // enable 4.5 divider PLL and set it as the EMIFA clock source.
    //    SETBIT(SYSCONFIG->CFGCHIP[3], DIV4P5ENA | EMA_CLKSRC);
       
       return (rtn);
    }
    
    uint32_t config_pll0(uint32_t clkmode, uint32_t pllm, uint32_t postdiv, uint32_t plldiv1, uint32_t plldiv2, uint32_t plldiv3, uint32_t plldiv7)
    {
       uint32_t i;
       
       // unlock the system config registers.
       SYSCONFIG->KICKR[0] = KICK0R_UNLOCK;
       SYSCONFIG->KICKR[1] = KICK1R_UNLOCK;
        // unlock pll regs.
       CLRBIT(SYSCONFIG->CFGCHIP[0], PLL0_MASTER_LOCK);
       
       // prepare to enable pll (PLLENSRC must be clear for PLLEN to have effect).
       CLRBIT(PLL0->PLLCTL, PLLENSRC);//ok
       
       // disable external clock source.
       CLRBIT(PLL0->PLLCTL, EXTCLKSRC);
       
       // switch to bypass mode...wait 4 cycles to ensure it switches properly.
       CLRBIT(PLL0->PLLCTL, PLLEN);
       for (i = 0; i < 4; i++) {}
       
       // select clock mode (on-chip oscillator or external).
    	CLRBIT(PLL0->PLLCTL, CLKMODE);
    	SETBIT(PLL0->PLLCTL, (clkmode << CLKMODE_SHIFT));
       
       // reset the pll.
       CLRBIT(PLL0->PLLCTL, PLLRST);
       
       // disable the pll...set disable bit.
    //   SETBIT(PLL0->PLLCTL, PLLDIS);
       
       // PLL initialization sequence
       //----------------------------
       // power up the pll...clear power down bit.
       CLRBIT(PLL0->PLLCTL, PLLPWRDN);   
       
       // enable the pll...clear disable bit.
    //   CLRBIT(PLL0->PLLCTL, PLLDIS);
       
       /*PLL stabilisation time- take out this step , not required here when PLL in bypassmode*/
       for(i = 0; i < PLL_STABILIZATION_TIME; i++) {;}
       
       // program the required multiplier value.
       PLL0->PLLM = pllm;
       
       // program postdiv ratio.
       PLL0->POSTDIV = DIV_ENABLE | postdiv;
       
       // spin until all transitions are complete.
       while (CHKBIT(PLL0->PLLSTAT, GOSTAT)) {}
       
       // program the divisors.
       PLL0->PLLDIV1 = DIV_ENABLE | plldiv1;
       PLL0->PLLDIV2 = DIV_ENABLE | plldiv2;
       PLL0->PLLDIV3 = DIV_ENABLE | plldiv3;
       PLL0->PLLDIV4 = DIV_ENABLE | (((plldiv1 + 1) * 4) - 1);
       PLL0->PLLDIV6 = DIV_ENABLE | plldiv1;
       PLL0->PLLDIV7 = DIV_ENABLE | plldiv7;
       
       // kick off the transitions and spin until they are complete.
       SETBIT(PLL0->PLLCMD, GOSET);
       while (CHKBIT(PLL0->PLLSTAT, GOSTAT)) {}
       
       /*Wait for PLL to reset properly. See PLL spec for PLL reset time - This step is not required here -step11*/
       for(i = 0; i < PLL_RESET_TIME_CNT; i++) {;}   /*128 MXI Cycles*/
       
       // bring pll out of reset and wait for pll to lock.
       SETBIT(PLL0->PLLCTL, PLLRST);
       for (i = 0; i < PLL_LOCK_CYCLES; i++) {}
       
       // exit bypass mode.
       SETBIT(PLL0->PLLCTL, PLLEN);
       
       // lock pll regs.
       SETBIT(SYSCONFIG->CFGCHIP[0], PLL0_MASTER_LOCK);
       
       return (ERR_NO_ERROR);
    }
    
    uint32_t config_pll1(uint32_t pllm, uint32_t postdiv, uint32_t plldiv1, uint32_t plldiv2, uint32_t plldiv3)
    {
       uint32_t i;
       
       // unlock the system config registers.
       SYSCONFIG->KICKR[0] = KICK0R_UNLOCK;
    	SYSCONFIG->KICKR[1] = KICK1R_UNLOCK;
       
       // unlock pll regs.
       CLRBIT(SYSCONFIG->CFGCHIP[3], PLL1_MASTER_LOCK);
       
       // prepare to enable pll (PLLENSRC must be clear for PLLEN to have effect).
       CLRBIT(PLL1->PLLCTL, PLLENSRC);
       CLRBIT(PLL1->PLLCTL, EXTCLKSRC);
       
       // switch to bypass mode...wait 4 cycles to ensure it switches properly.
       CLRBIT(PLL1->PLLCTL, PLLEN);
       for (i = 0; i < 4; i++) {}
       
       // reset the pll.
       CLRBIT(PLL1->PLLCTL, PLLRST);
       
       // disable the pll...set disable bit.
       SETBIT(PLL1->PLLCTL, PLLDIS);
       
       // PLL initialization sequence
       //----------------------------
       // power up the pll...clear power down bit.
       CLRBIT(PLL1->PLLCTL, PLLPWRDN);
       
       // enable the pll...clear disable bit.
       CLRBIT(PLL1->PLLCTL, PLLDIS);
       
       /*PLL stabilisation time- take out this step , not required here when PLL in bypassmode*/
       for(i = 0; i < PLL_STABILIZATION_TIME; i++) {;}
       
       // program the required multiplier value.
       PLL1->PLLM = pllm;
       
       // program postdiv ratio.
       PLL1->POSTDIV = DIV_ENABLE | postdiv;
       
       // spin until all transitions are complete.
       while (CHKBIT(PLL1->PLLSTAT, GOSTAT)) {}
       
       // program the divisors.
       PLL1->PLLDIV1 = DIV_ENABLE | plldiv1;
       PLL1->PLLDIV2 = DIV_ENABLE | plldiv2;
       PLL1->PLLDIV3 = DIV_ENABLE | plldiv3;
       
       // kick off the transitions and spin until they are complete.
       SETBIT(PLL1->PLLCMD, GOSET);
       while (CHKBIT(PLL1->PLLSTAT, GOSTAT)) {}
       
       /*Wait for PLL to reset properly. See PLL spec for PLL reset time - This step is not required here -step11*/
       for(i = 0; i < PLL_RESET_TIME_CNT; i++) {;}
       
       // bring pll out of reset and wait for pll to lock.
       SETBIT(PLL1->PLLCTL, PLLRST);
       for (i = 0; i < PLL_LOCK_CYCLES; i++) {}
       
       // exit bypass mode.
       SETBIT(PLL1->PLLCTL, PLLEN);
       
       // lock pll regs.
       SETBIT(SYSCONFIG->CFGCHIP[3], PLL1_MASTER_LOCK);
       
       return (ERR_NO_ERROR);
    }
    
    //-----------------------------------------------------------------------------
    // prints a chunk of flash data in a readable format.
    //-----------------------------------------------------------------------------
    #ifdef DEBUG
    void UTIL_printMem(uint32_t begin_addr, uint8_t *buffer, uint32_t length, uint8_t continuation)
    {
    #define BYTES_PER_LINE  16
       uint32_t i, j, line_end;
    
       if (!continuation)
       {
          printf("\r\n\r\nPrint Data\r\n");
          printf("----------\r\n");
    
          // print idices across the top.
          printf("address     ");
          for (i = 0; i < BYTES_PER_LINE; i++)
          {
             printf("%02X ", i);
          }
          printf("\r\n");
       }
    
       // print data.
       for (i = 0; i < length; i += BYTES_PER_LINE)
       {
          if (length > (i + BYTES_PER_LINE))
          {
             line_end = (i + BYTES_PER_LINE);
          }
          else
          {
             line_end = length;
          }
    
          printf("\n%08X    ", (begin_addr + i));
          for (j = i; j < line_end; j++)
             printf("%02X ", buffer[j]);
       }
    
       printf("\r\n");
    }
    #endif
    
    //-----------------------------------------------------------------------------
    // looks for the UI gpio expander to see if UI board is attached.
    //-----------------------------------------------------------------------------
    //uint8_t UTIL_isUIBoardAttached(void)
    //{
    //   if (I2CGPIO_init(I2C_ADDR_GPIO_UI) == ERR_NO_ERROR)
    //      return (1);
    //   else
    //      return (0);
    //}
    

  • Hi,

    Can you please provide me the link where you downloaded,

    //upp_config.UPICR.bits.STARTA = 0x01;//使能CHA的START信号(接收模式)
    upp_config.UPICR.bits.ENAB = 0x01;//使能CHB的ENABLE信号(发送模式)add by wh 20140211
    //upp_config.UPICR.bits.STARTB = 0x01;//使能CHB的START信号(发送模式)add by wh 20140211


    Do not comment the both the STARTx lines, Instead,

    upp_config.UPICR.bits.STARTA = 0x01;//使能CHA的START信号(接收模式) // Enable START signal since It is in Rx mode

    upp_config.UPICR.bits.STARTB = 0x0;//使能CHB的START信号(发送模式)add by wh 20140211 //// Disable START signal since It is in Rx

  • set as below:

    upp_config.UPICR.bits.STARTA = 0x01;//使能CHA的START信号(接收模式)

    upp_config.UPICR.bits.ENAB = 0x01;//使能CHB的ENABLE信号(发送模式)add by wh 20140211
    upp_config.UPICR.bits.STARTB = 0x00;//使能CHB的START信号(发送模式)add by wh 20140211

    There still have 2 START pulse!

    The example code is provied by the 3rd support from Arrow SEED (HK) Limited Co.(北京艾睿合众科技有限公司)

    4274.02.Test Demos under CCS.rar

  • Hi,

    Ensure your configuration that you have modified from original,

    Is this affects the performance of uPP or even not able to initiate the transfer?

  • Dear  

               The code mostly is wrote by myself,and I watch the registers,It is seemly right .

    I have some snap picture of registers setting.

     best rregards! 

  • Hi,

    "Is this affects the performance of uPP or even not able to initiate the transfer?"

    reply: This problem affects little,the code of FPGA now can work well,I just want to know the trues.

    Thanks anyway.

  • Hi,

               The code mostly is wrote by myself,and I watch the registers,It is seemly right .


    Please refer the chapter 33.2.6.2 & 33.2.6.3 in TRM to tune the uPP,