Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About jonathan03

  • Rank
  1. I'm working on using my own RS232 implimentation because it takes some time for me to get the next character I want to send. My goal is to have something like this: 1) Write a character to the transmit buffer. 2) Return to code to get the next character to send while the previous character (in step 1) is being sent. 3) Send the next character when the transmit buffer is empty. Ideally, I will have no delays. I want to check when the transmit buffer is empty, then send the next character. The problem that I'm having is to do with knowing when the transmit buffer is empty. I am looking for a flag that indicates that the entire word has been sent, including start, stop and other bits. TXIF is low just for a short time after writing to the transmit buffer. TRMT goes low too late and ends before the stop bit is sent. This is almost what I want: void sendCharacter() { //check if its ok to send if(txsta & (0<<TRMT) || pir1 & (0<<TXIF)) return; //trying to send before the last character was sent txreg = outputBuffer[lastpos]; //these are globals //i use a circular output buffer to hold the data to send //the main loop calls send character with NO delay //this allows for other processing while the data is being sent (i.e. to calculate any additional data to transmit more efficently } This code almost works but I miss about half of the characters. (I verfied this by using a delay). The nulls are almost always missed with the above code as well. Are there any flags that indicate when the stop bit has been sent? Thanks for the help.
  2. Does using a higher baud use more power though? I'm by no means a hardware expert, but I would think that a higher transmission rate would draw more power. I was wondering about that, maybe someone knows for sure? I'm working ona project that sends 7 bytes about every 10 minutes. I need the battery life of my circuit to be as good as possible, but I don't really need a fast transmission rate. I'm not even sure how one would calculate the power used by an IC. Do you just connect an ammeter and multiply? Anyway, it would be an interesting test. Would any additional power used even be significant? I am still learning hardware so I'm not sure either way. Any ideas?
  3. Bug description: If a fucntion is called with arguements of two or more other functions that return a value, the same value is used for all parameters. Steps to reproduce: unsigned char MyFunctionOne() { ........... return 2; } unsigned char MyFunctionTwo() { return 17; } void TwoParameterFunction(unsigned char one, unsigned char two) { ....... any code } void main() { TwoParameterFunction(MyFunctionOne(), MyFunctionTwo()); //instead of TwoParameterFunction(2,17); what happens is //TwoparameterFunction(2,2); /* //the fix usigned char tmp; tmp = MyFunctionTwo(); TwoparameterFunction(MyFunctionOne(), tmp); */ } Expected behaviour: Should be able to call a function with arguements that are the result of two other functions. Is the problem 100% reproduceable: Happens all the time. IDE version: 6.15 Compiler: BoostC Compiler version: 6.15? (Not sure how to tell) Target device: PIC16F628 OS: Windows XP Comments: I think that the problem is that the compiler puts the result of a function call in the working register (w). There doesn't seem to be logic to store one of the values to a temporary register. From the assembly code, it looks like all return values are put in w. Also, this code results in a bug too. MyArray[MyFunctionOne()] = TwoParameterFunction(MyFunctionOne(), MyFunctionTwo()); //is the same as //MyArray[2] = TwoParameterFunction(2, 2); //and MyArray[MyFunctionOne()] = OneParameterFunction(MyFunctionOne()); //is the same as //MyArray[2] = TwoParameterFunction(2);
  • Create New...