UART PRBLEM with STM32F3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-01-30 1:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-01-30 11:08 AM
You IRQHandler is weird
You spin on RXNE when you should just test it, that's why it entered.You spin on TXE *AFTER* sending data, if you absolutely must spin, do it BEFORE, otherwise you might dwell for over a character time.Check the framing error in status register, if you get it a lot scope the data to understand why there is an issue with the timing, and why this might be occurring. Check that your clocks are correct.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-01-30 1:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-01-30 1:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-01-30 2:05 PM
I though I described why. Generally you want to avoid while() loops in interrupts, especially when you might get stuck there for extended periods, or forever.
void USART1_IRQHandler(void)
{
if (USART_GetITStatus(USART1, USART_IT_RXNE))
{
/* Read one byte from the receive data register */
rx_buffer[rx_counter] = USART_ReceiveData(USART1) & 0x7F;
/* Loop until transmit data register is empty, spin if we must */
while(!(USART1->ISR & USART_FLAG_TXE));
/* Put character on the serial line */
USART1->TDR = 25; // '%'
if (((rx_counter + 1) >= RX_BUFFER_LENGTH) ||
(rx_buffer[rx_counter] == '
') ||
(rx_buffer[rx_counter] == '
'))
{
rx_counter = 0;
}
else
{
rx_counter++;
STM_EVAL_LEDToggle(LED4);
}
}
}
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-01-31 8:53 AM
I've tried your modification but still have the same problems, the
USART1_IRQHandler
is executed even if no data is sent and when i send something, i can receive and send but the wrong data. An other thing is that the ''FE'' is always set.I can't really see what would be the problem.Thanks for your help- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-01-31 9:14 AM
What USB UART are you using? The pins of the STM32 are NOT RS232 level compatible.
Have you tried sending a stream of characters ('U') from the STM32 and observed the signal on the TX pin? Use a scope, verify the bit timing. Have you tried looping the TX and RX pins of the STM32 and determined you can send/receive data correctly there?Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-01-31 9:31 AM
1) USB To serial type device FTDI (made in china !! )
2) not yet, i ll do it3) not yet, i ll do it Thanks for this remarks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-02 1:35 PM
Have you tried looping the TX and RX pins of the STM32 and determined you can send/receive data correctly there? : I have tried this but doesn't work, i really don't know what going with my code. An other thing the RDR and TDR contains the value sent and received but the bit RXNE never set.
My main is below : int main(void) { /* Initialize USART communication */ USART1_Init2(9600); while(!(USART1->ISR & USART_FLAG_TXE)); /* Put character on the serial line */ USART1->TDR = 25; // '%' STM_EVAL_LEDOn(LED5); if ((USART1->ISR & USART_FLAG_RXNE)) { /* Read one byte from the receive data register */ rx= USART_ReceiveData(USART1) & 0x7F; STM_EVAL_LEDOff(LED5); } while(1){}; }- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-02 4:36 PM
Are you sure PB6/PB7 are appropriate for the STM32F3-DISCO, don't they clash with the I2C of the LSM device?
Why can't you use PA9/PA10 which are actually free?Up vote any posts that you find helpful, it shows what's working..
