2016-04-02 03:40 AM
Hi,
I am facing some weird problem in UART.Whenever i am using UART in polling to receive the data followed by storing the data into some array. But what is happening is that the array is sometimes(mostly) starts to fill from some random index that is sometimes it start to fill the data from array index 5 or sometimes 6 and so on. It does not fill the array from the starting indices of the array that is from index 0.My code is all right, checked many times but couldn't resolve the issue.Please help! #uart #stm32 #uart #standard-peripheral2016-04-02 04:52 AM
Dear moradiya.bhavesh,
What are the values filled at initial indexes of array. Are these similar every time or different. Are you taking care of Array overflow?Could you share your polling code?/*Please
mark helpfull
if this post helps you or solves your problem.*/
/* If you need any personal support for your work please contact at
embeddeddesign.help@gmail.com*/
2016-04-02 06:01 AM
The microcontroller has evaluated your code and disagrees. Show enough of the salient code so it can be evaluated here.
What tests have you done to prove two way communication with the usart is working properly.2016-04-05 12:17 AM
Hello,
Thanks for your time.Actually when I am receiving data from serial terminal using USART receive function & data is captured in an array, then first few location were getting skipped & then I am able to receive the data.Secondly, when data is received then first byte of data from serial terminal was lost using USART receive function.NOTE: Complete data is important for me because I am performing OTA update or you can say IAP to reprogram the flash memory from GPRS.j = 0;for (int p = 0; p<=1024; p++){ while(1) { while(USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET); data_receive2[j]= USART_ReceiveData(USART2); if(j == 1024) { j = 0; break; } j++; //if (j != 1024) //break; }}can i use pointer instead of array ?if yes, then how pointer can be beneficial for directly copying data into flash memory?Please suggest some suitable solution to resolve this issue.2016-04-05 09:44 AM
You increment j in the wrong spot, causing blocks of 1025 bytes to overflow a 1024 buffer. And will cause the data to appear to precess from block to block.
You just seem to be pulling a stream of 1MB of data, I think you need to packetize and manage it in some manner, especially if you are considering writing to flash, as this stalls the processor and will result in data loss, unless you have some form of flow control. Coding solutions is beyond the scope of my participation here.