We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi All,
I add the UART code into EMI example from the ST and compile the following code with the configuration Options->Target -> off-chip RAM1 0x3c000000 size 0x400000 -> on-chip IRAM1 0x4000000 size 0x18000
The message " EMI Example ***" cannot be sent to the Hyperterminal. However, the EMI works fine.
Anyone has experiences with EMI and UART? Could you please point out where I am wrong? Greatly appreciate your help.
u8 TxBuffer[] = "EMI Example ****\n\r" int main() {
#ifdef DEBUG debug(); #endif
/*CPU running @96MHZ*/ MCLK_Config ();
/* Configure the system clocks */ SCU_Configuration();
/* Configure the GPIO ports */ GPIO_Configuration();
/* UART0 configuration -------------------------------------------------------*/ /* UART0 configured as follow: - Word Length = 7 Bits - Two Stop Bit - No parity - BaudRate = 115200 baud - Hardware flow control enabled (RTS and CTS signals) - Receive and transmit enabled - Receive and transmit FIFOs are enabled - Transmit and Receive FIFOs levels have 8 bytes depth */ UART_InitStructure.UART_WordLength = UART_WordLength_8D; UART_InitStructure.UART_StopBits = UART_StopBits_1; UART_InitStructure.UART_Parity = UART_Parity_No ; UART_InitStructure.UART_BaudRate = 115200; UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None; UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; UART_InitStructure.UART_FIFO = UART_FIFO_Disable;
UART_DeInit(UART0); UART_Init(UART0, &UART_InitStructure);
/* Enable the UART0 */ UART_Cmd(UART0, ENABLE);
/* EMI default configuration : Reset configuration*/ EMI_DeInit();
/**************************EMI configuration*********************************/
EMI_StructInit(&EMI_InitStruct); /* Number of bus turnaround cycles added between read and write accesses.*/ EMI_InitStruct.EMI_Bank_IDCY = 0x3 ;
/* Number of wait states for read accesses*/ //EMI_InitStruct.EMI_Bank_WSTRD = 0x3 ; EMI_InitStruct.EMI_Bank_WSTRD = 0x5 ; /* Number of wait states for write accesses*/ //EMI_InitStruct.EMI_Bank_WSTWR = 0x3 ; EMI_InitStruct.EMI_Bank_WSTWR = 0x4 ;
/*Output enable assertion delay from chip select assertion*/ EMI_InitStruct.EMI_Bank_WSTROEN = 0x2;
/*Write enable assertion delay from chip select assertion*/ EMI_InitStruct.EMI_Bank_WSTWEN = 0x2;
/*This member Controls the memory width*/ EMI_InitStruct.EMI_Bank_MemWidth = EMI_Width_HalfWord;
/*Write protection feature */ EMI_InitStruct.EMI_Bank_WriteProtection = EMI_Bank_NonWriteProtect;
/*Use Bank1 (CS1)*/ EMI_Init( EMI_Bank1, &EMI_InitStruct);
/* Send a buffer from UART to hyperterminal */ while(NbrOfDataToTransfer--) { UART_SendData(UART0, TxBuffer[TxCounter++]); while(UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull) != RESET);
}
while (1) {
/*Write in the external memory*/
for (k = 0; k < 32; k++)
*(u16*)(0x3C000000 + (k*2)) = Buffer_Write[k] ; // *(u16*)(0x3C000000 + (k*2)) = 0x0101 ;
/*Read from the external memory*/
Buffer_Read[k] = *(u16*)(0x3C000000 + (k * 2)) ;
/*Comparaison*/
/* Check the received data with the send ones */ TransferStatus = Buffercmp(Buffer_Write, Buffer_Read, 32);
if (TransferStatus != 0) UART_SendData(UART0, (u8)(TransferStatus+48));
} /******************************************************************************* * Function Name : SCU_Configuration * Description : Configures the system clocks. * Input : None * Output : None * Return : None *******************************************************************************/ void SCU_Configuration(void) {
/* Enable the clock for EMI*/ SCU_AHBPeriphClockConfig(__EMI | __EMI_MEM_CLK, ENABLE);
/*BCLK=96Mhz*/ SCU_EMIBCLKDivisorConfig(SCU_EMIBCLK_Div1);
/*Enable the Mux mode*/ SCU_EMIModeConfig(SCU_EMI_MUX);
/*ALE length and polarity definition*/ SCU_EMIALEConfig(SCU_EMIALE_LEN1, SCU_EMIALE_POLHigh);
/* Enable the GPIO7 Clock */ SCU_APBPeriphClockConfig(__GPIO7 , ENABLE); SCU_APBPeriphReset(__GPIO7,DISABLE);
SCU_APBPeriphClockConfig(__UART0, ENABLE); SCU_APBPeriphReset(__UART0,DISABLE);
/* Enable the GPIO2 Clock */ SCU_APBPeriphClockConfig(__GPIO2, ENABLE); SCU_APBPeriphReset(__GPIO2,DISABLE); /* Enable the GPIO3 Clock */ SCU_APBPeriphClockConfig(__GPIO3, ENABLE); SCU_APBPeriphReset(__GPIO3,DISABLE);
/* Enable the GPIO8 Clock */ SCU_APBPeriphClockConfig(__GPIO8, ENABLE); SCU_APBPeriphReset(__GPIO8,DISABLE); /* Enable the GPIO9 Clock */ SCU_APBPeriphClockConfig(__GPIO9, ENABLE); SCU_APBPeriphReset(__GPIO9,DISABLE);
/******************************************************************************* * Function Name : GPIO_Configuration * Description : Configures the different GPIO ports. * Input : None * Output : None * Return : None *******************************************************************************/ void GPIO_Configuration(void) { /* GPIO8,GPIO9 Configuration*/
GPIO_EMIConfig(ENABLE);
/* GPIO7 Configuration */ GPIO_DeInit(GPIO7); GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; /* GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 ; */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ; GPIO_Init (GPIO7, &GPIO_InitStructure);
//uart0 setup
GPIO_DeInit(GPIO3); /*Gonfigure UART0_Rx pin GPIO3.0*/ GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; GPIO_Init (GPIO3, &GPIO_InitStructure);
/* GPIO_DeInit(GPIO3); */ /*Gonfigure UART0_Tx pin GPIO3.1*/ GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ; GPIO_Init (GPIO3, &GPIO_InitStructure); }