2006-11-22 05:37 PM
2011-05-17 02:31 AM
Hi everybody!
i am writing driver code for uart(of str912fw44) i am very new to this processor i was working with LPC21xx from past 2 weeks i am into this st and i have my deadline nearing please help me by telling what is wrong in my code and i havenot found datasheet for str912fw44 can anyone help me with that and help with my driver code void main() { uint8_t a[5]; UART_InitTypeDef UART_InitStructure; void SCU_Configuration(void); void GPIO_Configuration(void); #ifdef DEBUG debug(); #endif /* Configure the system clocks */ SCU_Configuration(); /* Configure the GPIO ports */ GPIO_Configuration(); UART_InitStructure.UART_WordLength = UART_WordLength_7D; UART_InitStructure.UART_StopBits = UART_StopBits_2; UART_InitStructure.UART_Parity = UART_Parity_No ; UART_InitStructure.UART_BaudRate = 9600; UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_RTS_CTS; UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; UART_InitStructure.UART_FIFO = UART_FIFO_Enable; UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */ UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */ UART_DeInit(UART0); UART_Init(UART0, &UART_InitStructure); /* Enable the UART0 */ UART_Cmd(UART0, ENABLE); UART_ReceiveData(UART0, &a[0] ); UART_SendData(UART0, a[0]); } void SCU_Configuration(void) { /* Enable the UART0 Clock */ SCU_APBPeriphClockConfig(__UART0, ENABLE); /* Enable the GPIO2 Clock */ SCU_APBPeriphClockConfig(__GPIO2, ENABLE); /* Enable the GPIO3 Clock */ SCU_APBPeriphClockConfig(__GPIO3, ENABLE); /* Enable the GPIO5 Clock */ SCU_APBPeriphClockConfig(__GPIO5, ENABLE); } void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; /*Configure UART0_CTS P2.0*/ GPIO_DeInit(GPIO2); /*After DeInit function P2.0 = UART0_CTS (defaut configuration)*/ GPIO_DeInit(GPIO5); /*Gonfigure UART0_Rx pin GPIO5.1*/ GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; GPIO_Init (GPIO5, &GPIO_InitStructure); GPIO_DeInit(GPIO3); /*Gonfigure UART0_Tx pin GPIO3.4*/ GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3 ; GPIO_Init (GPIO3, &GPIO_InitStructure); /*Gonfigure UART0_RTS pin GPIO3.3*/ GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3 ; GPIO_Init (GPIO3, &GPIO_InitStructure); } void UART_SendData(UART_TypeDef* UARTx, uint8_t Data) { //while ((UARTx->FR & 0x0060)==0); // UARTx->FR |= UART_Enable_Mask; /* Transmit one byte */ UARTx->DR = Data; } /******************************************************************************* * Function Name : UART_ReceiveData * Description : Returns the most recent received Byte by the UARTx peripheral. * Input : UARTx: where x can be 0,1 or 2 to select the UART peripheral. * Output : None * Return : The received data *******************************************************************************/ uint8_t UART_ReceiveData(UART_TypeDef* UARTx,uint8_t *pdata ) { //while(!(UARTx->DR & 0x00ff)==0); /* Receive one byte */ *pdata = UARTx->DR; // return ((uint8_t)UARTx->DR); return 0; } please see whether my send data and receive data modules are correct Thanking all of u all in advance please do help me since i am very new to this microcontroller and this field tooo ,