We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi. I'm working on a project involving a java program and the micro controller NXP P89v664.
The java program which utilises the RXTX package, outputs to the serial port a string of characters to be deciphered by the micro controller.
My java program is completed and outputs correctly as checked by virtual com ports and a c program.
I have written a keil c program to receive the input but I somehow receive random inputs instead.
I used the _getkey() fuction to receive the input and putchar() function to check the output.
I'm new to keil c can anyone shed some light on this pls?
Thanks.
Most circular buffer software is written incorrectly. There are several things you need to know with circ buffers.
To accomplish all of these, you obviously need a buffer, a next-in pointer (or index), and a next-out pointer (or index). Generally, you can figure out the amount of data in the buffer by subtracting the next-out from next-in (with a modulo). However, if the result is 0, does that mean that the buffer is full or empty? This is where most circ buffer implementations fall apart.
Choosing a buffer size that is a power of 2, and using indexes for next-in and next-out, and NOT mod'ing the indexes after an increment, it is easy to answer the questions of the list above.
This is how the serial I/O routines work that I wrote when I was at Keil. This is found at http://www.keil.com/download/docs/200.asp.
The examples listed in this thread look mysteriously like the code I wrote way back when.
Jon