2008-04-14 08:59 PM
2011-05-17 12:52 AM
Dear All,
I am using UART0 of STR9, I am abled to transmit the data to PC. I have made one simple function which takes string as input & transmits data byte by byte on UART with help of ST library function UART_SendData(). When I calls that function through while( 1 ), it gives junk chars on PC. Other every thing is right i.e. baud rate & other parameters on both ends. I tried to check busy flag to let UART transmit data completely, I have also tried other flags also like FIFO Empty/Full flag, but still it is giving junk chars at PC end. I will be very thankful if anybody tell me the solution. :-[2011-05-17 12:52 AM
are you FIFOs working?
2011-05-17 12:52 AM
Yes FIFOs are enabled
2011-05-17 12:52 AM
''Garbage characters'' is usually a sign of a mismatch in baud rates or word size. Are you sure the clock source is at the frequency you think it is?
2011-05-17 12:52 AM
post your register values please.
2011-05-17 12:52 AM
Dear Michael & JakBird Thanks for replying,
I am using Library given by ST. If I print string through before while it gets on PC properly therefore I think that baud rate setting is not problem. My code is as follows after configuring PLL for 96MHz. /* Enable the UART0 Clock */ SCU_APBPeriphClockConfig(__UART0, ENABLE); /* UART Initialization */ 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 = 9600; UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None; 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); /* Following is the code in main */ sprintf( acString,''Any String''); Uart0printf( acString ); <----This line works properlywhile ( 1 ) { Uart0printf( acString ); <----This line doesn't work properly } Following is the function which I am using for printing a stringvoid Uart0printf( char *pcString ) { while( *pcString != '\n' ) { UART_SendData( UART0, *pcString); while(UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull) != RESET); At above position I have also tried some other flags & there SET, RESET values, even UART_Clear function also used pcString++; }//while }//Uart0printf Please tell me if any mistake in above code.2011-05-17 12:52 AM
Dear All,
Problem is solved. Mistake was in checking '\n' in place of NULL. After correcting it I just added ''while(UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull) != RESET);'' after char send API. Now it is working fine in while also. Thanks :D