Thanks Melanie.
I didn't mean to pester you.
The list has been behaving a little strange for me the last couple of days and the fact that it said I had put three posts up and could only find two had me wondering.
I'll email Lester about it though.
Anyway, I do indeed understand how timing critical serial I/O is, and I do not want to upset that. However, I've found a way to implement what I was trying to accomplish using the USART example (USART.bas) that comes with PBP. I never could get that example working (if anybody knows of any known bugs please let me know) but I found a work around.
In my project, the Slave (PIC) is constantly listening for a start character that indicates that an ID name (2 characters) is coming next. I simply used HSERIN before with no timeout value. The program would just sit there until the start symbol appeared and then would proceed. I wanted to use the USART sample that's given with PBP and, within that code, tickle an external watchdog circuit with a pin on the PIC, but I couldn't get the sample code to work . However, I managed to accomplish what I wanted using HSERIN. What I've done now is implement a short (1ms) timeout at the point where I receive my first character. Before the HSERIN is performed I toggle the watchdog pin. If there is a timeout in 1ms (i.e. the start character is not received) I go back and listen again and toggle the watchdog pin again. The watchdog device I'm using requires a state change at least every 700ms or else it will drive MCLR low and reset the micro.
Now, regarding the AtoD converter. I don't mind doing 5 of my AtoD conversions on a need to know basis, but I do want to keep a constant eye on the pre-regulated input voltage. What I plan to do is initiate an AtoD conversion after 1 timeout (in the loop that looks for the start character) and then check to see the result at the next timeout. This would mean that I'd be doing an AtoD conversion every 2ms. This would take a back seat when servicing the serial commands (i.e. acting on them) but that's OK. I'm going to put a pretty good sized capacitor on the regulator's output to give me the time I need to "take care of business" in case the input voltage drops.
I'm not really going for speed with this project. I want something that is incredibly stable and error proof.
Anyways, as always, thanks again Melanie. If anybody else has any comments or suggestions feel free.
Bookmarks