- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I wrote a program to process data from PC through uart, but there is something wrong.
<div class='quotetop'>QUOTE </div> --- Quote Start --- main() { ...... init_uart0(); ...... while(1) { if(uart0_rbuf_out_cnt != uart0_rbuf_in_cnt ) { ...... } } }[/b] --- Quote End --- I receive data in uart0_ISR(), if there is one new byte, at first put it into the uart0_rbuf, and then the uart0_rbuf_in_cnt add 1. The problem is when (uart0_rbuf_out_cnt != uart0_rbuf_in_cnt ) is true, it can not go into the program to process the data. What's the matter?Thanks.Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
define uart0_rbuf_out_cnt and uart0_rbuf_in_cnt variable as volatile, for example: volatile int uart0_rbuf_out_cnt if not, the compiler optimize these variables because they aren't managed in the main program...- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page