2012-09-13 07:12 AM
2012-09-13 04:40 PM
You need to stop doing the while() loops and SendString functions under interrupt, they will soak up way too much time, causing data in the in bound USART to overrun. You might also need to consider checking for, and clearing, USART errors.
Your interrupt routine should look more like this.unsigned char rxData[4];
uint8_t rxDataCount = 0;
void USART1_IRQHandler(void)
{
if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
rxData[rxDataCount++] = USART_ReceiveData(USART1);
if (rxDataCount >= sizeof(rxData)) rxDataCount = 0;
}
}
2012-09-14 11:20 AM
2012-09-14 01:07 PM
The exact order of actual info when buffer is increased to 6 instead of 4 is:
13, 10, 51, 45, 48, 572012-09-14 01:21 PM
I would also like some pointers to see if there is a better way to handle the sending of data then what I am currently doing (through interrupt, by checking certain flags, handling the tx execution differently).
You need to implement some FIFO (ring/circular) buffers, which separate the foreground function of stuffing characters/strings into the buffer, and the background (interrupt) routine which deals with the byte going to the USART.2012-09-17 05:47 AM
Any ideals on my receive issues?
2012-09-17 08:16 AM
Any ideals on my receive issues?
Not really, I don't know the nature of the data stream you expect to be receiving. If you are expecting multiple bytes you going to have to figure out how to store and process that data, and resynchronize the stream if it starts mid sequence. 10, 13 is suggestive of a <CR> <LF> end of line markers, in which case you should design your code to parse/process lines of data, and restart when you get a new line. Also be aware that a 16-bit unsigned value is never going to be bigger than 65535, so testing for that condition isn't going to be helpful.
2012-09-17 08:51 AM
intTimes = 32 when the receive interrupt stops. Doesn't this mean there was 32 bits received thus 4 chars worth of info - the 48, 57, 13, 10? So why when just the buffer size increases to 6 I get values for RxBuffer[4] and RxBuffer[5] when intTimes remains at 32? It seems as though RxBuffer[4] and RxBuffer[5] should remain at their original values since the interrupt did not execute more than 32 times.
void USART1_IRQHandler(void) { //Receive Interrupt Handler if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET){ intTimes++; if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET){ RxBuffer[RxCount++] = USART_ReceiveData(USART1); if (RxCount >= sizeof(RxBuffer)) RxCount = 0; } } }2012-09-17 09:06 AM
intTimes = 32 when the receive interrupt stops. Doesn't this mean there was 32 bits received thus 4 chars worth of info - the 48, 57, 13, 10? So why when just the buffer size increases to 6 I get values for RxBuffer[4] and RxBuffer[5] when intTimes remains at 32? It seems as though RxBuffer[4] and RxBuffer[5] should remain at their original values since the interrupt did not execute more than 32 times.
2012-09-17 10:09 AM
The interrupt does not occur on a bit basis. In the case of the receive it occurs when a framed byte (start, 8 bits, stop) enters the holding buffer.
If the interrupt has occurred 32 times, you need a significantly larger buffer to hold the incoming data.