Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by jwilson

  1. Thanks for the clarification. I didn't even think about how the pushbutton would call the interrupt twice. I do not have to go to sleep, the second version I posted works great and is less code. I just wanted to know what I was doing wrong and why it wouldn't work. In the past I have always implemented an interrupt using the timer. On the final version of this project I also plan to use a timer. The main reason for my questions were to learn about what I was doing wrong and how to solve them in case it ever presents itself again. Again thanks for the help, you cleared it up fo
  2. I just tried only disabling the RAIF bit and it works also. I can only assume that bringing the GIE = 0 affects the delay_s function. I really would like conformation that I am not insane though. Haha
  3. Reynard, that didn't fix it either. But I did find something that did. Maybe you can shed some light as to exactly why. Simply removing the interrupt disable command solved my problem. Does making GIE=0 effect the delay_s routine? //intcon &= 0x7F; //disable interrupts
  4. I tried this with no changes. If it will help to point out the problem... the following code works. It accomplishes the same goal but I wanted to use sleep mode and have to find out what in the world is keeping the original code from working correctly. //----------------INITIATE------------------- void initiate(void) { option_reg = 0x00; // bit 7=0 enable pullups // bit 6=0 don't care // bit 5=0 Fosc/4 = tmr0 clock // bit 4=0 don't care // bit 3=0 prescaler assigned to tmr0 // bits 2-0=000 prescale = 1:2 (won't use) cm1con0 &= 0x7F; //turn comparator cm2con0 &=
  5. Hey guys I am working on an extremely simple project, but I am beating my head trying to get it to work the way I want. If you look down you will see that I call the delay_s function two times. I did this because on the final version of the software I will have to delay for a few minutes, therefore I will go over the 255 maximum for the delay functions (unless this has changed). What is happening is that my delay is twice what it should be. I have commented out the second delay function call and still with a single function call I am getting twice the time. I am sure there is something
  6. I didn't even think about if no digits were there. My way would give me an endless loop, and that is not good. I am still a little wet behind the ears at coding, I really appreciate the help you have given me. Thanks yet again.
  7. Does this look okay? The array rx_buffer is global. unsigned int weight() { char *weight_ptr; unsigned int weight_int; unsigned char digit_flag; unsigned char j; for(j=0; digit_flag != 0; j++)//find where digits start { digit_flag = isdigit(rx_buffer[j]); } weight_int = strtoi(&rx_buffer[j], &weight_ptr, 10);//convert string to int return weight_int;
  8. In your example lets say the string was "ABCD1234" instead. Would you set *myBuf to point at mybuffer[4] instead of starting at the front of the array?
  9. I am receiving ASCII characters in my UART and storing them into a character array. I need to take 3 or 4 of those chars in the array and evaluate them. They will be one number (e.g. 139). I know how I can do this a sloppy way, just taking each char, converting to decimal, etc. What I wanted to know was if there was a built in function that would basically do this for me? I found this function in the manual, but was a little unclear on how it worked. Can anyone give me a little more information on it and its uses?
  10. Guys someone local needs to come give me a swift kick in the you know what. I started thinking.... If my micro can communicate with my PC just fine and the scale can communicate with the PC just fine, what is the deal. Then it hit me. The TX and RX wires are backwards when I connect my micro to the scale. I just didn't catch it before. So I switched that and everything worked beautifully the way it should regardless of the oscillator. Thanks for all of the help guys, I learned a lot.
  11. Currently I am using the STX command as a qualifier, then placing the data into my array after that. I really don't think that part is my issue now, but I will note that and try it if the crystal doesn't provide any improvements. Thank you for your suggestions.
  12. The load cell is already connected and the entire system has been calibrated. The display that you see above is with my weight on it (182.8 lbs), it follows the data stream perfectly. When I add more weight or less weight the value changes exactly like it is supposed to.
  13. Raghunathan, Below is the setup for the serial port on the weight indicator. Some of this won't pertain to the protocol at all. EDP = 9600/8NONE/CR/OFF Print (not used though) = 9600/8NONE/CR STREAM = EDP STMDLY = 1SEC PRNDES = EDP PROTCT = DISABLE
  14. BTW I have played with Advanced Serial Port Terminal and it is really great. Thank you for that tip. Haven't tried the only Reynard suggested...will try it next.
  15. So do you think if I change to the crystal I will still see my problem?
  16. Well currently I have an error rate of 0.16% at 8MHz. My problem is my 8MHz is not accurate either. Maybe I am wrong but I thought I read where the internal oscillator can be up to 5% off?
  17. Thank you for the suggestions. I am talking with my work now about taking home an oscope for the weekend. I was curious about the accuracy of the other device also, if it is a little off of 9600 then that could be my problem. I KNOW that I am off up to 5% using the internal oscillator. I have an 11.0592MHz crystal on the way, should be here tomorrow. That will give me precisely 9600 baud. I can at least eliminate that from my troubleshooting. If that doesn't solve my problem, I will try the OSCTUNE method that you explained above. I hope that is doesn't come to that, because it w
  18. Can someone verify or not whether the internal oscillator could make my baud rate work while connected to a PC but not to another embedded device?
  19. Thank you for the tip. Seeing the values will be much nicer than what hyperterminal provides. I downloaded the program, looks to have a 14 day trial and then it is $40. That will give me enough time to see how much I like it.
  20. Answered my own question about the smiley face... it is what hyperterminal prints when an STX command is received.
  21. I attempted to run this code on the device that I plan to talk to in the main design. This device is a weight indicator, it sends continuous streams (every 1 second) of data. I connected my computer to this indicator and I could view the data perfectly. This is a sample of the data that hyperterminal displayed (what does the smiley face mean?). When I connected my breadboard instead of my computer it would not work. I wrote the above code in order to obtain the data from the indicator. The data stream format for the indicator is: So the first character that is send
  22. Null at the end of my string worked great!! If you were local I would buy you a beer sir! Thanks!!
  23. Great idea. I will do that now. Man I love Sourceboost and this forum. You guys are so helpful. Thanks yet again
  • Create New...